Skip to content

Commit

Permalink
Try to fix error loading adoption dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
tatiana authored and sunank200 committed Jul 22, 2022
1 parent d2ff433 commit 4f01214
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/astro/databases/snowflake.py
Expand Up @@ -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:
Expand Down

0 comments on commit 4f01214

Please sign in to comment.