Skip to content

Commit

Permalink
fix(query): fix create table with cluster by get map type panic (#15475)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored May 11, 2024
1 parent 51f592b commit 5698d16
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/query/sql/src/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3816,22 +3816,24 @@ impl<'a> TypeChecker<'a> {
// If it is a tuple column, convert it to the internal column specified by the paths.
// For other types of columns, convert it to get functions.
if let ScalarExpr::BoundColumnRef(BoundColumnRef { ref column, .. }) = scalar {
let column_entry = self.metadata.read().column(column.index).clone();
if let ColumnEntry::BaseTableColumn(BaseTableColumn { ref data_type, .. }) =
column_entry
{
// Use data type from meta to get the field names of tuple type.
table_data_type = data_type.clone();
if let TableDataType::Tuple { .. } = table_data_type.remove_nullable() {
let box (inner_scalar, _inner_data_type) = self
.resolve_tuple_map_access_pushdown(
expr.span(),
column.clone(),
&mut table_data_type,
&mut paths,
)
.await?;
scalar = inner_scalar;
if column.index < self.metadata.read().columns().len() {
let column_entry = self.metadata.read().column(column.index).clone();
if let ColumnEntry::BaseTableColumn(BaseTableColumn { ref data_type, .. }) =
column_entry
{
// Use data type from meta to get the field names of tuple type.
table_data_type = data_type.clone();
if let TableDataType::Tuple { .. } = table_data_type.remove_nullable() {
let box (inner_scalar, _inner_data_type) = self
.resolve_tuple_map_access_pushdown(
expr.span(),
column.clone(),
&mut table_data_type,
&mut paths,
)
.await?;
scalar = inner_scalar;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ CREATE TABLE t(id Int null, arr VARIANT null) cluster by(json_path_query(arr, '$
statement error 1081
CREATE TABLE t(a string null, b tuple(int, int)) cluster by(a,b)

statement ok
CREATE TABLE t(id int, tags map(string, variant)) cluster by (id, substr(md5(tags['uri']), 1, 4));

statement ok
DROP DATABASE db1

Expand Down

0 comments on commit 5698d16

Please sign in to comment.