snowflakedb/snowflake-jdbc

PUT command fails with ~ in file name

Closed this issue · 1 comments

On Windows it is possible to create a file path like this: C:/tmp/snowflake~\myfile.csv. When using this file path in the PUT command it fails since the driver replaces the ~ with the user home e.g. C:/tmp/snowflakeC:\User\Test\myfile.csv resulting in a file does not exists error. The problematic code is this: https://github.com/snowflakedb/snowflake-jdbc/blob/v3.13.33/src/main/java/net/snowflake/client/jdbc/SnowflakeFileTransferAgent.java#L1693

  1. What version of JDBC driver are you using?
    3.13.33 but also affects earlier versions

  2. What operating system and processor architecture are you using?
    Windows 10

  3. What version of Java are you using?
    JDK17

  4. What did you do?
    Tried to upload a file with ~ in the path name.

  5. What did you expect to see?
    That file would be uploaded

  6. Can you set logging to DEBUG and collect the logs?
    The used PUT command
    PUT 'file:///C:/tmp/snowflake~/knime_AP_20398_Snowfl_10693/snowflake-52197/knime2db8fbb59aee4534586.csv.gz' '@~' SOURCE_COMPRESSION=GZIP AUTO_COMPRESS=FALSE
    The exception that happened which shows the altered path name:

net.snowflake.client.jdbc.SnowflakeSQLLoggedException: File not found.
Cause: specified file does not exist: /C:/tmp/snowflakeC:\Users\Tobias/knime_AP_20398_Snowfl_10693/snowflake-52197/knime2db8fbb59aee4534586.csv.gz
Usage: to specify files, use "file://" prefix followed by path to files. A path can be relative or absolute. Example: put file:///tmp/bla* @table.

Hi @koettert I can easily reproduce this issue. Let me check internally what we can do about it.