Skip to content

Commit

Permalink
fix concat dictionary(int32, utf8) bug (#12143)
Browse files Browse the repository at this point in the history
* fix concat bug

* clippy fix
  • Loading branch information
thinh2 authored Aug 24, 2024
1 parent e4c3d64 commit a58416c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datafusion/expr-common/src/type_coercion/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,9 @@ fn string_concat_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<Da
(LargeUtf8, from_type) | (from_type, LargeUtf8) => {
string_concat_internal_coercion(from_type, &LargeUtf8)
}
(Dictionary(_, lhs_value_type), Dictionary(_, rhs_value_type)) => {
string_coercion(lhs_value_type, rhs_value_type).or(None)
}
_ => None,
})
}
Expand Down
29 changes: 29 additions & 0 deletions datafusion/sqllogictest/test_files/type_coercion.slt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ select interval '1 month' - '2023-05-01'::date;
query error DataFusion error: Error during planning: Cannot coerce arithmetic expression Interval\(MonthDayNano\) \- Timestamp\(Nanosecond, None\) to valid types
SELECT interval '1 month' - '2023-05-01 12:30:00'::timestamp;

# dictionary(int32, utf8) -> utf8
query T
select arrow_cast('foo', 'Dictionary(Int32, Utf8)') || arrow_cast('bar', 'Dictionary(Int32, Utf8)');
----
foobar

# dictionary(int32, largeUtf8) -> largeUtf8
query T
select arrow_cast('foo', 'Dictionary(Int32, LargeUtf8)') || arrow_cast('bar', 'Dictionary(Int32, LargeUtf8)');
----
foobar

####################################
## Concat column dictionary test ##
####################################
statement ok
create table t as values (arrow_cast('foo', 'Dictionary(Int32, Utf8)'), arrow_cast('bar', 'Dictionary(Int32, Utf8)'));

query T
select column1 || column2 from t;
----
foobar

statement ok
DROP TABLE t

#######################################
## Concat column dictionary test end ##
#######################################

####################################
## Test type coercion with UNIONs ##
Expand Down

0 comments on commit a58416c

Please sign in to comment.