Skip to content

Commit

Permalink
Merge branch 'master' into package_signature_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko authored Nov 5, 2024
2 parents 258fcf6 + d69e2cb commit 1ac871d
Show file tree
Hide file tree
Showing 14 changed files with 261 additions and 128 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ Read more in [certificate validation](doc/CertficateValidation.md) docs.
were not performed where the insecureMode flag was set to false, which is the default setting.
From version v2.1.5 CRL is working back as intended.

5. This driver currently does not support GCP regional endpoints. Please ensure that any workloads using through this driver do not require support for regional endpoints on GCP. If you have questions about this, please contact Snowflake Support.

Note that the driver is now targeting .NET Standard 2.0. When upgrading, you might also need to run “Update-Package -reinstall” to update the dependencies.

See more:
Expand Down
90 changes: 90 additions & 0 deletions Snowflake.Data.Tests/IntegrationTests/SFDbCommandIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Threading;
using System.Threading.Tasks;
using Snowflake.Data.Core;
using System.Linq;
using System.IO;

namespace Snowflake.Data.Tests.IntegrationTests
{
Expand Down Expand Up @@ -1674,5 +1676,93 @@ public async Task TestCommandWithCommentEmbeddedAsync()
Assert.AreEqual("--", reader.GetString(0));
}
}

[Test]
public void TestExecuteNonQueryReturnsCorrectRowCountForUploadWithMultipleFiles()
{
const int NumberOfFiles = 5;
const int NumberOfRows = 3;
const int ExpectedRowCount = NumberOfFiles * NumberOfRows;

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
{
var tempFolder = $"{Path.GetTempPath()}Temp_{Guid.NewGuid()}";

try
{
// Arrange
Directory.CreateDirectory(tempFolder);
var data = string.Concat(Enumerable.Repeat(string.Join(",", "TestData") + "\n", NumberOfRows));
for (int i = 0; i < NumberOfFiles; i++)
{
File.WriteAllText(Path.Combine(tempFolder, $"{TestContext.CurrentContext.Test.Name}_{i}.csv"), data);
}
CreateOrReplaceTable(conn, TableName, new[] { "COL1 STRING" });
cmd.CommandText = $"PUT file://{Path.Combine(tempFolder, "*.csv")} @%{TableName} AUTO_COMPRESS=FALSE";
var reader = cmd.ExecuteReader();

// Act
cmd.CommandText = $"COPY INTO {TableName} FROM @%{TableName} PATTERN='.*.csv' FILE_FORMAT=(TYPE=CSV)";
int actualRowCount = cmd.ExecuteNonQuery();

// Assert
Assert.AreEqual(ExpectedRowCount, actualRowCount);
}
finally
{
Directory.Delete(tempFolder, true);
}
}
}
}

[Test]
public async Task TestExecuteNonQueryAsyncReturnsCorrectRowCountForUploadWithMultipleFiles()
{
const int NumberOfFiles = 5;
const int NumberOfRows = 3;
const int ExpectedRowCount = NumberOfFiles * NumberOfRows;

using (SnowflakeDbConnection conn = new SnowflakeDbConnection())
{
conn.ConnectionString = ConnectionString + "poolingEnabled=false";
conn.Open();

using (SnowflakeDbCommand cmd = (SnowflakeDbCommand)conn.CreateCommand())
{
var tempFolder = $"{Path.GetTempPath()}Temp_{Guid.NewGuid()}";

try
{
// Arrange
Directory.CreateDirectory(tempFolder);
var data = string.Concat(Enumerable.Repeat(string.Join(",", "TestData") + "\n", NumberOfRows));
for (int i = 0; i < NumberOfFiles; i++)
{
File.WriteAllText(Path.Combine(tempFolder, $"{TestContext.CurrentContext.Test.Name}_{i}.csv"), data);
}
CreateOrReplaceTable(conn, TableName, new[] { "COL1 STRING" });
cmd.CommandText = $"PUT file://{Path.Combine(tempFolder, "*.csv")} @%{TableName} AUTO_COMPRESS=FALSE";
var reader = cmd.ExecuteReader();

// Act
cmd.CommandText = $"COPY INTO {TableName} FROM @%{TableName} PATTERN='.*.csv' FILE_FORMAT=(TYPE=CSV)";
int actualRowCount = await cmd.ExecuteNonQueryAsync().ConfigureAwait(false);

// Assert
Assert.AreEqual(ExpectedRowCount, actualRowCount);
}
finally
{
Directory.Delete(tempFolder, true);
}
}
}
}
}
}
Loading

0 comments on commit 1ac871d

Please sign in to comment.