diff --git a/src/astro/databases/snowflake.py b/src/astro/databases/snowflake.py index 7eb15937be..cda8726937 100644 --- a/src/astro/databases/snowflake.py +++ b/src/astro/databases/snowflake.py @@ -302,6 +302,29 @@ def drop_stage(self, stage: SnowflakeStage) -> None: # Table load methods # --------------------------------------------------------- + def create_table_using_schema_autodetection( + self, + table: Table, + file: Optional[File] = None, + dataframe: Optional[pd.DataFrame] = None, + ) -> None: + """ + Create a SQL table, automatically inferring the schema using the given file. + + :param table: The table to be created. + :param file: File used to infer the new table columns. + :param dataframe: Dataframe used to infer the new table columns if there is no file + """ + if file: + dataframe = file.export_to_dataframe( + nrows=settings.LOAD_TABLE_AUTODETECT_ROWS_COUNT + ) + + if dataframe is not None: + dataframe.columns.str.upper() + # Make columns uppercase to prevent weird errors in snowflake + super().create_table_using_schema_autodetection(table, dataframe=dataframe) + def is_native_load_file_available( self, source_file: File, target_table: Table ) -> bool: