3

I have done the following in Code Repositories

@transform_df(
    Output(test_dataset_path),
    df=Input(og_dataset_path)
)
def compute(ctx, df):
    ctx.spark_session.sql(f'''
    CREATE TABLE `test_dataset_path` AS
    SELECT * FROM `og_dataset_path`
    ''')

    return ctx.spark_session.sql(f'''
    SELECT * FROM `og_dataset_path`
    ''')

and it is erroring out on the code:

ctx.spark_session.sql(f'''
CREATE TABLE `test_dataset_path` AS
SELECT * FROM `og_dataset_path`
''')

with the error:

pyspar.sql.utils.AnanlysisException: Table or view not found: og_dataset_path

How can I resolve this error?

ZygD
  • 22,092
  • 39
  • 79
  • 102

1 Answers1

2

Using createOrReplaceTempView should resolve this problem:

from transforms.api import transform_df, Input, Output

@transform_df(
     Output("/Users/XXXXX/sqlcsvA2"),
     ALL=Input("/datasources/locations/data/cleaned")
)
def my_compute_function(ctx, ALL):
    ALL.createOrReplaceTempView('ALL')
    return ctx.spark_session.sql('select * from ALL limit 10')
ZygD
  • 22,092
  • 39
  • 79
  • 102