Automatically reload schema from table

Level 1
Automatically reload schema from table


I created a python recipe that define a SQL query and run it on a BigQuery table through the Python Bigquery API. My recipe looks like this:


import dataiku
from bq_manager import run_bq_query

query = """
CREATE OR REPLACE TABLE `project.dataset.output_table` as


The query runs successfully, however the shema of the created dataset is empty:

When reloading manually shema, everything works fine. But I need to automate this reload and add it inside the recipe.

I have tried this solution:

But I get this error: 

DataikuException: java.lang.ClassCastException: Cannot cast com.dataiku.dip.datasets.sql.ManagedSQLTableDatasetTestHandler to com.dataiku.dip.datasets.sql.ExternalSQLDatasetTestHandler


0 Kudos
1 Reply

Hi @ZMehdi,

autodetect_settings() is intended for "input" datasets, not for datasets that are in the middle of the Flow. For them (aka "managed datasets", the schema's "truth" is the dataset definition, not the table.

What you may be looking for is schema propagation to propagate schema changes across the flow, from left to right (

Also note that in DSS 9.0, we introduced both "reload schema of input dataset from table" and "propagate schema across Flow" as scenario steps, which allow you to automate that without code.



0 Kudos