Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
# specific language governing permissions and limitations
# under the License.

# --------------------------------------
# Test `substr()` with literal arguments
# --------------------------------------
include ./substr_literal.slt.part
statement ok
create table test_source as values
('Andrew', 'X', 'datafusion📊🔥', '🔥'),
('Xiangpeng', 'Xiangpeng', 'datafusion数据融合', 'datafusion数据融合'),
('Raphael', 'R', 'datafusionДатаФусион', 'аФус'),
(NULL, 'R', NULL, '🔥');
Comment on lines +19 to +23
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we started to implement some ASCII-faster paths, I think we should always consider testing both ASCII-only and Unicode cases.


# --------------------------------------
# Setup test tables with different physical string types (Utf8/Utf8View/LargeUtf8)
Expand All @@ -29,44 +31,3 @@ create table test_substr_base (
col1 VARCHAR
) as values ('foo'), ('hello🌏世界'), ('💩'), ('ThisIsAVeryLongASCIIString'), (''), (NULL);

#
# Run1: Utf8
#
statement ok
create table test_substr as
select arrow_cast(col1, 'Utf8') as c1 from test_substr_base;

include ./substr_table.slt.part

statement ok
drop table test_substr;

#
# Run2: Utf8View
#
statement ok
create table test_substr as
select arrow_cast(col1, 'Utf8View') as c1 from test_substr_base;

include ./substr_table.slt.part

statement ok
drop table test_substr;

#
# Run3: LargeUtf8
#
statement ok
create table test_substr as
select arrow_cast(col1, 'LargeUtf8') as c1 from test_substr_base;

include ./substr_table.slt.part

statement ok
drop table test_substr;

# --------------------------------------
# Cleanup
# --------------------------------------
statement ok
drop table test_substr_base;
50 changes: 50 additions & 0 deletions datafusion/sqllogictest/test_files/string/large_string.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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.

include ./init_data.slt.part

# --------------------------------------
# Setup test tables with different physical string types
# and repeat tests in `string_query.slt.part`
# --------------------------------------
statement ok
create table test_basic_operator as
select
arrow_cast(column1, 'LargeUtf8') as ascii_1,
arrow_cast(column2, 'LargeUtf8') as ascii_2,
arrow_cast(column3, 'LargeUtf8') as unicode_1,
arrow_cast(column4, 'LargeUtf8') as unicode_2
from test_source;

statement ok
create table test_substr as
select arrow_cast(col1, 'LargeUtf8') as c1 from test_substr_base;

#
# common test for string-like functions and operators
#
include ./string_query.slt.part

#
# Clean up
#

statement ok
drop table test_basic_operator;

statement ok
drop table test_substr_base;
50 changes: 50 additions & 0 deletions datafusion/sqllogictest/test_files/string/string.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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.

include ./init_data.slt.part

# --------------------------------------
# Setup test tables with different physical string types
# and repeat tests in `string_query.slt.part`
# --------------------------------------
statement ok
create table test_basic_operator as
select
arrow_cast(column1, 'Utf8') as ascii_1,
arrow_cast(column2, 'Utf8') as ascii_2,
arrow_cast(column3, 'Utf8') as unicode_1,
arrow_cast(column4, 'Utf8') as unicode_2
from test_source;

statement ok
create table test_substr as
select arrow_cast(col1, 'Utf8') as c1 from test_substr_base;

#
# common test for string-like functions and operators
#
include ./string_query.slt.part

#
# Clean up
#

statement ok
drop table test_basic_operator;

statement ok
drop table test_substr;
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ SELECT substr('alphabet', 3, 20)
phabet

query TT
select
substr(arrow_cast('alphabet', 'LargeUtf8'), 3, 20),
select
substr(arrow_cast('alphabet', 'LargeUtf8'), 3, 20),
substr(arrow_cast('alphabet', 'Utf8View'), 3, 20);
----
phabet phabet
Expand Down Expand Up @@ -99,7 +99,7 @@ SELECT

# Nulls
query TTTTTTTTTT
SELECT
SELECT
substr('alphabet', NULL),
substr(NULL, 1),
substr(NULL, NULL),
Expand Down Expand Up @@ -134,3 +134,14 @@ select substr(arrow_cast('foo', 'Utf8View'), 1, -1);

statement error Execution error: negative substring length not allowed
select substr('', 1, -1);

# StringView scalar to StringView scalar

query BBBB
select
arrow_cast('NULL', 'Utf8View') = arrow_cast('Andrew', 'Utf8View'),
arrow_cast('NULL', 'Utf8View') <> arrow_cast('Andrew', 'Utf8View'),
arrow_cast('Andrew', 'Utf8View') = arrow_cast('Andrew', 'Utf8View'),
arrow_cast('Xiangpeng', 'Utf8View') <> arrow_cast('Andrew', 'Utf8View');
----
false true true true
Loading