@@ -37,20 +37,27 @@ const (
37
37
insertSQLBulkArrayDateTimeTimestamp = "insert into test_bulk_array_DateTimeTimestamp values(?, ?, ?, ?, ?)"
38
38
selectAllSQLBulkArrayDateTimeTimestamp = "select * from test_bulk_array_DateTimeTimestamp ORDER BY 1"
39
39
40
- enableFeatureMaxLOBSize = "ALTER SESSION SET FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY='ENABLED'"
41
- unsetFeatureMaxLOBSize = "ALTER SESSION UNSET FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY"
40
+ enableFeatureMaxLOBSize = "ALTER SESSION SET FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY='ENABLED'"
41
+ unsetFeatureMaxLOBSize = "ALTER SESSION UNSET FEATURE_INCREASED_MAX_LOB_SIZE_IN_MEMORY"
42
+ enableLargeVarcharAndBinary = "ALTER SESSION SET ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT=TRUE"
43
+ disableLargeVarcharAndBinary = "ALTER SESSION SET ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT=FALSE"
44
+ unsetLargeVarcharAndBinary = "ALTER SESSION UNSET ENABLE_LARGE_VARCHAR_AND_BINARY_IN_RESULT"
45
+
46
+ maxVarcharAndBinarySizeParam = "varchar_and_binary_max_size_in_result"
42
47
43
- // For max LOB size tests
44
- // maxLOBSize = 128 * 1024 * 1024 // new max LOB size
45
- maxLOBSize = 16 * 1024 * 1024 // current max LOB size
46
- largeSize = maxLOBSize / 2
47
- mediumSize = largeSize / 2
48
48
originSize = 16 * 1024 * 1024
49
49
smallSize = 16
50
50
// range to use for generating random numbers
51
51
lobRandomRange = 100000
52
52
)
53
53
54
+ var (
55
+ // maxLOBSize = 128 * 1024 * 1024 // new max LOB size
56
+ maxLOBSize = 16 * 1024 * 1024 // current max LOB size
57
+ largeSize = maxLOBSize / 2
58
+ mediumSize = largeSize / 2
59
+ )
60
+
54
61
func TestBindingFloat64 (t * testing.T ) {
55
62
runDBTest (t , func (dbt * DBTest ) {
56
63
types := [2 ]string {"FLOAT" , "DOUBLE" }
@@ -220,9 +227,9 @@ func TestBindingTimePtrInStruct(t *testing.T) {
220
227
id * int
221
228
timeVal * time.Time
222
229
}
223
- var expectedID int = 1
224
- var expectedTime time. Time = time .Now ()
225
- var testStruct timePtrStruct = timePtrStruct {id : & expectedID , timeVal : & expectedTime }
230
+ expectedID : = 1
231
+ expectedTime : = time .Now ()
232
+ testStruct : = timePtrStruct {id : & expectedID , timeVal : & expectedTime }
226
233
dbt .mustExec ("CREATE OR REPLACE TABLE timeStructTest (id int, tz timestamp_tz)" )
227
234
228
235
runInsertQuery := false
@@ -267,9 +274,9 @@ func TestBindingTimeInStruct(t *testing.T) {
267
274
id int
268
275
timeVal time.Time
269
276
}
270
- var expectedID int = 1
271
- var expectedTime time. Time = time .Now ()
272
- var testStruct timeStruct = timeStruct {id : expectedID , timeVal : expectedTime }
277
+ expectedID : = 1
278
+ expectedTime : = time .Now ()
279
+ testStruct : = timeStruct {id : expectedID , timeVal : expectedTime }
273
280
dbt .mustExec ("CREATE OR REPLACE TABLE timeStructTest (id int, tz timestamp_tz)" )
274
281
275
282
runInsertQuery := false
@@ -885,7 +892,7 @@ func TestBulkArrayMultiPartBindingInt(t *testing.T) {
885
892
cnt ++
886
893
}
887
894
if cnt != endNum {
888
- t .Fatalf ("expected %v rows, got %v" , numRows , ( cnt - startNum ) )
895
+ t .Fatalf ("expected %v rows, got %v" , numRows , cnt - startNum )
889
896
}
890
897
dbt .mustExec ("DROP TABLE binding_test" )
891
898
})
@@ -947,7 +954,7 @@ func TestBulkArrayMultiPartBindingWithNull(t *testing.T) {
947
954
cnt ++
948
955
}
949
956
if cnt != endNum {
950
- t .Fatalf ("expected %v rows, got %v" , numRows , ( cnt - startNum ) )
957
+ t .Fatalf ("expected %v rows, got %v" , numRows , cnt - startNum )
951
958
}
952
959
dbt .mustExec ("DROP TABLE binding_test" )
953
960
})
@@ -1111,6 +1118,12 @@ func TestVariousBindingModes(t *testing.T) {
1111
1118
})
1112
1119
}
1113
1120
1121
+ func skipMaxLobSizeTestOnGithubActions (t * testing.T ) {
1122
+ if runningOnGithubAction () {
1123
+ t .Skip ("Max Lob Size parameters are not available on GH Actions" )
1124
+ }
1125
+ }
1126
+
1114
1127
func TestLOBRetrievalWithArrow (t * testing.T ) {
1115
1128
testLOBRetrieval (t , true )
1116
1129
}
@@ -1120,18 +1133,25 @@ func TestLOBRetrievalWithJSON(t *testing.T) {
1120
1133
}
1121
1134
1122
1135
func testLOBRetrieval (t * testing.T , useArrowFormat bool ) {
1123
- // the LOB sizes to be tested
1124
- testSizes := [5 ]int {smallSize , originSize , mediumSize , largeSize , maxLOBSize }
1125
- var res string
1126
-
1127
1136
runDBTest (t , func (dbt * DBTest ) {
1128
- dbt .exec (enableFeatureMaxLOBSize )
1137
+ parameters := dbt .connParams ()
1138
+ varcharBinaryMaxSizeRaw := parameters [maxVarcharAndBinarySizeParam ]
1139
+ if varcharBinaryMaxSizeRaw != nil && * varcharBinaryMaxSizeRaw != "" {
1140
+ varcharBinaryMaxSize , err := strconv .ParseFloat (* varcharBinaryMaxSizeRaw , 64 )
1141
+ assertNilF (t , err , "error during varcharBinaryMaxSize conversion" )
1142
+ maxLOBSize = int (varcharBinaryMaxSize )
1143
+ }
1144
+
1145
+ dbt .Logf ("using %v as max LOB size" , maxLOBSize )
1129
1146
if useArrowFormat {
1130
1147
dbt .mustExec (forceARROW )
1131
1148
} else {
1132
1149
dbt .mustExec (forceJSON )
1133
1150
}
1134
1151
1152
+ var res string
1153
+ // the LOB sizes to be tested
1154
+ testSizes := [5 ]int {smallSize , originSize , mediumSize , largeSize , maxLOBSize }
1135
1155
for _ , testSize := range testSizes {
1136
1156
t .Run (fmt .Sprintf ("testLOB_%v_useArrowFormat=%v" , strconv .Itoa (testSize ), strconv .FormatBool (useArrowFormat )), func (t * testing.T ) {
1137
1157
rows , err := dbt .query (fmt .Sprintf ("SELECT randstr(%v, 124)" , testSize ))
@@ -1151,6 +1171,27 @@ func testLOBRetrieval(t *testing.T, useArrowFormat bool) {
1151
1171
})
1152
1172
}
1153
1173
1174
+ func TestMaxLobSize (t * testing.T ) {
1175
+ skipMaxLobSizeTestOnGithubActions (t )
1176
+ runDBTest (t , func (dbt * DBTest ) {
1177
+ dbt .mustExec (enableFeatureMaxLOBSize )
1178
+ defer dbt .mustExec (unsetLargeVarcharAndBinary )
1179
+ t .Run ("Max Lob Size disabled" , func (t * testing.T ) {
1180
+ dbt .mustExec (disableLargeVarcharAndBinary )
1181
+ _ , err := dbt .query ("select randstr(20000000, random())" )
1182
+ assertNotNilF (t , err )
1183
+ assertStringContainsF (t , err .Error (), "Actual length 20000000 exceeds supported length" )
1184
+ })
1185
+
1186
+ t .Run ("Max Lob Size enabled" , func (t * testing.T ) {
1187
+ dbt .mustExec (enableLargeVarcharAndBinary )
1188
+ rows , err := dbt .query ("select randstr(20000000, random())" )
1189
+ assertNilF (t , err )
1190
+ rows .Close ()
1191
+ })
1192
+ })
1193
+ }
1194
+
1154
1195
func TestInsertLobDataWithLiteralArrow (t * testing.T ) {
1155
1196
// TODO SNOW-1264687
1156
1197
skipOnJenkins (t , "skipped until SNOW-1264687 is fixed" )
0 commit comments