-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1856596: df.write.save_as_table
fails when column_order="name"
and a column has a SQL name clash
#2763
Comments
df.write.save_as_table
fails when column_order="name"
and a column has a SQL name clashdf.write.save_as_table
fails when column_order="name"
and a column has a SQL name clash
Hello @tvdboom , Thanks for raising the issue. As a workaround,
test_data = session.create_dataframe( test_data.write.save_as_table( I hope its clear Regards, |
@sfc-gh-sghosh Changing the function snowpark-python/src/snowflake/snowpark/_internal/analyzer/analyzer_utils.py Lines 835 to 844 in d6653f5
into this solves the issue: def insert_into_statement(
table_name: str,
child: str,
column_names: Optional[Iterable[str]] = None,
overwrite: bool = False,
) -> str:
if column_names:
table_columns = "(" + COMMA.join(f'"{c}"' for c in column_names) + ")"
else:
table_columns = EMPTY_STRING
if is_sql_select_statement(child):
return f"{INSERT}{OVERWRITE if overwrite else EMPTY_STRING}{INTO}{table_name}{table_columns}{SPACE}{child}"
return f"{INSERT}{INTO}{table_name}{table_columns}{project_statement([], child)}" let me know if you agree so I can open a PR |
Thank you @tvdboom , We are internally checking with team, will update. Regards, |
Please answer these questions before submitting your issue. Thanks!
What version of Python are you using?
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]
What operating system and processor architecture are you using?
Windows-10-10.0.22631-SP0
What are the component versions in the environment (
pip freeze
)?pandas==2.2.2
snowflake-snowpark-python==1.26.0
What did you do?
I created a dataframe with a column named
ROW
and tried to save it as a table usingcolumn_order="name"
.What did you expect to see?
No error, but got
I inspected the query created by snowpark which failed, which was
INSERT INTO DATABASE.SCHEMA.TESTTABLE1(A, ROW) SELECT * FROM "DATABASE"."SCHEMA"."SNOWPARK_TEMP_TABLE_8A1BTHDOUP"
as you can see, the column names in (A, ROW) are not enclosed in double quotes, therefore the query is invalid since it thinks
ROW
is a sql command.The text was updated successfully, but these errors were encountered: