From 7dc01515cef4300e8da8467065fdfe4a4528cddc Mon Sep 17 00:00:00 2001 From: Jax Liu Date: Sun, 22 Sep 2024 19:50:09 +0800 Subject: [PATCH] Reorgnize the StringView tests in sqllogictests (#12572) * move the string function tests * move the operator test * add back the test for dictionary string --- .../test_files/string/string_literal.slt | 22 + .../test_files/string/string_query.slt.part | 368 ++++++ .../test_files/string/string_view.slt | 646 ++++++++++ .../sqllogictest/test_files/string_view.slt | 1093 ----------------- 4 files changed, 1036 insertions(+), 1093 deletions(-) delete mode 100644 datafusion/sqllogictest/test_files/string_view.slt diff --git a/datafusion/sqllogictest/test_files/string/string_literal.slt b/datafusion/sqllogictest/test_files/string/string_literal.slt index 37dc1a8ce84d..7cb921a6603e 100644 --- a/datafusion/sqllogictest/test_files/string/string_literal.slt +++ b/datafusion/sqllogictest/test_files/string/string_literal.slt @@ -145,3 +145,25 @@ select arrow_cast('Xiangpeng', 'Utf8View') <> arrow_cast('Andrew', 'Utf8View'); ---- false true true true + + +query II +SELECT + ASCII('hello'), + ASCII(arrow_cast('world', 'Utf8View')) +---- +104 119 + +query III +SELECT + ASCII(arrow_cast('äöüß', 'Utf8View')) as c1, + ASCII(arrow_cast('', 'Utf8View')) as c2, + ASCII(arrow_cast(NULL, 'Utf8View')) as c3 +---- +228 0 NULL + +# coercion from stringview to integer, as input to make_date +query D +select make_date(arrow_cast('2024', 'Utf8View'), arrow_cast('01', 'Utf8View'), arrow_cast('23', 'Utf8View')) +---- +2024-01-23 diff --git a/datafusion/sqllogictest/test_files/string/string_query.slt.part b/datafusion/sqllogictest/test_files/string/string_query.slt.part index 4f737954000b..f22edae01de9 100644 --- a/datafusion/sqllogictest/test_files/string/string_query.slt.part +++ b/datafusion/sqllogictest/test_files/string/string_query.slt.part @@ -164,6 +164,19 @@ ThisIsAVeryLongASCIIString isIsAVeryLongASCIIString (empty) ThisIsAVeryLongASCII (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) (empty) NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL +query TTTT +SELECT + SUBSTR(ascii_1, 1, 3) as c1, + SUBSTR(ascii_2, 1, 3) as c2, + SUBSTR(unicode_1, 1, 3) as c3, + SUBSTR(unicode_2, 1, 3) as c4 +FROM test_basic_operator; +---- +And X dat 🔥 +Xia Xia dat dat +Rap R dat аФу +NULL R NULL 🔥 + # -------------------------------------- # test distinct aggregate # -------------------------------------- @@ -324,3 +337,358 @@ NULL NULL statement ok drop table test_lowercase; + +# -------------------------------------- +# Test ASCII +# -------------------------------------- + +query IIII +SELECT + ASCII(ascii_1) as c1, + ASCII(ascii_2) as c2, + ASCII(unicode_1) as c3, + ASCII(unicode_2) as c4 +FROM test_basic_operator; +---- +65 88 100 128293 +88 88 100 100 +82 82 100 1072 +NULL 82 NULL 128293 + +# -------------------------------------- +# Test BTRIM +# -------------------------------------- + +# Test BTRIM outputs +query TTTTTT +SELECT + BTRIM(ascii_1, 'foo'), + BTRIM(ascii_1, 'A'), + BTRIM(ascii_1, NULL), + BTRIM(unicode_1), + BTRIM(unicode_1, '🔥'), + BTRIM(unicode_1, NULL) +FROM test_basic_operator; +---- +Andrew ndrew NULL datafusion📊🔥 datafusion📊 NULL +Xiangpeng Xiangpeng NULL datafusion数据融合 datafusion数据融合 NULL +Raphael Raphael NULL datafusionДатаФусион datafusionДатаФусион NULL +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test LTRIM +# -------------------------------------- + +# Test LTRIM outputs +query TTTTTT +SELECT + LTRIM(ascii_1, 'foo'), + LTRIM(ascii_1, ascii_2), + LTRIM(ascii_1, NULL), + LTRIM(unicode_1), + LTRIM(unicode_1, NULL), + LTRIM(unicode_1, '🔥') +FROM test_basic_operator; +---- +Andrew Andrew NULL datafusion📊🔥 NULL datafusion📊🔥 +Xiangpeng (empty) NULL datafusion数据融合 NULL datafusion数据融合 +Raphael aphael NULL datafusionДатаФусион NULL datafusionДатаФусион +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test RTRIM +# -------------------------------------- + +# Test RTRIM outputs +query TTTTT +SELECT + RTRIM(ascii_1, 'rew'), + RTRIM(ascii_1, ascii_2), + RTRIM(ascii_1), + RTRIM(unicode_1, NULL), + RTRIM(unicode_1, '🔥') +FROM test_basic_operator; +---- +And Andrew Andrew NULL datafusion📊 +Xiangpeng (empty) Xiangpeng NULL datafusion数据融合 +Raphael Raphael Raphael NULL datafusionДатаФусион +NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test CONTAINS +# -------------------------------------- + +query BBBBBB +SELECT + CONTAINS(ascii_1, 'foo') as c1, + CONTAINS(ascii_1, ascii_2) as c2, + CONTAINS(ascii_1, NULL) as c3, + CONTAINS(unicode_1, unicode_2) as c4, + CONTAINS(unicode_1, NULL) as c5, + CONTAINS(unicode_1, '🔥') as c6 +FROM test_basic_operator; +---- +false false NULL true NULL true +false true NULL true NULL false +false true NULL true NULL false +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test LOWER +# -------------------------------------- + +query TT +SELECT LOWER(ascii_1) as c1, LOWER(unicode_1) as c2 FROM test_basic_operator; +---- +andrew datafusion📊🔥 +xiangpeng datafusion数据融合 +raphael datafusionдатафусион +NULL NULL + +# -------------------------------------- +# Test UPPER +# -------------------------------------- + +query TT +SELECT UPPER(ascii_1) as c1, UPPER(unicode_1) as c2 FROM test_basic_operator; +---- +ANDREW DATAFUSION📊🔥 +XIANGPENG DATAFUSION数据融合 +RAPHAEL DATAFUSIONДАТАФУСИОН +NULL NULL + +# -------------------------------------- +# Test Concat +# -------------------------------------- + +query TTTTTTTTTTTT +SELECT + concat(ascii_1, ':Data'), + concat(ascii_1, ascii_2), + concat(ascii_1, NULL), + concat(ascii_1, unicode_1), + concat(ascii_1, unicode_2), + concat(unicode_1, ascii_1), + concat(unicode_1, unicode_2), + concat(unicode_1, NULL), + concat(unicode_1, '🔥'), + concat(NULL, '🔥'), + concat(NULL, NULL), + concat(ascii_1, ',', unicode_1) +FROM test_basic_operator; +---- +Andrew:Data AndrewX Andrew Andrewdatafusion📊🔥 Andrew🔥 datafusion📊🔥Andrew datafusion📊🔥🔥 datafusion📊🔥 datafusion📊🔥🔥 🔥 (empty) Andrew,datafusion📊🔥 +Xiangpeng:Data XiangpengXiangpeng Xiangpeng Xiangpengdatafusion数据融合 Xiangpengdatafusion数据融合 datafusion数据融合Xiangpeng datafusion数据融合datafusion数据融合 datafusion数据融合 datafusion数据融合🔥 🔥 (empty) Xiangpeng,datafusion数据融合 +Raphael:Data RaphaelR Raphael RaphaeldatafusionДатаФусион RaphaelаФус datafusionДатаФусионRaphael datafusionДатаФусионаФус datafusionДатаФусион datafusionДатаФусион🔥 🔥 (empty) Raphael,datafusionДатаФусион +:Data R (empty) (empty) 🔥 (empty) 🔥 (empty) 🔥 🔥 (empty) , + +# -------------------------------------- +# Test OVERLAY +# -------------------------------------- + +query TTTTTT +SELECT + OVERLAY(ascii_1 PLACING 'foo' FROM 2 ), + OVERLAY(unicode_1 PLACING 'foo' FROM 2), + OVERLAY(ascii_1 PLACING '🔥' FROM 2), + OVERLAY(unicode_1 PLACING '🔥' FROM 2), + OVERLAY(ascii_1 PLACING NULL FROM 2), + OVERLAY(unicode_1 PLACING NULL FROM 2) +FROM test_basic_operator; +---- +Afooew dfoofusion📊🔥 A🔥drew d🔥tafusion📊🔥 NULL NULL +Xfoogpeng dfoofusion数据融合 X🔥angpeng d🔥tafusion数据融合 NULL NULL +Rfooael dfoofusionДатаФусион R🔥phael d🔥tafusionДатаФусион NULL NULL +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test REPLACE +# -------------------------------------- + +query TTTTTT +SELECT + REPLACE(ascii_1, 'foo', 'bar'), + REPLACE(ascii_1, ascii_2, 'bar'), + REPLACE(ascii_1, NULL, 'bar'), + REPLACE(unicode_1, unicode_2, 'bar'), + REPLACE(unicode_1, NULL, 'bar'), + REPLACE(unicode_1, '🔥', 'bar') +FROM test_basic_operator; +---- +Andrew Andrew NULL datafusion📊bar NULL datafusion📊bar +Xiangpeng bar NULL bar NULL datafusion数据融合 +Raphael baraphael NULL datafusionДатbarион NULL datafusionДатаФусион +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test RIGHT +# -------------------------------------- +# Test outputs of RIGHT +query TTTTTT +SELECT + RIGHT(ascii_1, 3), + RIGHT(ascii_1, 0), + RIGHT(ascii_1, -3), + RIGHT(unicode_1, 3), + RIGHT(unicode_1, 0), + RIGHT(unicode_1, -3) +FROM test_basic_operator; +---- +rew (empty) rew n📊🔥 (empty) afusion📊🔥 +eng (empty) ngpeng 据融合 (empty) afusion数据融合 +ael (empty) hael ион (empty) afusionДатаФусион +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test LEFT +# -------------------------------------- + +# Test outputs of LEFT +query TTTTTT +SELECT + LEFT(ascii_1, 3), + LEFT(ascii_1, 0), + LEFT(ascii_1, -3), + LEFT(unicode_1, 3), + LEFT(unicode_1, 0), + LEFT(unicode_1, -3) +FROM test_basic_operator; +---- +And (empty) And dat (empty) datafusio +Xia (empty) Xiangp dat (empty) datafusion数 +Rap (empty) Raph dat (empty) datafusionДатаФус +NULL NULL NULL NULL NULL NULL + +# -------------------------------------- +# Test SUBSTR_INDEX +# -------------------------------------- + +query TTTT +SELECT + SUBSTR_INDEX(ascii_1, 'a', 1), + SUBSTR_INDEX(ascii_1, 'a', 2), + SUBSTR_INDEX(unicode_1, 'а', 1), + SUBSTR_INDEX(unicode_1, 'а', 2) +FROM test_basic_operator; +---- +Andrew Andrew datafusion📊🔥 datafusion📊🔥 +Xi Xiangpeng datafusion数据融合 datafusion数据融合 +R Raph datafusionД datafusionДат +NULL NULL NULL NULL + +# -------------------------------------- +# Test FIND_IN_SET +# -------------------------------------- + +query IIII +SELECT + FIND_IN_SET(ascii_1, 'a,b,c,d'), + FIND_IN_SET(ascii_1, 'Andrew,Xiangpeng,Raphael'), + FIND_IN_SET(unicode_1, 'a,b,c,d'), + FIND_IN_SET(unicode_1, 'datafusion📊🔥,datafusion数据融合,datafusionДатаФусион') +FROM test_basic_operator; +---- +0 1 0 1 +0 2 0 2 +0 3 0 3 +NULL NULL NULL NULL + +# -------------------------------------- +# Test || operator +# -------------------------------------- + +# || constants +# expect all results to be the same for each row as they all have the same values +query TTTT +SELECT + ascii_1 || 'foo', + ascii_1 || '🔥', + unicode_1 || 'foo', + unicode_1 || '🔥' +FROM test_basic_operator; +---- +Andrewfoo Andrew🔥 datafusion📊🔥foo datafusion📊🔥🔥 +Xiangpengfoo Xiangpeng🔥 datafusion数据融合foo datafusion数据融合🔥 +Raphaelfoo Raphael🔥 datafusionДатаФусионfoo datafusionДатаФусион🔥 +NULL NULL NULL NULL + +# || same type (column1 has null, so also tests NULL || NULL) +# expect all results to be the same for each row as they all have the same values +query TTTT +SELECT + ascii_1 || ascii_2, + ascii_1 || unicode_2, + unicode_1 || ascii_2, + unicode_1 || unicode_2 +FROM test_basic_operator; +---- +AndrewX Andrew🔥 datafusion📊🔥X datafusion📊🔥🔥 +XiangpengXiangpeng Xiangpengdatafusion数据融合 datafusion数据融合Xiangpeng datafusion数据融合datafusion数据融合 +RaphaelR RaphaelаФус datafusionДатаФусионR datafusionДатаФусионаФус +NULL NULL NULL NULL + +# -------------------------------------- +# Test ~ operator +# -------------------------------------- + +query BB +SELECT + ascii_1 ~ 'an', + unicode_1 ~ 'таФ' +FROM test_basic_operator; +---- +false false +true false +false true +NULL NULL + +query BB +SELECT + ascii_1 ~* '^a.{3}e', + unicode_1 ~* '^d.*Фу' +FROM test_basic_operator; +---- +true false +false false +false true +NULL NULL + +query BB +SELECT + ascii_1 !~~ 'xia_g%g', + unicode_1 !~~ 'datafusion数据融合' +FROM test_basic_operator; +---- +true true +true false +true true +NULL NULL + +query BB +SELECT + ascii_1 !~~* 'xia_g%g', + unicode_1 !~~* 'datafusion数据融合' +FROM test_basic_operator; +---- +true true +false false +true true +NULL NULL + +# -------------------------------------- +# Test || operator +# -------------------------------------- + +query TTTTT +select + ascii_1 || ' nice', + ascii_1 || ' and ' || ascii_2, + unicode_1 || ' cool', + unicode_1 || ' and ' || unicode_2, + ascii_1 || ' 🔥 ' || unicode_1 +from test_basic_operator; +---- +Andrew nice Andrew and X datafusion📊🔥 cool datafusion📊🔥 and 🔥 Andrew 🔥 datafusion📊🔥 +Xiangpeng nice Xiangpeng and Xiangpeng datafusion数据融合 cool datafusion数据融合 and datafusion数据融合 Xiangpeng 🔥 datafusion数据融合 +Raphael nice Raphael and R datafusionДатаФусион cool datafusionДатаФусион and аФус Raphael 🔥 datafusionДатаФусион +NULL NULL NULL NULL NULL diff --git a/datafusion/sqllogictest/test_files/string/string_view.slt b/datafusion/sqllogictest/test_files/string/string_view.slt index ca08f647d246..da7d99cc311b 100644 --- a/datafusion/sqllogictest/test_files/string/string_view.slt +++ b/datafusion/sqllogictest/test_files/string/string_view.slt @@ -352,5 +352,651 @@ logical_plan statement ok drop table test_lowercase +# Ensure string functions use native StringView implementation +# and do not fall back to Utf8 or LargeUtf8 +# Should see no casts to Utf8 in the plans below + +## Ensure no casts for LIKE/ILIKE +query TT +EXPLAIN SELECT + column1_utf8view like 'foo' as "like", + column1_utf8view ilike 'foo' as "ilike" +FROM test; +---- +logical_plan +01)Projection: test.column1_utf8view LIKE Utf8View("foo") AS like, test.column1_utf8view ILIKE Utf8View("foo") AS ilike +02)--TableScan: test projection=[column1_utf8view] + + +query TT +EXPLAIN SELECT + SUBSTR(column1_utf8view, 1, 3) as c1, + SUBSTR(column2_utf8, 1, 3) as c2, + SUBSTR(column2_large_utf8, 1, 3) as c3 +FROM test; +---- +logical_plan +01)Projection: substr(test.column1_utf8view, Int64(1), Int64(3)) AS c1, substr(test.column2_utf8, Int64(1), Int64(3)) AS c2, substr(test.column2_large_utf8, Int64(1), Int64(3)) AS c3 +02)--TableScan: test projection=[column2_utf8, column2_large_utf8, column1_utf8view] + +## Ensure no casts for SUBSTR + +query TT +EXPLAIN SELECT + SUBSTR(column1_utf8view, 1, 3) as c1, + SUBSTR(column2_utf8, 1, 3) as c2, + SUBSTR(column2_large_utf8, 1, 3) as c3 +FROM test; +---- +logical_plan +01)Projection: substr(test.column1_utf8view, Int64(1), Int64(3)) AS c1, substr(test.column2_utf8, Int64(1), Int64(3)) AS c2, substr(test.column2_large_utf8, Int64(1), Int64(3)) AS c3 +02)--TableScan: test projection=[column2_utf8, column2_large_utf8, column1_utf8view] + +# Test ASCII with utf8view against utf8view, utf8, and largeutf8 +# (should be no casts) +query TT +EXPLAIN SELECT + ASCII(column1_utf8view) as c1, + ASCII(column2_utf8) as c2, + ASCII(column2_large_utf8) as c3 +FROM test; +---- +logical_plan +01)Projection: ascii(test.column1_utf8view) AS c1, ascii(test.column2_utf8) AS c2, ascii(test.column2_large_utf8) AS c3 +02)--TableScan: test projection=[column2_utf8, column2_large_utf8, column1_utf8view] + +query TT +EXPLAIN SELECT + ASCII(column1_utf8) as c1, + ASCII(column1_large_utf8) as c2, + ASCII(column2_utf8view) as c3, + ASCII('hello') as c4, + ASCII(arrow_cast('world', 'Utf8View')) as c5 +FROM test; +---- +logical_plan +01)Projection: ascii(test.column1_utf8) AS c1, ascii(test.column1_large_utf8) AS c2, ascii(test.column2_utf8view) AS c3, Int32(104) AS c4, Int32(119) AS c5 +02)--TableScan: test projection=[column1_utf8, column1_large_utf8, column2_utf8view] + +# Test ASCII with literals cast to Utf8View +query TT +EXPLAIN SELECT + ASCII(arrow_cast('äöüß', 'Utf8View')) as c1, + ASCII(arrow_cast('', 'Utf8View')) as c2, + ASCII(arrow_cast(NULL, 'Utf8View')) as c3 +FROM test; +---- +logical_plan +01)Projection: Int32(228) AS c1, Int32(0) AS c2, Int32(NULL) AS c3 +02)--TableScan: test projection=[] + +## Ensure no casts for BTRIM +# Test BTRIM with Utf8View input +query TT +EXPLAIN SELECT + BTRIM(column1_utf8view) AS l +FROM test; +---- +logical_plan +01)Projection: btrim(test.column1_utf8view) AS l +02)--TableScan: test projection=[column1_utf8view] + +# Test BTRIM with Utf8View input and Utf8View pattern +query TT +EXPLAIN SELECT + BTRIM(column1_utf8view, 'foo') AS l +FROM test; +---- +logical_plan +01)Projection: btrim(test.column1_utf8view, Utf8View("foo")) AS l +02)--TableScan: test projection=[column1_utf8view] + +# Test BTRIM with Utf8View bytes longer than 12 +query TT +EXPLAIN SELECT + BTRIM(column1_utf8view, 'this is longer than 12') AS l +FROM test; +---- +logical_plan +01)Projection: btrim(test.column1_utf8view, Utf8View("this is longer than 12")) AS l +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for LTRIM +# Test LTRIM with Utf8View input +query TT +EXPLAIN SELECT + LTRIM(column1_utf8view) AS l +FROM test; +---- +logical_plan +01)Projection: ltrim(test.column1_utf8view) AS l +02)--TableScan: test projection=[column1_utf8view] + +# Test LTRIM with Utf8View input and Utf8View pattern +query TT +EXPLAIN SELECT + LTRIM(column1_utf8view, 'foo') AS l +FROM test; +---- +logical_plan +01)Projection: ltrim(test.column1_utf8view, Utf8View("foo")) AS l +02)--TableScan: test projection=[column1_utf8view] + +# Test LTRIM with Utf8View bytes longer than 12 +query TT +EXPLAIN SELECT + LTRIM(column1_utf8view, 'this is longer than 12') AS l +FROM test; +---- +logical_plan +01)Projection: ltrim(test.column1_utf8view, Utf8View("this is longer than 12")) AS l +02)--TableScan: test projection=[column1_utf8view] + +## ensure no casts for RTRIM +# Test RTRIM with Utf8View input +query TT +EXPLAIN SELECT + RTRIM(column1_utf8view) AS l +FROM test; +---- +logical_plan +01)Projection: rtrim(test.column1_utf8view) AS l +02)--TableScan: test projection=[column1_utf8view] + +# Test RTRIM with Utf8View input and Utf8View pattern +query TT +EXPLAIN SELECT + RTRIM(column1_utf8view, 'foo') AS l +FROM test; +---- +logical_plan +01)Projection: rtrim(test.column1_utf8view, Utf8View("foo")) AS l +02)--TableScan: test projection=[column1_utf8view] + +# Test RTRIM with Utf8View bytes longer than 12 +query TT +EXPLAIN SELECT + RTRIM(column1_utf8view, 'this is longer than 12') AS l +FROM test; +---- +logical_plan +01)Projection: rtrim(test.column1_utf8view, Utf8View("this is longer than 12")) AS l +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for CHARACTER_LENGTH +query TT +EXPLAIN SELECT + CHARACTER_LENGTH(column1_utf8view) AS l +FROM test; +---- +logical_plan +01)Projection: character_length(test.column1_utf8view) AS l +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for CONCAT Utf8View +query TT +EXPLAIN SELECT + concat(column1_utf8view, column2_utf8view) as c +FROM test; +---- +logical_plan +01)Projection: concat(test.column1_utf8view, test.column2_utf8view) AS c +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for CONCAT LargeUtf8 +query TT +EXPLAIN SELECT + concat(column1_large_utf8, column2_large_utf8) as c +FROM test; +---- +logical_plan +01)Projection: concat(test.column1_large_utf8, test.column2_large_utf8) AS c +02)--TableScan: test projection=[column1_large_utf8, column2_large_utf8] + +## Ensure no casts for CONCAT_WS +query TT +EXPLAIN SELECT + concat_ws(', ', column1_utf8view, column2_utf8view) as c +FROM test; +---- +logical_plan +01)Projection: concat_ws(Utf8(", "), test.column1_utf8view, test.column2_utf8view) AS c +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for CONTAINS +query TT +EXPLAIN SELECT + CONTAINS(column1_utf8view, 'foo') as c1, + CONTAINS(column1_utf8view, column2_utf8view) as c2, + CONTAINS(column1_utf8view, column2_large_utf8) as c3, + CONTAINS(column1_utf8, column2_utf8view) as c4, + CONTAINS(column1_utf8, column2_utf8) as c5, + CONTAINS(column1_utf8, column2_large_utf8) as c6, + CONTAINS(column1_large_utf8, column1_utf8view) as c7, + CONTAINS(column1_large_utf8, column2_utf8) as c8, + CONTAINS(column1_large_utf8, column2_large_utf8) as c9 +FROM test; +---- +logical_plan +01)Projection: contains(test.column1_utf8view, Utf8("foo")) AS c1, contains(test.column1_utf8view, test.column2_utf8view) AS c2, contains(test.column1_utf8view, test.column2_large_utf8) AS c3, contains(test.column1_utf8, test.column2_utf8view) AS c4, contains(test.column1_utf8, test.column2_utf8) AS c5, contains(test.column1_utf8, test.column2_large_utf8) AS c6, contains(test.column1_large_utf8, test.column1_utf8view) AS c7, contains(test.column1_large_utf8, test.column2_utf8) AS c8, contains(test.column1_large_utf8, test.column2_large_utf8) AS c9 +02)--TableScan: test projection=[column1_utf8, column2_utf8, column1_large_utf8, column2_large_utf8, column1_utf8view, column2_utf8view] + +## Ensure no casts for ENDS_WITH +query TT +EXPLAIN SELECT + ENDS_WITH(column1_utf8view, 'foo') as c1, + ENDS_WITH(column2_utf8view, column2_utf8view) as c2 +FROM test; +---- +logical_plan +01)Projection: ends_with(test.column1_utf8view, Utf8View("foo")) AS c1, ends_with(test.column2_utf8view, test.column2_utf8view) AS c2 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for LEVENSHTEIN +query TT +EXPLAIN SELECT + levenshtein(column1_utf8view, 'foo') as c1, + levenshtein(column1_utf8view, column2_utf8view) as c2 +FROM test; +---- +logical_plan +01)Projection: levenshtein(test.column1_utf8view, Utf8View("foo")) AS c1, levenshtein(test.column1_utf8view, test.column2_utf8view) AS c2 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for LOWER +query TT +EXPLAIN SELECT + LOWER(column1_utf8view) as c1 +FROM test; +---- +logical_plan +01)Projection: lower(test.column1_utf8view) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for UPPER +query TT +EXPLAIN SELECT + UPPER(column1_utf8view) as c1 +FROM test; +---- +logical_plan +01)Projection: upper(test.column1_utf8view) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for LPAD +query TT +EXPLAIN SELECT + LPAD(column1_utf8view, 12, ' ') as c1 +FROM test; +---- +logical_plan +01)Projection: lpad(test.column1_utf8view, Int64(12), Utf8(" ")) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +query TT +EXPLAIN SELECT + LPAD(column1_utf8view, 12, column2_large_utf8) as c1 +FROM test; +---- +logical_plan +01)Projection: lpad(test.column1_utf8view, Int64(12), test.column2_large_utf8) AS c1 +02)--TableScan: test projection=[column2_large_utf8, column1_utf8view] + +query TT +EXPLAIN SELECT + LPAD(column1_utf8view, 12, column2_utf8view) as c1 +FROM test; +---- +logical_plan +01)Projection: lpad(test.column1_utf8view, Int64(12), test.column2_utf8view) AS c1 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for OCTET_LENGTH +query TT +EXPLAIN SELECT + OCTET_LENGTH(column1_utf8view) as c1 +FROM test; +---- +logical_plan +01)Projection: octet_length(test.column1_utf8view) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for OVERLAY +query TT +EXPLAIN SELECT + OVERLAY(column1_utf8view PLACING 'foo' FROM 2 ) as c1 +FROM test; +---- +logical_plan +01)Projection: overlay(test.column1_utf8view, Utf8View("foo"), Int64(2)) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +## Should run CONCAT successfully with utf8 and utf8view +query T +SELECT + concat(column1_utf8view, column2_utf8) as c +FROM test; +---- +AndrewX +XiangpengXiangpeng +RaphaelR +R + +## Should run CONCAT successfully with utf8 utf8view and largeutf8 +query T +SELECT + concat(column1_utf8view, column2_utf8, column2_large_utf8) as c +FROM test; +---- +AndrewXX +XiangpengXiangpengXiangpeng +RaphaelRR +RR + +## Ensure no casts for REGEXP_LIKE +query TT +EXPLAIN SELECT + REGEXP_LIKE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k +FROM test; +---- +logical_plan +01)Projection: regexp_like(CAST(test.column1_utf8view AS Utf8), Utf8("^https?://(?:www\.)?([^/]+)/.*$")) AS k +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for REGEXP_MATCH +query TT +EXPLAIN SELECT + REGEXP_MATCH(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k +FROM test; +---- +logical_plan +01)Projection: regexp_match(CAST(test.column1_utf8view AS Utf8), Utf8("^https?://(?:www\.)?([^/]+)/.*$")) AS k +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for REGEXP_REPLACE +query TT +EXPLAIN SELECT + REGEXP_REPLACE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k +FROM test; +---- +logical_plan +01)Projection: regexp_replace(test.column1_utf8view, Utf8("^https?://(?:www\.)?([^/]+)/.*$"), Utf8("\1")) AS k +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for REPEAT +query TT +EXPLAIN SELECT + REPEAT(column1_utf8view, 2) as c1 +FROM test; +---- +logical_plan +01)Projection: repeat(test.column1_utf8view, Int64(2)) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for REPLACE +query TT +EXPLAIN SELECT + REPLACE(column1_utf8view, 'foo', 'bar') as c1, + REPLACE(column1_utf8view, column2_utf8view, 'bar') as c2 +FROM test; +---- +logical_plan +01)Projection: replace(test.column1_utf8view, Utf8View("foo"), Utf8View("bar")) AS c1, replace(test.column1_utf8view, test.column2_utf8view, Utf8View("bar")) AS c2 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for REVERSE +query TT +EXPLAIN SELECT + REVERSE(column1_utf8view) as c1 +FROM test; +---- +logical_plan +01)Projection: reverse(test.column1_utf8view) AS c1 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for RIGHT +query TT +EXPLAIN SELECT + RIGHT(column1_utf8view, 3) as c2 +FROM test; +---- +logical_plan +01)Projection: right(test.column1_utf8view, Int64(3)) AS c2 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for LEFT +query TT +EXPLAIN SELECT + LEFT(column1_utf8view, 3) as c2 +FROM test; +---- +logical_plan +01)Projection: left(test.column1_utf8view, Int64(3)) AS c2 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for RPAD +query TT +EXPLAIN SELECT + RPAD(column1_utf8view, 1) as c1, + RPAD(column1_utf8view, 2, column2_utf8view) as c2 +FROM test; +---- +logical_plan +01)Projection: rpad(test.column1_utf8view, Int64(1)) AS c1, rpad(test.column1_utf8view, Int64(2), test.column2_utf8view) AS c2 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +query TT +EXPLAIN SELECT + RPAD(column1_utf8view, 12, column2_large_utf8) as c1 +FROM test; +---- +logical_plan +01)Projection: rpad(test.column1_utf8view, Int64(12), test.column2_large_utf8) AS c1 +02)--TableScan: test projection=[column2_large_utf8, column1_utf8view] + +query TT +EXPLAIN SELECT + RPAD(column1_utf8view, 12, column2_utf8view) as c1 +FROM test; +---- +logical_plan +01)Projection: rpad(test.column1_utf8view, Int64(12), test.column2_utf8view) AS c1 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for SPLIT_PART +query TT +EXPLAIN SELECT + SPLIT_PART(column1_utf8view, 'f', 1) as c1, + SPLIT_PART('testtesttest',column1_utf8view, 1) as c2 +FROM test; +---- +logical_plan +01)Projection: split_part(test.column1_utf8view, Utf8("f"), Int64(1)) AS c1, split_part(Utf8("testtesttest"), test.column1_utf8view, Int64(1)) AS c2 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for STRPOS +query TT +EXPLAIN SELECT + STRPOS(column1_utf8view, 'f') as c, + STRPOS(column1_utf8view, column2_utf8view) as c2 +FROM test; +---- +logical_plan +01)Projection: strpos(test.column1_utf8view, Utf8("f")) AS c, strpos(test.column1_utf8view, test.column2_utf8view) AS c2 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for SUBSTR +query TT +EXPLAIN SELECT + SUBSTR(column1_utf8view, 1) as c, + SUBSTR(column1_utf8view, 1 ,2) as c2 +FROM test; +---- +logical_plan +01)Projection: substr(test.column1_utf8view, Int64(1)) AS c, substr(test.column1_utf8view, Int64(1), Int64(2)) AS c2 +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for SUBSTRINDEX +query TT +EXPLAIN SELECT + SUBSTR_INDEX(column1_utf8view, 'a', 1) as c, + SUBSTR_INDEX(column1_utf8view, 'a', 2) as c2 +FROM test; +---- +logical_plan +01)Projection: substr_index(test.column1_utf8view, Utf8View("a"), Int64(1)) AS c, substr_index(test.column1_utf8view, Utf8View("a"), Int64(2)) AS c2 +02)--TableScan: test projection=[column1_utf8view] + + +## Ensure no casts on columns for STARTS_WITH +query TT +EXPLAIN SELECT + STARTS_WITH(column1_utf8view, 'foo') as c, + STARTS_WITH(column1_utf8view, column2_utf8view) as c2 +FROM test; +---- +logical_plan +01)Projection: starts_with(test.column1_utf8view, Utf8View("foo")) AS c, starts_with(test.column1_utf8view, test.column2_utf8view) AS c2 +02)--TableScan: test projection=[column1_utf8view, column2_utf8view] + +## Ensure no casts for TRANSLATE +query TT +EXPLAIN SELECT + TRANSLATE(column1_utf8view, 'foo', 'bar') as c +FROM test; +---- +logical_plan +01)Projection: translate(test.column1_utf8view, Utf8("foo"), Utf8("bar")) AS c +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for FIND_IN_SET +query TT +EXPLAIN SELECT + FIND_IN_SET(column1_utf8view, 'a,b,c,d') as c +FROM test; +---- +logical_plan +01)Projection: find_in_set(test.column1_utf8view, Utf8View("a,b,c,d")) AS c +02)--TableScan: test projection=[column1_utf8view] + +## Ensure no casts for binary operators +# `~` operator (regex match) +query TT +EXPLAIN SELECT + column1_utf8view ~ 'an' AS c1 +FROM test; +---- +logical_plan +01)Projection: CAST(test.column1_utf8view AS Utf8) LIKE Utf8("%an%") AS c1 +02)--TableScan: test projection=[column1_utf8view] + +# `~*` operator (regex match case-insensitive) +query TT +EXPLAIN SELECT + column1_utf8view ~* '^a.{3}e' AS c1 +FROM test; +---- +logical_plan +01)Projection: CAST(test.column1_utf8view AS Utf8) ~* Utf8("^a.{3}e") AS c1 +02)--TableScan: test projection=[column1_utf8view] + +# `!~~` operator (not like match) +query TT +EXPLAIN SELECT + column1_utf8view !~~ 'xia_g%g' AS c1 +FROM test; +---- +logical_plan +01)Projection: CAST(test.column1_utf8view AS Utf8) !~~ Utf8("xia_g%g") AS c1 +02)--TableScan: test projection=[column1_utf8view] + +# `!~~*` operator (not like match case-insensitive) +query TT +EXPLAIN SELECT + column1_utf8view !~~* 'xia_g%g' AS c1 +FROM test; +---- +logical_plan +01)Projection: CAST(test.column1_utf8view AS Utf8) !~~* Utf8("xia_g%g") AS c1 +02)--TableScan: test projection=[column1_utf8view] + +# coercions between stringview and date types +statement ok +create table dates (dt date) as values + (date '2024-01-23'), + (date '2023-11-30'); + +query D +select t.dt from dates t where arrow_cast('2024-01-01', 'Utf8View') < t.dt; +---- +2024-01-23 + +statement ok +drop table dates; + +### Tests for `||` with Utf8View specifically + +statement ok +create table temp as values +('value1', arrow_cast('rust', 'Utf8View'), arrow_cast('fast', 'Utf8View')), +('value2', arrow_cast('datafusion', 'Utf8View'), arrow_cast('cool', 'Utf8View')); + +query TTT +select arrow_typeof(column1), arrow_typeof(column2), arrow_typeof(column3) from temp; +---- +Utf8 Utf8View Utf8View +Utf8 Utf8View Utf8View + +query TT +explain select column2 || 'is' || column3 from temp; +---- +logical_plan +01)Projection: temp.column2 || Utf8View("is") || temp.column3 AS temp.column2 || Utf8("is") || temp.column3 +02)--TableScan: temp projection=[column2, column3] + +# should not cast the column2 to utf8 +query TT +explain select column2||' is fast' from temp; +---- +logical_plan +01)Projection: temp.column2 || Utf8View(" is fast") AS temp.column2 || Utf8(" is fast") +02)--TableScan: temp projection=[column2] + +query TT +explain select column2||column3 from temp; +---- +logical_plan +01)Projection: temp.column2 || temp.column3 +02)--TableScan: temp projection=[column2, column3] + +################################################ +# Test for Dictionary String concatenation +################################################ + +# || same type (column1 has null, so also tests NULL || NULL) +# expect all results to be the same for each row as they all have the same values +query T +SELECT + column1_dict || column1_dict +FROM test; +---- +AndrewAndrew +XiangpengXiangpeng +RaphaelRaphael +NULL + +# || constants +# expect all results to be the same for each row as they all have the same values +query TT +SELECT + column1_dict || 'foo', + 'foo' || column1_dict +FROM test; +---- +Andrewfoo fooAndrew +Xiangpengfoo fooXiangpeng +Raphaelfoo fooRaphael +NULL NULL + statement ok drop table test diff --git a/datafusion/sqllogictest/test_files/string_view.slt b/datafusion/sqllogictest/test_files/string_view.slt deleted file mode 100644 index 4e99d8cfa675..000000000000 --- a/datafusion/sqllogictest/test_files/string_view.slt +++ /dev/null @@ -1,1093 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -######## -## Test setup -######## - -statement ok -create table test_source as values - ('Andrew', 'X'), - ('Xiangpeng', 'Xiangpeng'), - ('Raphael', 'R'), - (NULL, 'R'); - -# Table with the different combination of column types -statement ok -create table test as -SELECT - arrow_cast(column1, 'Utf8') as column1_utf8, - arrow_cast(column2, 'Utf8') as column2_utf8, - arrow_cast(column1, 'LargeUtf8') as column1_large_utf8, - arrow_cast(column2, 'LargeUtf8') as column2_large_utf8, - arrow_cast(column1, 'Utf8View') as column1_utf8view, - arrow_cast(column2, 'Utf8View') as column2_utf8view, - arrow_cast(column1, 'Dictionary(Int32, Utf8)') as column1_dict, - arrow_cast(column2, 'Dictionary(Int32, Utf8)') as column2_dict -FROM test_source; - -statement ok -drop table test_source - -statement ok -set datafusion.explain.logical_plan_only = true; - -# Ensure string functions use native StringView implementation -# and do not fall back to Utf8 or LargeUtf8 -# Should see no casts to Utf8 in the plans below - -## Ensure no casts for LIKE/ILIKE -query TT -EXPLAIN SELECT - column1_utf8view like 'foo' as "like", - column1_utf8view ilike 'foo' as "ilike" -FROM test; ----- -logical_plan -01)Projection: test.column1_utf8view LIKE Utf8View("foo") AS like, test.column1_utf8view ILIKE Utf8View("foo") AS ilike -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for SUBSTR - -query TT -EXPLAIN SELECT - SUBSTR(column1_utf8view, 1, 3) as c1, - SUBSTR(column2_utf8, 1, 3) as c2, - SUBSTR(column2_large_utf8, 1, 3) as c3 -FROM test; ----- -logical_plan -01)Projection: substr(test.column1_utf8view, Int64(1), Int64(3)) AS c1, substr(test.column2_utf8, Int64(1), Int64(3)) AS c2, substr(test.column2_large_utf8, Int64(1), Int64(3)) AS c3 -02)--TableScan: test projection=[column2_utf8, column2_large_utf8, column1_utf8view] - -query TTT -SELECT - SUBSTR(column1_utf8view, 1, 3) as c1, - SUBSTR(column2_utf8, 1, 3) as c2, - SUBSTR(column2_large_utf8, 1, 3) as c3 -FROM test; ----- -And X X -Xia Xia Xia -Rap R R -NULL R R - -## Ensure no casts for ASCII - -### ASCII - -# Test ASCII with utf8view against utf8view, utf8, and largeutf8 -# (should be no casts) -query TT -EXPLAIN SELECT - ASCII(column1_utf8view) as c1, - ASCII(column2_utf8) as c2, - ASCII(column2_large_utf8) as c3 -FROM test; ----- -logical_plan -01)Projection: ascii(test.column1_utf8view) AS c1, ascii(test.column2_utf8) AS c2, ascii(test.column2_large_utf8) AS c3 -02)--TableScan: test projection=[column2_utf8, column2_large_utf8, column1_utf8view] - -query III -SELECT - ASCII(column1_utf8view) as c1, - ASCII(column2_utf8) as c2, - ASCII(column2_large_utf8) as c3 -FROM test; ----- -65 88 88 -88 88 88 -82 82 82 -NULL 82 82 - -query TT -EXPLAIN SELECT - ASCII(column1_utf8) as c1, - ASCII(column1_large_utf8) as c2, - ASCII(column2_utf8view) as c3, - ASCII('hello') as c4, - ASCII(arrow_cast('world', 'Utf8View')) as c5 -FROM test; ----- -logical_plan -01)Projection: ascii(test.column1_utf8) AS c1, ascii(test.column1_large_utf8) AS c2, ascii(test.column2_utf8view) AS c3, Int32(104) AS c4, Int32(119) AS c5 -02)--TableScan: test projection=[column1_utf8, column1_large_utf8, column2_utf8view] - -query IIIII -SELECT - ASCII(column1_utf8) as c1, - ASCII(column1_large_utf8) as c2, - ASCII(column2_utf8view) as c3, - ASCII('hello') as c4, - ASCII(arrow_cast('world', 'Utf8View')) as c5 -FROM test; ----- -65 65 88 104 119 -88 88 88 104 119 -82 82 82 104 119 -NULL NULL 82 104 119 - -# Test ASCII with literals cast to Utf8View -query TT -EXPLAIN SELECT - ASCII(arrow_cast('äöüß', 'Utf8View')) as c1, - ASCII(arrow_cast('', 'Utf8View')) as c2, - ASCII(arrow_cast(NULL, 'Utf8View')) as c3 -FROM test; ----- -logical_plan -01)Projection: Int32(228) AS c1, Int32(0) AS c2, Int32(NULL) AS c3 -02)--TableScan: test projection=[] - -query III -SELECT - ASCII(arrow_cast('äöüß', 'Utf8View')) as c1, - ASCII(arrow_cast('', 'Utf8View')) as c2, - ASCII(arrow_cast(NULL, 'Utf8View')) as c3 ----- -228 0 NULL - -## Ensure no casts for BTRIM -# Test BTRIM with Utf8View input -query TT -EXPLAIN SELECT - BTRIM(column1_utf8view) AS l -FROM test; ----- -logical_plan -01)Projection: btrim(test.column1_utf8view) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test BTRIM with Utf8View input and Utf8View pattern -query TT -EXPLAIN SELECT - BTRIM(column1_utf8view, 'foo') AS l -FROM test; ----- -logical_plan -01)Projection: btrim(test.column1_utf8view, Utf8View("foo")) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test BTRIM with Utf8View bytes longer than 12 -query TT -EXPLAIN SELECT - BTRIM(column1_utf8view, 'this is longer than 12') AS l -FROM test; ----- -logical_plan -01)Projection: btrim(test.column1_utf8view, Utf8View("this is longer than 12")) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test BTRIM outputs -query TTTT -SELECT - BTRIM(column1_utf8view, 'foo') AS l1, - BTRIM(column1_utf8view, 'A') AS l2, - BTRIM(column1_utf8view) AS l3, - BTRIM(column1_utf8view, NULL) AS l4 -FROM test; ----- -Andrew ndrew Andrew NULL -Xiangpeng Xiangpeng Xiangpeng NULL -Raphael Raphael Raphael NULL -NULL NULL NULL NULL - -## Ensure no casts for LTRIM -# Test LTRIM with Utf8View input -query TT -EXPLAIN SELECT - LTRIM(column1_utf8view) AS l -FROM test; ----- -logical_plan -01)Projection: ltrim(test.column1_utf8view) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test LTRIM with Utf8View input and Utf8View pattern -query TT -EXPLAIN SELECT - LTRIM(column1_utf8view, 'foo') AS l -FROM test; ----- -logical_plan -01)Projection: ltrim(test.column1_utf8view, Utf8View("foo")) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test LTRIM with Utf8View bytes longer than 12 -query TT -EXPLAIN SELECT - LTRIM(column1_utf8view, 'this is longer than 12') AS l -FROM test; ----- -logical_plan -01)Projection: ltrim(test.column1_utf8view, Utf8View("this is longer than 12")) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test LTRIM outputs -query TTTTT -SELECT - LTRIM(column1_utf8view, 'foo') AS l1, - LTRIM(column1_utf8view, column2_utf8view) AS l2, - LTRIM(column1_utf8view) AS l3, - LTRIM(column1_utf8view, NULL) AS l4, - LTRIM(column1_utf8view, 'Xiang') AS l5 -FROM test; ----- -Andrew Andrew Andrew NULL Andrew -Xiangpeng (empty) Xiangpeng NULL peng -Raphael aphael Raphael NULL Raphael -NULL NULL NULL NULL NULL - -## ensure no casts for RTRIM -# Test RTRIM with Utf8View input -query TT -EXPLAIN SELECT - RTRIM(column1_utf8view) AS l -FROM test; ----- -logical_plan -01)Projection: rtrim(test.column1_utf8view) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test RTRIM with Utf8View input and Utf8View pattern -query TT -EXPLAIN SELECT - RTRIM(column1_utf8view, 'foo') AS l -FROM test; ----- -logical_plan -01)Projection: rtrim(test.column1_utf8view, Utf8View("foo")) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test RTRIM with Utf8View bytes longer than 12 -query TT -EXPLAIN SELECT - RTRIM(column1_utf8view, 'this is longer than 12') AS l -FROM test; ----- -logical_plan -01)Projection: rtrim(test.column1_utf8view, Utf8View("this is longer than 12")) AS l -02)--TableScan: test projection=[column1_utf8view] - -# Test RTRIM outputs -query TTTTT -SELECT - RTRIM(column1_utf8view, 'foo') AS l1, - RTRIM(column1_utf8view, column2_utf8view) AS l2, - RTRIM(column1_utf8view) AS l3, - RTRIM(column1_utf8view, NULL) AS l4, - RTRIM(column1_utf8view, 'peng') As l5 -FROM test; ----- -Andrew Andrew Andrew NULL Andrew -Xiangpeng (empty) Xiangpeng NULL Xia -Raphael Raphael Raphael NULL Raphael -NULL NULL NULL NULL NULL - - -## Ensure no casts for CHARACTER_LENGTH -query TT -EXPLAIN SELECT - CHARACTER_LENGTH(column1_utf8view) AS l -FROM test; ----- -logical_plan -01)Projection: character_length(test.column1_utf8view) AS l -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for CONCAT Utf8View -query TT -EXPLAIN SELECT - concat(column1_utf8view, column2_utf8view) as c -FROM test; ----- -logical_plan -01)Projection: concat(test.column1_utf8view, test.column2_utf8view) AS c -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for CONCAT LargeUtf8 -query TT -EXPLAIN SELECT - concat(column1_large_utf8, column2_large_utf8) as c -FROM test; ----- -logical_plan -01)Projection: concat(test.column1_large_utf8, test.column2_large_utf8) AS c -02)--TableScan: test projection=[column1_large_utf8, column2_large_utf8] - -## Ensure no casts for CONCAT_WS -## TODO https://github.com/apache/datafusion/issues/11837 -query TT -EXPLAIN SELECT - concat_ws(', ', column1_utf8view, column2_utf8view) as c -FROM test; ----- -logical_plan -01)Projection: concat_ws(Utf8(", "), test.column1_utf8view, test.column2_utf8view) AS c -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for CONTAINS -query TT -EXPLAIN SELECT - CONTAINS(column1_utf8view, 'foo') as c1, - CONTAINS(column1_utf8view, column2_utf8view) as c2, - CONTAINS(column1_utf8view, column2_large_utf8) as c3, - CONTAINS(column1_utf8, column2_utf8view) as c4, - CONTAINS(column1_utf8, column2_utf8) as c5, - CONTAINS(column1_utf8, column2_large_utf8) as c6, - CONTAINS(column1_large_utf8, column1_utf8view) as c7, - CONTAINS(column1_large_utf8, column2_utf8) as c8, - CONTAINS(column1_large_utf8, column2_large_utf8) as c9 -FROM test; ----- -logical_plan -01)Projection: contains(test.column1_utf8view, Utf8("foo")) AS c1, contains(test.column1_utf8view, test.column2_utf8view) AS c2, contains(test.column1_utf8view, test.column2_large_utf8) AS c3, contains(test.column1_utf8, test.column2_utf8view) AS c4, contains(test.column1_utf8, test.column2_utf8) AS c5, contains(test.column1_utf8, test.column2_large_utf8) AS c6, contains(test.column1_large_utf8, test.column1_utf8view) AS c7, contains(test.column1_large_utf8, test.column2_utf8) AS c8, contains(test.column1_large_utf8, test.column2_large_utf8) AS c9 -02)--TableScan: test projection=[column1_utf8, column2_utf8, column1_large_utf8, column2_large_utf8, column1_utf8view, column2_utf8view] - -query BBBBBBBBB -SELECT - CONTAINS(column1_utf8view, 'foo') as c1, - CONTAINS(column1_utf8view, column2_utf8view) as c2, - CONTAINS(column1_utf8view, column2_large_utf8) as c3, - CONTAINS(column1_utf8, column2_utf8view) as c4, - CONTAINS(column1_utf8, column2_utf8) as c5, - CONTAINS(column1_utf8, column2_large_utf8) as c6, - CONTAINS(column1_large_utf8, column1_utf8view) as c7, - CONTAINS(column1_large_utf8, column2_utf8) as c8, - CONTAINS(column1_large_utf8, column2_large_utf8) as c9 -FROM test; ----- -false false false false false false true false false -false true true true true true true true true -false true true true true true true true true -NULL NULL NULL NULL NULL NULL NULL NULL NULL - -## Ensure no casts for ENDS_WITH -query TT -EXPLAIN SELECT - ENDS_WITH(column1_utf8view, 'foo') as c1, - ENDS_WITH(column2_utf8view, column2_utf8view) as c2 -FROM test; ----- -logical_plan -01)Projection: ends_with(test.column1_utf8view, Utf8View("foo")) AS c1, ends_with(test.column2_utf8view, test.column2_utf8view) AS c2 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for LEVENSHTEIN -query TT -EXPLAIN SELECT - levenshtein(column1_utf8view, 'foo') as c1, - levenshtein(column1_utf8view, column2_utf8view) as c2 -FROM test; ----- -logical_plan -01)Projection: levenshtein(test.column1_utf8view, Utf8View("foo")) AS c1, levenshtein(test.column1_utf8view, test.column2_utf8view) AS c2 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for LOWER -query TT -EXPLAIN SELECT - LOWER(column1_utf8view) as c1 -FROM test; ----- -logical_plan -01)Projection: lower(test.column1_utf8view) AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query T -SELECT LOWER(column1_utf8view) as c1 -FROM test; ----- -andrew -xiangpeng -raphael -NULL - -## Ensure no casts for UPPER -query TT -EXPLAIN SELECT - UPPER(column1_utf8view) as c1 -FROM test; ----- -logical_plan -01)Projection: upper(test.column1_utf8view) AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query T -SELECT UPPER(column1_utf8view) as c1 -FROM test; ----- -ANDREW -XIANGPENG -RAPHAEL -NULL - -## Should run CONCAT successfully with utf8view -query T -SELECT - concat(column1_utf8view, column2_utf8view) as c -FROM test; ----- -AndrewX -XiangpengXiangpeng -RaphaelR -R - -## Should run CONCAT successfully with utf8 -query T -SELECT - concat(column1_utf8, column2_utf8) as c -FROM test; ----- -AndrewX -XiangpengXiangpeng -RaphaelR -R - -## Should run CONCAT successfully with utf8 and utf8view -query T -SELECT - concat(column1_utf8view, column2_utf8) as c -FROM test; ----- -AndrewX -XiangpengXiangpeng -RaphaelR -R - -## Should run CONCAT successfully with utf8 utf8view and largeutf8 -query T -SELECT - concat(column1_utf8view, column2_utf8, column2_large_utf8) as c -FROM test; ----- -AndrewXX -XiangpengXiangpengXiangpeng -RaphaelRR -RR - -## Should run CONCAT successfully with utf8large -query T -SELECT - concat(column1_large_utf8, column2_large_utf8) as c -FROM test; ----- -AndrewX -XiangpengXiangpeng -RaphaelR -R - -## Should run CONCAT successfully with utf8view -query T -SELECT - concat(column1_utf8view, column2_utf8view) as c -FROM test; ----- -AndrewX -XiangpengXiangpeng -RaphaelR -R - -## Should run CONCAT_WS successfully with utf8 -query T -SELECT - concat_ws(',', column1_utf8, column2_utf8) as c -FROM test; ----- -Andrew,X -Xiangpeng,Xiangpeng -Raphael,R -R - -## Should run CONCAT_WS successfully with utf8view -query T -SELECT - concat_ws(',', column1_utf8view, column2_utf8view) as c -FROM test; ----- -Andrew,X -Xiangpeng,Xiangpeng -Raphael,R -R - -## Should run CONCAT_WS successfully with largeutf8 -query T -SELECT - concat_ws(',', column1_large_utf8, column2_large_utf8) as c -FROM test; ----- -Andrew,X -Xiangpeng,Xiangpeng -Raphael,R -R - -## Should run CONCAT_WS successfully with utf8 and largeutf8 -query T -SELECT - concat_ws(',', column1_utf8, column2_large_utf8) as c -FROM test; ----- -Andrew,X -Xiangpeng,Xiangpeng -Raphael,R -R - -## Should run CONCAT_WS successfully with utf8 and utf8view -query T -SELECT - concat_ws(',', column1_utf8view, column2_utf8) as c -FROM test; ----- -Andrew,X -Xiangpeng,Xiangpeng -Raphael,R -R - -## Should run CONCAT_WS successfully with largeutf8 and utf8view -query T -SELECT - concat_ws(',', column1_utf8view, column2_large_utf8) as c -FROM test; ----- -Andrew,X -Xiangpeng,Xiangpeng -Raphael,R -R - -## Ensure no casts for LPAD -query TT -EXPLAIN SELECT - LPAD(column1_utf8view, 12, ' ') as c1 -FROM test; ----- -logical_plan -01)Projection: lpad(test.column1_utf8view, Int64(12), Utf8(" ")) AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query TT -EXPLAIN SELECT - LPAD(column1_utf8view, 12, column2_large_utf8) as c1 -FROM test; ----- -logical_plan -01)Projection: lpad(test.column1_utf8view, Int64(12), test.column2_large_utf8) AS c1 -02)--TableScan: test projection=[column2_large_utf8, column1_utf8view] - -query TT -EXPLAIN SELECT - LPAD(column1_utf8view, 12, column2_utf8view) as c1 -FROM test; ----- -logical_plan -01)Projection: lpad(test.column1_utf8view, Int64(12), test.column2_utf8view) AS c1 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for OCTET_LENGTH -query TT -EXPLAIN SELECT - OCTET_LENGTH(column1_utf8view) as c1 -FROM test; ----- -logical_plan -01)Projection: octet_length(test.column1_utf8view) AS c1 -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for OVERLAY -query TT -EXPLAIN SELECT - OVERLAY(column1_utf8view PLACING 'foo' FROM 2 ) as c1 -FROM test; ----- -logical_plan -01)Projection: overlay(test.column1_utf8view, Utf8View("foo"), Int64(2)) AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query T -SELECT OVERLAY(column1_utf8view PLACING 'foo' FROM 2 ) as c1 FROM test; ----- -Afooew -Xfoogpeng -Rfooael -NULL - -## Ensure no casts for REGEXP_LIKE -query TT -EXPLAIN SELECT - REGEXP_LIKE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k -FROM test; ----- -logical_plan -01)Projection: regexp_like(CAST(test.column1_utf8view AS Utf8), Utf8("^https?://(?:www\.)?([^/]+)/.*$")) AS k -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for REGEXP_MATCH -query TT -EXPLAIN SELECT - REGEXP_MATCH(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k -FROM test; ----- -logical_plan -01)Projection: regexp_match(CAST(test.column1_utf8view AS Utf8), Utf8("^https?://(?:www\.)?([^/]+)/.*$")) AS k -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for REGEXP_REPLACE -query TT -EXPLAIN SELECT - REGEXP_REPLACE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k -FROM test; ----- -logical_plan -01)Projection: regexp_replace(test.column1_utf8view, Utf8("^https?://(?:www\.)?([^/]+)/.*$"), Utf8("\1")) AS k -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for REPEAT -query TT -EXPLAIN SELECT - REPEAT(column1_utf8view, 2) as c1 -FROM test; ----- -logical_plan -01)Projection: repeat(test.column1_utf8view, Int64(2)) AS c1 -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for REPLACE -query TT -EXPLAIN SELECT - REPLACE(column1_utf8view, 'foo', 'bar') as c1, - REPLACE(column1_utf8view, column2_utf8view, 'bar') as c2 -FROM test; ----- -logical_plan -01)Projection: replace(test.column1_utf8view, Utf8View("foo"), Utf8View("bar")) AS c1, replace(test.column1_utf8view, test.column2_utf8view, Utf8View("bar")) AS c2 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -query TT -SELECT - REPLACE(column1_utf8view, 'foo', 'bar') as c1, - REPLACE(column1_utf8view, column2_utf8view, 'bar') as c2 -FROM test; ----- -Andrew Andrew -Xiangpeng bar -Raphael baraphael -NULL NULL - - -## Ensure no casts for REVERSE -query TT -EXPLAIN SELECT - REVERSE(column1_utf8view) as c1 -FROM test; ----- -logical_plan -01)Projection: reverse(test.column1_utf8view) AS c1 -02)--TableScan: test projection=[column1_utf8view] - - -## Ensure no casts for RIGHT -query TT -EXPLAIN SELECT - RIGHT(column1_utf8view, 3) as c2 -FROM test; ----- -logical_plan -01)Projection: right(test.column1_utf8view, Int64(3)) AS c2 -02)--TableScan: test projection=[column1_utf8view] - -# Test outputs of RIGHT -query TTT -SELECT - RIGHT(column1_utf8view, 3) as c1, - RIGHT(column1_utf8view, 0) as c2, - RIGHT(column1_utf8view, -3) as c3 -FROM test; ----- -rew (empty) rew -eng (empty) ngpeng -ael (empty) hael -NULL NULL NULL - -## Ensure no casts for LEFT -query TT -EXPLAIN SELECT - LEFT(column1_utf8view, 3) as c2 -FROM test; ----- -logical_plan -01)Projection: left(test.column1_utf8view, Int64(3)) AS c2 -02)--TableScan: test projection=[column1_utf8view] - -# Test outputs of LEFT -query TTT -SELECT - LEFT(column1_utf8view, 3) as c1, - LEFT(column1_utf8view, 0) as c2, - LEFT(column1_utf8view, -3) as c3 -FROM test; ----- -And (empty) And -Xia (empty) Xiangp -Rap (empty) Raph -NULL NULL NULL - -## Ensure no casts for RPAD -query TT -EXPLAIN SELECT - RPAD(column1_utf8view, 1) as c1, - RPAD(column1_utf8view, 2, column2_utf8view) as c2 -FROM test; ----- -logical_plan -01)Projection: rpad(test.column1_utf8view, Int64(1)) AS c1, rpad(test.column1_utf8view, Int64(2), test.column2_utf8view) AS c2 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -query TT -EXPLAIN SELECT - RPAD(column1_utf8view, 12, column2_large_utf8) as c1 -FROM test; ----- -logical_plan -01)Projection: rpad(test.column1_utf8view, Int64(12), test.column2_large_utf8) AS c1 -02)--TableScan: test projection=[column2_large_utf8, column1_utf8view] - -query TT -EXPLAIN SELECT - RPAD(column1_utf8view, 12, column2_utf8view) as c1 -FROM test; ----- -logical_plan -01)Projection: rpad(test.column1_utf8view, Int64(12), test.column2_utf8view) AS c1 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for SPLIT_PART -query TT -EXPLAIN SELECT - SPLIT_PART(column1_utf8view, 'f', 1) as c1, - SPLIT_PART('testtesttest',column1_utf8view, 1) as c2 -FROM test; ----- -logical_plan -01)Projection: split_part(test.column1_utf8view, Utf8("f"), Int64(1)) AS c1, split_part(Utf8("testtesttest"), test.column1_utf8view, Int64(1)) AS c2 -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for STRPOS -query TT -EXPLAIN SELECT - STRPOS(column1_utf8view, 'f') as c, - STRPOS(column1_utf8view, column2_utf8view) as c2 -FROM test; ----- -logical_plan -01)Projection: strpos(test.column1_utf8view, Utf8("f")) AS c, strpos(test.column1_utf8view, test.column2_utf8view) AS c2 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for SUBSTR -query TT -EXPLAIN SELECT - SUBSTR(column1_utf8view, 1) as c, - SUBSTR(column1_utf8view, 1 ,2) as c2 -FROM test; ----- -logical_plan -01)Projection: substr(test.column1_utf8view, Int64(1)) AS c, substr(test.column1_utf8view, Int64(1), Int64(2)) AS c2 -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for SUBSTRINDEX -query TT -EXPLAIN SELECT - SUBSTR_INDEX(column1_utf8view, 'a', 1) as c, - SUBSTR_INDEX(column1_utf8view, 'a', 2) as c2 -FROM test; ----- -logical_plan -01)Projection: substr_index(test.column1_utf8view, Utf8View("a"), Int64(1)) AS c, substr_index(test.column1_utf8view, Utf8View("a"), Int64(2)) AS c2 -02)--TableScan: test projection=[column1_utf8view] - -query TT -SELECT - SUBSTR_INDEX(column1_utf8view, 'a', 1) as c, - SUBSTR_INDEX(column1_utf8view, 'a', 2) as c2 -FROM test; ----- -Andrew Andrew -Xi Xiangpeng -R Raph -NULL NULL - -## Ensure no casts on columns for STARTS_WITH -query TT -EXPLAIN SELECT - STARTS_WITH(column1_utf8view, 'foo') as c, - STARTS_WITH(column1_utf8view, column2_utf8view) as c2 -FROM test; ----- -logical_plan -01)Projection: starts_with(test.column1_utf8view, Utf8View("foo")) AS c, starts_with(test.column1_utf8view, test.column2_utf8view) AS c2 -02)--TableScan: test projection=[column1_utf8view, column2_utf8view] - -## Ensure no casts for TRANSLATE -query TT -EXPLAIN SELECT - TRANSLATE(column1_utf8view, 'foo', 'bar') as c -FROM test; ----- -logical_plan -01)Projection: translate(test.column1_utf8view, Utf8("foo"), Utf8("bar")) AS c -02)--TableScan: test projection=[column1_utf8view] - -## Ensure no casts for FIND_IN_SET -query TT -EXPLAIN SELECT - FIND_IN_SET(column1_utf8view, 'a,b,c,d') as c -FROM test; ----- -logical_plan -01)Projection: find_in_set(test.column1_utf8view, Utf8View("a,b,c,d")) AS c -02)--TableScan: test projection=[column1_utf8view] - -query I -SELECT - FIND_IN_SET(column1_utf8view, 'a,b,c,d') as c -FROM test; ----- -0 -0 -0 -NULL - -# || mixed types -# expect all results to be the same for each row as they all have the same values -query TTTTTTTT -SELECT - column1_utf8view || column2_utf8view, - column1_utf8 || column2_utf8view, - column1_large_utf8 || column2_utf8view, - column1_dict || column2_utf8view, - -- reverse argument order - column2_utf8view || column1_utf8view, - column2_utf8view || column1_utf8, - column2_utf8view || column1_large_utf8, - column2_utf8view || column1_dict -FROM test; ----- -AndrewX AndrewX AndrewX AndrewX XAndrew XAndrew XAndrew XAndrew -XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng -RaphaelR RaphaelR RaphaelR RaphaelR RRaphael RRaphael RRaphael RRaphael -NULL NULL NULL NULL NULL NULL NULL NULL - -# || constants -# expect all results to be the same for each row as they all have the same values -query TTTTTTTT -SELECT - column1_utf8view || 'foo', - column1_utf8 || 'foo', - column1_large_utf8 || 'foo', - column1_dict || 'foo', - -- reverse argument order - 'foo' || column1_utf8view, - 'foo' || column1_utf8, - 'foo' || column1_large_utf8, - 'foo' || column1_dict -FROM test; ----- -Andrewfoo Andrewfoo Andrewfoo Andrewfoo fooAndrew fooAndrew fooAndrew fooAndrew -Xiangpengfoo Xiangpengfoo Xiangpengfoo Xiangpengfoo fooXiangpeng fooXiangpeng fooXiangpeng fooXiangpeng -Raphaelfoo Raphaelfoo Raphaelfoo Raphaelfoo fooRaphael fooRaphael fooRaphael fooRaphael -NULL NULL NULL NULL NULL NULL NULL NULL - -# || same type (column1 has null, so also tests NULL || NULL) -# expect all results to be the same for each row as they all have the same values -query TTT -SELECT - column1_utf8view || column1_utf8view, - column1_utf8 || column1_utf8, - column1_large_utf8 || column1_large_utf8 - -- Dictionary/Dictionary coercion doesn't work - -- https://github.com/apache/datafusion/issues/12101 - --column1_dict || column1_dict -FROM test; ----- -AndrewAndrew AndrewAndrew AndrewAndrew -XiangpengXiangpeng XiangpengXiangpeng XiangpengXiangpeng -RaphaelRaphael RaphaelRaphael RaphaelRaphael -NULL NULL NULL - -## Ensure no casts for binary operators -## TODO: https://github.com/apache/datafusion/issues/12180 -# `~` operator (regex match) -query TT -EXPLAIN SELECT - column1_utf8view ~ 'an' AS c1 -FROM test; ----- -logical_plan -01)Projection: CAST(test.column1_utf8view AS Utf8) LIKE Utf8("%an%") AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query B -SELECT - column1_utf8view ~ 'an' AS c1 -FROM test; ----- -false -true -false -NULL - -# `~*` operator (regex match case-insensitive) -query TT -EXPLAIN SELECT - column1_utf8view ~* '^a.{3}e' AS c1 -FROM test; ----- -logical_plan -01)Projection: CAST(test.column1_utf8view AS Utf8) ~* Utf8("^a.{3}e") AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query B -SELECT - column1_utf8view ~* '^a.{3}e' AS c1 -FROM test; ----- -true -false -false -NULL - -# `!~~` operator (not like match) -query TT -EXPLAIN SELECT - column1_utf8view !~~ 'xia_g%g' AS c1 -FROM test; ----- -logical_plan -01)Projection: CAST(test.column1_utf8view AS Utf8) !~~ Utf8("xia_g%g") AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query B -SELECT - column1_utf8view !~~ 'xia_g%g' AS c1 -FROM test; ----- -true -true -true -NULL - -# `!~~*` operator (not like match case-insensitive) -query TT -EXPLAIN SELECT - column1_utf8view !~~* 'xia_g%g' AS c1 -FROM test; ----- -logical_plan -01)Projection: CAST(test.column1_utf8view AS Utf8) !~~* Utf8("xia_g%g") AS c1 -02)--TableScan: test projection=[column1_utf8view] - -query B -SELECT - column1_utf8view !~~* 'xia_g%g' AS c1 -FROM test; ----- -true -false -true -NULL - -statement ok -drop table test; - -# coercion from stringview to integer, as input to make_date -query D -select make_date(arrow_cast('2024', 'Utf8View'), arrow_cast('01', 'Utf8View'), arrow_cast('23', 'Utf8View')) ----- -2024-01-23 - -# coercions between stringview and date types -statement ok -create table dates (dt date) as values - (date '2024-01-23'), - (date '2023-11-30'); - -query D -select t.dt from dates t where arrow_cast('2024-01-01', 'Utf8View') < t.dt; ----- -2024-01-23 - -statement ok -drop table dates; - -### Tests for `||` with Utf8View specifically - -statement ok -create table temp as values -('value1', arrow_cast('rust', 'Utf8View'), arrow_cast('fast', 'Utf8View')), -('value2', arrow_cast('datafusion', 'Utf8View'), arrow_cast('cool', 'Utf8View')); - -query TTT -select arrow_typeof(column1), arrow_typeof(column2), arrow_typeof(column3) from temp; ----- -Utf8 Utf8View Utf8View -Utf8 Utf8View Utf8View - -query T -select column2||' is fast' from temp; ----- -rust is fast -datafusion is fast - -query T -select column2 || ' is ' || column3 from temp; ----- -rust is fast -datafusion is cool - -query TT -explain select column2 || 'is' || column3 from temp; ----- -logical_plan -01)Projection: temp.column2 || Utf8View("is") || temp.column3 AS temp.column2 || Utf8("is") || temp.column3 -02)--TableScan: temp projection=[column2, column3] - -# should not cast the column2 to utf8 -query TT -explain select column2||' is fast' from temp; ----- -logical_plan -01)Projection: temp.column2 || Utf8View(" is fast") AS temp.column2 || Utf8(" is fast") -02)--TableScan: temp projection=[column2] - - -query T -select column2||column3 from temp; ----- -rustfast -datafusioncool - -query TT -explain select column2||column3 from temp; ----- -logical_plan -01)Projection: temp.column2 || temp.column3 -02)--TableScan: temp projection=[column2, column3] - -query T -select column2|| ' ' ||column3 from temp; ----- -rust fast -datafusion cool