session.sql() causes error in Incremental DBT Python model

105 Views Asked by At

I have a created an incremental python model in DBT like this:

import pandas as pd

def model(dbt, session):
    dbt.config(materialized = "incremental")

    temp_df = pd.DataFrame({ 'plan_name' : ['a','b','c','x','y','z'], 'en_plan_name' : ['A','B','C','X','Y','Z']})

    if dbt.is_incremental:
        existing_plans = session.sql(f'SELECT * FROM {dbt.this}')
        existing_plans = existing_plans.toPandas()

        df = temp_df[~temp_df['plan_name'].isin(existing_plans['plan_name'])]
    

    return df

DBT is connected to BigQuery and I was able to successfull run the model to create the initial table (with materialization: table). But the above code results in this error. Specifically, it is triggered by the line containing sessions.sql()

ERROR TransportRequestHandler: Error while invoking RpcHandler#receive() for one-way message.
org.apache.spark.SparkException: Could not find CoarseGrainedScheduler.

I'm at a loss. The example in DBT documentation uses the session.sql function, so I'm not sure why im encountering an error here.

0

There are 0 best solutions below