From bc329abfcfad4c8fc7f6797a210102fc2713f616 Mon Sep 17 00:00:00 2001 From: Dawid Heyman Date: Tue, 9 Jul 2024 14:23:14 +0200 Subject: [PATCH] SNOW 1461701: Add test for Max LOB size parameter switch (#989) --- .../IntegrationTests/MaxLobSizeIT.cs | 8 ++--- .../IntegrationTests/SFMaxLobSizeSwitchIT.cs | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Snowflake.Data.Tests/IntegrationTests/SFMaxLobSizeSwitchIT.cs diff --git a/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs b/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs index 6a8bcce51..448585f52 100644 --- a/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/MaxLobSizeIT.cs @@ -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; @@ -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(); } @@ -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(); @@ -290,7 +289,6 @@ public void TestPutGetCommand(int lobSize) static IEnumerable LobSizeTestCases = new[] { - SmallSize, OriginSize, MediumSize, LargeSize, @@ -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(); } } diff --git a/Snowflake.Data.Tests/IntegrationTests/SFMaxLobSizeSwitchIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFMaxLobSizeSwitchIT.cs new file mode 100644 index 000000000..d90f9d0dc --- /dev/null +++ b/Snowflake.Data.Tests/IntegrationTests/SFMaxLobSizeSwitchIT.cs @@ -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(() => 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()); + } + } + } +}