Skip to content

Commit 1cb0641

Browse files
committed
[fix](regression) limit binary cases to supported value transport
1 parent 38ddc46 commit 1cb0641

2 files changed

Lines changed: 10 additions & 61 deletions

File tree

‎regression-test/suites/datatype_p0/test_varbinary_sql_support.groovy‎

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,50 +44,8 @@ suite("test_varbinary_sql_support") {
4444
[5, "AB"], [6, "AB00"], [7, "AB0001"], [8, "AB"], [9, "FF"]]
4545
def readBytes = { name -> sql "SELECT id, from_binary(payload) FROM ${name} ORDER BY id" }
4646
assertEquals(bytes, readBytes(table))
47-
assertEquals([[1], [2], [3], [4], [5], [8], [6], [7], [9]],
48-
sql("SELECT id FROM ${table} WHERE payload IS NOT NULL ORDER BY payload, id"))
49-
assertEquals([[5], [8]], sql("SELECT id FROM ${table} WHERE payload = X'AB' ORDER BY id"))
50-
assertEquals([[6], [7], [9]], sql("SELECT id FROM ${table} WHERE payload > X'AB' ORDER BY id"))
51-
assertEquals([[0]], sql("SELECT id FROM ${table} WHERE payload <=> NULL"))
52-
assertEquals([[1]], sql("SELECT id FROM ${table} WHERE payload = ''"))
53-
assertEquals([[1, 0]], sql("SELECT CAST(X'616263' = 'abc' AS INT), CAST(X'AB' = 'AB' AS INT)"))
54-
assertEquals([[5], [6], [7], [8]], sql("SELECT id FROM ${table} "
55-
+ "WHERE payload BETWEEN X'AB' AND X'AB0001' ORDER BY id"))
56-
assertEquals([[0, 1, 1]], sql("SELECT CAST(X'AB' = X'AB00' AS INT), "
57-
+ "CAST(X'AB' < X'AB0001' AS INT), CAST(X'7F' < X'80' AS INT)"))
58-
// Binary read/write support must not enable hash keys, IN sets, or aggregate kernels.
59-
["SELECT payload, count(*) FROM ${table} GROUP BY payload",
60-
"SELECT id, count(*) FROM ${table} GROUP BY id, payload",
61-
"SELECT count(*) FROM ${table} a JOIN ${table} b ON a.payload = b.payload",
62-
"SELECT count(*) FROM ${table} a JOIN ${table} b ON a.payload <=> b.payload",
63-
"SELECT count(*) FROM ${table} a JOIN ${table} b ON a.id = b.id AND a.payload = b.payload",
64-
"SELECT count(*) FROM ${table} WHERE payload IN (X'', X'00', NULL)",
65-
"SELECT count(*) FROM ${table} WHERE payload NOT IN (X'', X'00', NULL)",
66-
"SELECT min(payload) FROM ${table}",
67-
"SELECT max(payload) FROM ${table}"].each { query ->
68-
test {
69-
sql query
70-
exception "not supported"
71-
}
72-
}
73-
74-
// Unsupported binary collection kernels must fail in analysis, not with a BE internal error.
75-
def binaryArray = "array(payload, X'', X'0080FF', NULL)"
76-
["array_contains(${binaryArray}, X'0080FF')", "array_position(${binaryArray}, X'0080FF')",
77-
"countequal(${binaryArray}, X'0080FF')", "array_distinct(${binaryArray})",
78-
"array_remove(${binaryArray}, X'0080FF')", "array_enumerate_uniq(${binaryArray})",
79-
"array_contains_all(${binaryArray}, ${binaryArray})", "arrays_overlap(${binaryArray}, ${binaryArray})",
80-
"array_union(${binaryArray}, ${binaryArray})", "array_except(${binaryArray}, ${binaryArray})",
81-
"array_intersect(${binaryArray}, ${binaryArray})", "collect_set(payload)", "collect_set(payload, 2)"].each {
82-
expression ->
83-
test {
84-
sql "SELECT ${expression} FROM ${table}"
85-
exception "does not support VARBINARY"
86-
}
87-
}
88-
assertEquals([[9L]], sql("SELECT array_size(collect_list(payload)) FROM ${table}"))
89-
90-
sql "CREATE VIEW ${view} AS SELECT id, payload FROM ${table} WHERE payload <> X'AB00' OR payload IS NULL"
47+
// Exercise binary transport through views without requiring binary predicates or hash keys.
48+
sql "CREATE VIEW ${view} AS SELECT id, payload FROM ${table} WHERE id <> 6"
9149
assertEquals(bytes.findAll { it[0] != 6 }, readBytes(view))
9250
assertTrue(sql("DESC ${view}").find { it[0] == "payload" }[1].toLowerCase().startsWith("varbinary"))
9351
test {
@@ -118,11 +76,10 @@ suite("test_varbinary_sql_support") {
11876
// Long execution values must outlive source batches and retain their bytes.
11977
sql """INSERT INTO ${source} SELECT number + 100,
12078
concat(repeat('FF', 700), '00AB') FROM numbers('number'='2048')"""
121-
assertEquals([[2048L]], sql("SELECT count(*) FROM ${table} "
122-
+ "WHERE payload = to_binary(concat(repeat('FF', 700), '00AB'))"))
123-
test {
124-
sql "SELECT count(*) FROM ${table} WHERE payload IN (to_binary(concat(repeat('FF', 700), '00AB')), X'00', NULL)"
125-
exception "not supported"
79+
def longBytes = sql "SELECT id, from_binary(payload) FROM ${table} WHERE id >= 100 ORDER BY id"
80+
assertEquals(2048, longBytes.size())
81+
longBytes.eachWithIndex { row, index ->
82+
assertEquals([index + 100, "FF" * 700 + "00AB"], row)
12683
}
12784
} finally {
12885
cleanup()

‎regression-test/suites/external_table_p0/hive/test_hive_orc.groovy‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ suite("test_hive_orc", "all_types,p0,external,hive,external_docker,external_dock
247247
sql """ drop database if exists test_view_varbinary_db force"""
248248
sql """ create database if not exists test_view_varbinary_db"""
249249
sql """use test_view_varbinary_db"""
250-
// Bound the sample so duplicate binary values cannot turn this check into a huge self-join.
250+
// Binary mapping enables transport; compare hexadecimal strings without binary hash keys.
251251
def binaryQuery = ("SELECT binary_col FROM `test_hive_orc_mapping_varbinary`.`default`.`orc_all_types` "
252-
+ "ORDER BY int_col, binary_col LIMIT 100")
252+
+ "ORDER BY int_col, from_binary(binary_col) LIMIT 100")
253253
def binarySource = "(${binaryQuery}) binary_src"
254-
def expectedBinary = sql "SELECT from_binary(binary_col) FROM ${binarySource} ORDER BY binary_col"
254+
def expectedBinary = sql "SELECT from_binary(binary_col) FROM ${binarySource} ORDER BY from_binary(binary_col)"
255255
// Views retain execution types; materialized objects still obey native storage restrictions.
256256
sql "CREATE VIEW test_view_varbinary AS SELECT binary_col FROM ${binarySource}"
257257
assertEquals(expectedBinary,
258-
sql("SELECT from_binary(binary_col) FROM test_view_varbinary ORDER BY binary_col"))
258+
sql("SELECT from_binary(binary_col) FROM test_view_varbinary ORDER BY from_binary(binary_col)"))
259259
test {
260260
sql """CREATE TABLE test_ctas_varbinary DISTRIBUTED BY RANDOM BUCKETS 2
261261
PROPERTIES ('replication_num'='1') AS SELECT binary_col FROM ${binarySource}"""
@@ -270,14 +270,6 @@ suite("test_hive_orc", "all_types,p0,external,hive,external_docker,external_dock
270270
exception "varbinary"
271271
}
272272
assertTrue(sql("DESC test_view_varbinary")[0][1].toLowerCase().startsWith("varbinary"))
273-
assertEquals(sql("SELECT count(*) FROM ${binarySource}")[0][0].toString(),
274-
sql("SELECT coalesce(sum(n), 0) FROM (SELECT count(*) n FROM ${binarySource} GROUP BY binary_col) g")[0][0].toString())
275-
assertEquals(sql("SELECT coalesce(sum(n*n), 0) FROM (SELECT count(*) n FROM ${binarySource} "
276-
+ "WHERE binary_col IS NOT NULL GROUP BY binary_col) g")[0][0].toString(),
277-
sql("SELECT count(*) FROM (${binaryQuery}) a JOIN (${binaryQuery}) b "
278-
+ "ON a.binary_col = b.binary_col")[0][0].toString())
279-
assertEquals(sql("SELECT count(*) FROM ${binarySource} WHERE from_binary(binary_col) = 'AB'"),
280-
sql("SELECT count(*) FROM ${binarySource} WHERE binary_col = X'AB'"))
281273
sql "DROP DATABASE test_view_varbinary_db FORCE"
282274

283275
} finally {

0 commit comments

Comments
 (0)