Skip to content

Commit a3c239b

Browse files
committed
make query work
1 parent f4e519f commit a3c239b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

datafusion/expr/src/type_coercion/binary.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ fn dictionary_coercion(
890890
/// 2. Data type of the other side should be able to cast to string type
891891
fn string_concat_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
892892
use arrow::datatypes::DataType::*;
893-
string_coercion(lhs_type, rhs_type).or(match (lhs_type, rhs_type) {
893+
string_coercion_duplicate(lhs_type, rhs_type).or(match (lhs_type, rhs_type) {
894894
(Utf8, from_type) | (from_type, Utf8) => {
895895
string_concat_internal_coercion(from_type, &Utf8)
896896
}
@@ -939,6 +939,20 @@ fn string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>
939939
}
940940
}
941941

942+
fn string_coercion_duplicate(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
943+
use arrow::datatypes::DataType::*;
944+
match (lhs_type, rhs_type) {
945+
// If Utf8View is in any side, we coerce to Utf8.
946+
(Utf8View, Utf8View | Utf8 | LargeUtf8) | (Utf8 | LargeUtf8, Utf8View) => {
947+
Some(Utf8)
948+
}
949+
// Then, if LargeUtf8 is in any side, we coerce to LargeUtf8.
950+
(LargeUtf8, Utf8 | LargeUtf8) | (Utf8, LargeUtf8) => Some(LargeUtf8),
951+
(Utf8, Utf8) => Some(Utf8),
952+
_ => None,
953+
}
954+
}
955+
942956
fn numeric_string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
943957
use arrow::datatypes::DataType::*;
944958
match (lhs_type, rhs_type) {

datafusion/sqllogictest/test_files/string_view.slt

+9
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,12 @@ select t.dt from dates t where arrow_cast('2024-01-01', 'Utf8View') < t.dt;
379379

380380
statement ok
381381
drop table dates;
382+
383+
statement ok
384+
create table temp as values ('value1', arrow_cast('one', 'Utf8View')), ('value1', arrow_cast('two', 'Utf8View'));
385+
386+
query T
387+
select column2||'ff' from temp;
388+
----
389+
oneff
390+
twoff

0 commit comments

Comments
 (0)