You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue pertains to a possible bug in the implementation of SnowflakeConnectionV1.uploadStreamInternal. It seems that this method may not be appropriately wrapping the identifier for a named stage in single quotes when it contains spaces or special characters, as is required according to the Snowflake documentation:
Note
If the stage name or path includes spaces or special characters, enclose it in single quotes. For example, use '@"my stage"' for a stage named "my stage".
If you have time, I'd appreciate if this could be confirmed as a bug, or if we're not utilising the method correctly on our end.
Details are included below.
1. What version of JDBC driver are you using?
v3.20.0
2. What operating system and processor architecture are you using?
macOS M1 Pro
3. What version of Java are you using?
Java 17
4. What did you do?
In one of our applications, we utilise SnowflakeConnectionV1 via the following method:
We have the following named stages defined within a Snowflake database DATABASE_1 under schema PUBLIC:
df_stage_name_lowercase
df_STAGE_NAme_with_MIXEd_CASing
df stage name with spaces
df_stage_name_with_~???@_special_characters
We fully-qualify the stage name we pass to SnowflakeConnectionV1.uploadStream and quote each part of the identifier, e.g. "DATABASE_1"."PUBLIC"."df_stage_name_lowercase".
For the first two test cases, the files are successfully loaded to the named stage. However, for the named stages containing spaces or special characters, the SQL statement used to upload the files fails to execute. For the test case df stage name with spaces, we get the following exception logs:
25-01-08 16:33:44 agent-1 | Caused by: net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:
2025-01-08 16:33:44 agent-1 | syntax error line 1 at position 61 unexpected 'name'.
2025-01-08 16:33:44 agent-1 | syntax error line 1 at position 66 unexpected 'with'.
2025-01-08 16:33:44 agent-1 | parse error line 1 at position 131 near '<EOF>'.
The root cause appears to be that SnowflakeConnectionV1.uploadStreamInternal does not wrap the entire identifier in single quotes when spaces or special characters are present. For this test case, the following SQL statement gets constructed:
put file:///tmp/placeholder @"DATABASE_1"."PUBLIC"."df stage name with spaces"/d6cf4234-2f17-40cb-a2c0-b68a729b16ad/ overwrite=true
Based on the Snowflake docs referenced above, I believe it ought to be:
put file:///tmp/placeholder '@"DATABASE_1"."PUBLIC"."df stage name with spaces"'/d6cf4234-2f17-40cb-a2c0-b68a729b16ad/ overwrite=true
5. What did you expect to see?
I expect that the Snowflake connector succeeds in uploading files to named stages regardless of whether there are spaces or special characters in the name.
6. Can you set logging to DEBUG and collect the logs?
I believe the logs included below should be sufficient to debug the issue, but let me know if more logs are required:
2025-01-08 16:33:44 agent-1 | Caused by: net.snowflake.client.jdbc.SnowflakeSQLException: SQL compilation error:
2025-01-08 16:33:44 agent-1 | syntax error line 1 at position 61 unexpected 'name'.
2025-01-08 16:33:44 agent-1 | syntax error line 1 at position 66 unexpected 'with'.
2025-01-08 16:33:44 agent-1 | parse error line 1 at position 131 near '<EOF>'.
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowExceptionSub(SnowflakeUtil.java:176)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeUtil.checkErrorAndThrowException(SnowflakeUtil.java:109)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.core.StmtUtil.pollForOutput(StmtUtil.java:490)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.core.StmtUtil.execute(StmtUtil.java:396)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.core.SFStatement.executeHelper(SFStatement.java:498)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeFileTransferAgent.parseCommandInGS(SnowflakeFileTransferAgent.java:1299)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeFileTransferAgent.parseCommand(SnowflakeFileTransferAgent.java:919)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeFileTransferAgent.<init>(SnowflakeFileTransferAgent.java:895)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.DefaultSFConnectionHandler.getFileTransferAgent(DefaultSFConnectionHandler.java:381)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeConnectionV1.uploadStreamInternal(SnowflakeConnectionV1.java:959)
2025-01-08 16:33:44 agent-1 | at net.snowflake.client.jdbc.SnowflakeConnectionV1.uploadStream(SnowflakeConnectionV1.java:864)
The text was updated successfully, but these errors were encountered:
TAGC
changed the title
Named stages using spaces or special characters are not quoted in "PUT file" SQL statements
Unable to upload files to named stages using spaces or special characters
Jan 8, 2025
This issue pertains to a possible bug in the implementation of
SnowflakeConnectionV1.uploadStreamInternal
. It seems that this method may not be appropriately wrapping the identifier for a named stage in single quotes when it contains spaces or special characters, as is required according to the Snowflake documentation:If you have time, I'd appreciate if this could be confirmed as a bug, or if we're not utilising the method correctly on our end.
Details are included below.
1. What version of JDBC driver are you using?
v3.20.0
2. What operating system and processor architecture are you using?
macOS M1 Pro
3. What version of Java are you using?
Java 17
4. What did you do?
In one of our applications, we utilise
SnowflakeConnectionV1
via the following method:We have the following named stages defined within a Snowflake database
DATABASE_1
under schemaPUBLIC
:df_stage_name_lowercase
df_STAGE_NAme_with_MIXEd_CASing
df stage name with spaces
df_stage_name_with_~???@_special_characters
We fully-qualify the stage name we pass to
SnowflakeConnectionV1.uploadStream
and quote each part of the identifier, e.g."DATABASE_1"."PUBLIC"."df_stage_name_lowercase"
.For the first two test cases, the files are successfully loaded to the named stage. However, for the named stages containing spaces or special characters, the SQL statement used to upload the files fails to execute. For the test case
df stage name with spaces
, we get the following exception logs:The root cause appears to be that
SnowflakeConnectionV1.uploadStreamInternal
does not wrap the entire identifier in single quotes when spaces or special characters are present. For this test case, the following SQL statement gets constructed:Based on the Snowflake docs referenced above, I believe it ought to be:
5. What did you expect to see?
I expect that the Snowflake connector succeeds in uploading files to named stages regardless of whether there are spaces or special characters in the name.
6. Can you set logging to DEBUG and collect the logs?
I believe the logs included below should be sufficient to debug the issue, but let me know if more logs are required:
The text was updated successfully, but these errors were encountered: