-
Notifications
You must be signed in to change notification settings - Fork 140
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-1545648: PUT command error if file path contains spaces #996
Comments
hey - i'm trying to reproduce this issue with the following setup for files; where both the directory name and the file name contains spaces:
repro script, with Snowflake .NET driver 4.0.0: using System;
using System.Data;
using System.Data.Common;
using Snowflake.Data.Client;
namespace SnowflakeTestProgram
{
class Program
{
static void Main(string[] args)
{
try
{
using (IDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = "account=...";
conn.Open();
Console.WriteLine("Connection successful!");
Console.WriteLine("--> Issuing PUT");
SnowflakeDbCommand command3 = new SnowflakeDbCommand((SnowflakeDbConnection)conn,
"PUT 'file://C:/temp/directory name with spaces/*.*' @GH996 OVERWRITE=TRUE");
command3.ExecuteNonQuery();
/*
* or even with command.ExecuteReader()
System.Data.Common.DbDataReader reader3 = command3.ExecuteReader();
while (reader3.Read())
{
Console.WriteLine(reader3.GetString(6));
}
*/
string queryIdPut = command3.GetQueryId();
Console.WriteLine("queryIdPut: " + queryIdPut);
}
}
catch (DbException exc)
{
Console.WriteLine("Error Message: {0}", exc.Message);
}
}
}
} result:
so far, working as expected. I also took a look at the queryId you sent in the issue submission ( PUT 'file://test1.txt.gz @SE4_TEST_STAGE auto_compress=true closing apostrophe missing. It is not even with a directory name with spaces, so maybe this queryId does not belong to the issue you're describing? anyhow; since the use-case seems to be working to me as expected and documented, could you please provide further details on
This could help a lot in debugging the issue which is not reproducible for me. Thank you in advance ! |
This is indeed weird, and I'm wondering if the IDE itself has anything to do with the issue. Speaking about which, as a mitigation and to hopefully become unblocked with your use-case, can you perhaps try issuing
instead of the To troubleshoot the issue further, can you please
|
I have managed to find a workaround and get this working by simply removing a space after the second quotation mark. If there are no spaces between ' and @, then it works.
|
good to hear you found a workaround ! I'm going to leave this open for a while to see if you have a chance to try the other things suggested too; or if other people have the same issue which was not yet reproducible for me. |
Unfortunately, the workaround I mentioned won't work if both file path and internalStage have spaces. For example
It would great to find a real solution to this issue. I attached extract from my log I use Visual Studio on WIndows for development, and I have not tried a different environment. |
thank you for sending the log, for some reason indeed two queries are sent instead of one. the
format worked for me (maybe not very intuitive how to use stages with spaces, but at least it's documented) can you please try it? also maybe using Sadly since in my Visual Studio 2022 (17.9.6, Windows 10, 64-bit) it's not reproducible and it doesn't seem to be possible for you to try another IDE or even the NET CLI, can you perhaps try from the same version of Visual Studio or let me know which one you use so I could try reproducing on the same version? |
It appears the issue is with the getFilePathFromPutCommand function in SFFileTransferAgent.cs .
It does not handle correctly cases if file path or/and internalStage have single quotation marks around them, for example
|
this is a good catch indeed! wondering why it behaves entirely differently for me with same Snowflake .NET driver 4.0.0.0 and .NET 8.0. Anyways, that's something we can look at. For posterity, prepared repro program without Snowflake to test output for the function: using System;
public class Program
{
public static void Main()
{
string getFilePathFromPutCommand(string query)
{
// Extract file path from PUT command:
// E.g. "PUT file://C:<path-to-file> @DB.SCHEMA.%TABLE;"
int startIndex = query.IndexOf("file://") + "file://".Length;
int endIndex = query.Substring(startIndex).IndexOf('@') - 1;
string filePath = query.Substring(startIndex, endIndex);
return filePath;
}
string query1 = "PUT 'file://C:/temp/directory name with spaces/my file.txt' '@\"GH996 with space\"' OVERWRITE=TRUE";
string query2 = "PUT 'file://C:/temp/directory name with spaces/my file.txt' @GH996 OVERWRITE=TRUE";
string query3 = "PUT 'file://C:/temp/directory name with spaces/*.*' @GH996 OVERWRITE=TRUE";
string query4 = "PUT 'file://C:/temp/directory name with spaces/*.*' '@\"GH996 with space\"' OVERWRITE=TRUE";
Console.WriteLine(getFilePathFromPutCommand(query1));
Console.WriteLine(getFilePathFromPutCommand(query2));
Console.WriteLine(getFilePathFromPutCommand(query3));
Console.WriteLine(getFilePathFromPutCommand(query4));
}
} Outputs
with a little extra at the end of each string. In the meantime, I'm wondering (even if trying another IDE, NET CLI, etc. is apparently not even an option here), using |
Using Unfortunately, I do not have time and capabilities to test this in another environment. Just simply by looking at the getFilePathFromPutCommand function, it is difficult to imagine how it can possibly work correctly if there are single quotation marks. When do you think this bug will be fixed? When the new release be available? |
Currently i unfortunately cannot even estimate when the bug will be fixed, but I will keep this thread posted with every new information once they are available. As a workaround, please use directory/file/stage names without spaces until it is fixed. In the meantime, if this bug causes significant impact to your business, kindly reach out to your Snowflake account representative and let them know about it. They can help prioritize. |
addressed with #1066, in review |
I am using Snowflake.Data NuGet package v4.0.0, / .NET8.0 / Windows 11
My file path contains a space and I am following the following suggestion
"If the directory path or filename includes special characters or spaces, enclose the entire file URI in single quotes. " I have found here
Below is sample code
If a file path contains a space, it will throw the following error.
{"Error: SQL compilation error: parse error line 1 at position 59 near ''. SqlState: 42000, VendorCode: 1003, QueryId: 01b5be10-0001-2942-0001-f7f20001601e"}
If a file path does not contain a space and I do not use single quotes, then everything works fine, for example
command.CommandText = "PUT file://C:/Users/Alexander/AppData/Local/Temp/mypiei_jvzgq/*.* @MY4_TEST_STAGE auto_compress=true";
The text was updated successfully, but these errors were encountered: