Skip to content

Commit bc329ab

Browse files
SNOW 1461701: Add test for Max LOB size parameter switch (#989)
1 parent 76cfbd2 commit bc329ab

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class MaxLobSizeIT : SFBaseTest
2626
private const int LargeSize = (MaxLobSize / 2);
2727
private const int MediumSize = (LargeSize / 2);
2828
private const int OriginSize = (MediumSize / 2);
29-
private const int SmallSize = 16;
3029
private const int LobRandomRange = 100000 + 1; // range to use for generating random numbers (0 - 100000)
3130

3231
private static string s_outputDirectory;
@@ -82,7 +81,7 @@ public void SetUp()
8281
using (var command = conn.CreateCommand())
8382
{
8483
// Create temp table
85-
var columnNamesWithTypes = $"{s_colName[0]} VARCHAR, {s_colName[1]} VARCHAR, {s_colName[2]} INT";
84+
var columnNamesWithTypes = $"{s_colName[0]} VARCHAR({MaxLobSize}), {s_colName[1]} VARCHAR({MaxLobSize}), {s_colName[2]} INT";
8685
command.CommandText = $"CREATE OR REPLACE TABLE {t_tableName} ({columnNamesWithTypes})";
8786
command.ExecuteNonQuery();
8887
}
@@ -273,7 +272,7 @@ public void TestPutGetCommand(int lobSize)
273272
var c1 = GenerateRandomString(lobSize);
274273
var c2 = GenerateRandomString(lobSize);
275274
var c3 = new Random().Next(LobRandomRange);
276-
t_colData = new string[]{ c1, c2, c3.ToString() };
275+
t_colData = new string[] { c1, c2, c3.ToString() };
277276

278277
PrepareTest();
279278

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

291290
static IEnumerable<int> LobSizeTestCases = new[]
292291
{
293-
SmallSize,
294292
OriginSize,
295293
MediumSize,
296294
LargeSize,
@@ -388,6 +386,8 @@ private void AlterSessionSettings(SnowflakeDbConnection conn)
388386
//// Alter session max lob
389387
//command.CommandText = "ALTER SESSION SET FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY = 'ENABLED'";
390388
//command.ExecuteNonQuery();
389+
//command.CommandText = "alter session set ALLOW_LARGE_LOBS_IN_EXTERNAL_SCAN = true";
390+
//command.ExecuteNonQuery();
391391
}
392392
}
393393

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Data;
2+
using NUnit.Framework;
3+
using Snowflake.Data.Client;
4+
5+
namespace Snowflake.Data.Tests.IntegrationTests
6+
{
7+
[TestFixture]
8+
public class SFMaxLobSizeSwitchIT : SFBaseTest
9+
{
10+
private const string SqlSelectLargeString = "select randstr(20000000, random()) as large_str";
11+
12+
[Test]
13+
[Ignore("TODO: Enable when Max LOB size is available on the automated tests environment")]
14+
public void TestIncreaseMaxLobSizeParameterSwitchSelect()
15+
{
16+
using (var conn = new SnowflakeDbConnection(ConnectionString + "poolingEnabled=false"))
17+
{
18+
conn.Open();
19+
IDbCommand cmd = conn.CreateCommand();
20+
cmd.CommandText = "alter session set ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT=false";
21+
cmd.ExecuteNonQuery();
22+
23+
cmd.CommandText = SqlSelectLargeString;
24+
var thrown = Assert.Throws<SnowflakeDbException>(() => cmd.ExecuteReader());
25+
Assert.That(thrown.Message, Does.Contain("exceeds supported length"));
26+
27+
cmd.CommandText = "alter session set ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT=true";
28+
cmd.ExecuteNonQuery();
29+
cmd.CommandText = SqlSelectLargeString;
30+
var reader = cmd.ExecuteReader();
31+
Assert.IsTrue(reader.Read());
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)