syntax error line unexpected ';'

The problem I’m having

syntax error line unexpected ‘;’

The context of why I’m trying to do this

I am creating a model that merge two stages together. The purpose of the unified staging model is that I want to apply common transformations into unified staging model. When I tried to run the model, I got following error message. This is my first dbt model I am working on. So I dont have lot of expertise. I tried to troubleshoot but didn’t resolve it. The error is shown below

with unified_staging as (

    select 'CompassPlanInfo' as source_table, 
    PLAN_SERVICE, TECHNOLOGY, PRICE, PEAK_INFORMATION_RATE,
    COMMITTED_INFORMATION_RATE, DATA_CAPS, RETAIL_WHOLESALE, PROVIDER,ENDING_PERIOD        from {{ ref('stg_CompassPlanInfo') }}
    union all
    select 'ContactEnergyPlanInfo' as source_table, 
    PLAN_SERVICE, TECHNOLOGY, PRICE, PEAK_INFORMATION_RATE,
    COMMITTED_INFORMATION_RATE, DATA_CAPS, RETAIL_WHOLESALE, PROVIDER,ENDING_PERIOD  from {{ ref('stg_ContactEnergyPlanInfo') }}
    
)

SELECT * FROM unified_staging;

Error:

SELECT * FROM unified_staging;
10:38:20 Opening a new connection, currently in state closed
10:38:20 Snowflake adapter: Snowflake query id: 01b2037e-0001-159a-0000-24d903524772
10:38:20 Snowflake adapter: Snowflake error: 001003 (42000): SQL compilation error:
syntax error line 15 at position 29 unexpected ‘;’.
10:38:20 Timing info for model.comcom_techops_dbt_poc.unified_staging_planserviceinfo (execute): 10:38:19.984186 => 10:38:20.273517
10:38:20 On model.comcom_techops_dbt_poc.unified_staging_planserviceinfo: Close
10:38:20 Database Error in model unified_staging_planserviceinfo (models/mart/RCS/unified_staging_planserviceinfo.sql)
001003 (42000): SQL compilation error:
syntax error line 15 at position 29 unexpected ‘;’.
compiled Code at target/run/comcom_techops_dbt_poc/models/mart/RCS/unified_staging_planserviceinfo.sql
10:38:20 1 of 1 ERROR creating sql table model dbt_ymuhammad.unified_staging_planserviceinfo [ERROR in 0.37s]
10:38:20 Finished running node model.comcom_techops_dbt_poc.unified_staging_planserviceinfo

I could not find any semi-colon in the code to resolve the issue. Any help would be really appreciated. Thanks.

There is a semicolon after unified_staging, have you tried removing it?

dbt wraps your query so that’s probably causing problems. It’s added a couple of lines due to the wrapper but that’s the location it means when it says line 15 position 29

Note: @Mike Stanley originally posted this reply in Slack. It might not have transferred perfectly.