Skip to content

Commit

Permalink
SNOW 1461701: Add test for Max LOB size parameter switch (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman-1 authored Jul 9, 2024
1 parent 76cfbd2 commit bc329ab
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class MaxLobSizeIT : SFBaseTest
private const int LargeSize = (MaxLobSize / 2);
private const int MediumSize = (LargeSize / 2);
private const int OriginSize = (MediumSize / 2);
private const int SmallSize = 16;
private const int LobRandomRange = 100000 + 1; // range to use for generating random numbers (0 - 100000)

private static string s_outputDirectory;
Expand Down Expand Up @@ -82,7 +81,7 @@ public void SetUp()
using (var command = conn.CreateCommand())
{
// Create temp table
var columnNamesWithTypes = $"{s_colName[0]} VARCHAR, {s_colName[1]} VARCHAR, {s_colName[2]} INT";
var columnNamesWithTypes = $"{s_colName[0]} VARCHAR({MaxLobSize}), {s_colName[1]} VARCHAR({MaxLobSize}), {s_colName[2]} INT";
command.CommandText = $"CREATE OR REPLACE TABLE {t_tableName} ({columnNamesWithTypes})";
command.ExecuteNonQuery();
}
Expand Down Expand Up @@ -273,7 +272,7 @@ public void TestPutGetCommand(int lobSize)
var c1 = GenerateRandomString(lobSize);
var c2 = GenerateRandomString(lobSize);
var c3 = new Random().Next(LobRandomRange);
t_colData = new string[]{ c1, c2, c3.ToString() };
t_colData = new string[] { c1, c2, c3.ToString() };

PrepareTest();

Expand All @@ -290,7 +289,6 @@ public void TestPutGetCommand(int lobSize)

static IEnumerable<int> LobSizeTestCases = new[]
{
SmallSize,
OriginSize,
MediumSize,
LargeSize,
Expand Down Expand Up @@ -388,6 +386,8 @@ private void AlterSessionSettings(SnowflakeDbConnection conn)
//// Alter session max lob
//command.CommandText = "ALTER SESSION SET FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY = 'ENABLED'";
//command.ExecuteNonQuery();
//command.CommandText = "alter session set ALLOW_LARGE_LOBS_IN_EXTERNAL_SCAN = true";
//command.ExecuteNonQuery();
}
}

Expand Down
35 changes: 35 additions & 0 deletions Snowflake.Data.Tests/IntegrationTests/SFMaxLobSizeSwitchIT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Data;
using NUnit.Framework;
using Snowflake.Data.Client;

namespace Snowflake.Data.Tests.IntegrationTests
{
[TestFixture]
public class SFMaxLobSizeSwitchIT : SFBaseTest
{
private const string SqlSelectLargeString = "select randstr(20000000, random()) as large_str";

[Test]
[Ignore("TODO: Enable when Max LOB size is available on the automated tests environment")]
public void TestIncreaseMaxLobSizeParameterSwitchSelect()
{
using (var conn = new SnowflakeDbConnection(ConnectionString + "poolingEnabled=false"))
{
conn.Open();
IDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "alter session set ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT=false";
cmd.ExecuteNonQuery();

cmd.CommandText = SqlSelectLargeString;
var thrown = Assert.Throws<SnowflakeDbException>(() => cmd.ExecuteReader());
Assert.That(thrown.Message, Does.Contain("exceeds supported length"));

cmd.CommandText = "alter session set ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT=true";
cmd.ExecuteNonQuery();
cmd.CommandText = SqlSelectLargeString;
var reader = cmd.ExecuteReader();
Assert.IsTrue(reader.Read());
}
}
}
}

0 comments on commit bc329ab

Please sign in to comment.