Skip to content

Commit

Permalink
fix In ScalarFunc in RoughSetFilter (#8634)
Browse files Browse the repository at this point in the history
close #8631
  • Loading branch information
Lloyd-Pottiger committed Jan 2, 2024
1 parent ce42814 commit 6cae6e9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dbms/src/Storages/DeltaMerge/FilterParser/FilterParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ inline RSOperatorPtr parseTiCompareExpr( //
}
values.push_back(value);
}
else
{
// Any other type of child is not supported, like: ScalarFunc.
// case like `cast(a as signed) > 1`, `a in (0, cast(a as signed))` is not supported.
return createUnsupported(
expr.ShortDebugString(),
fmt::format("Unknown child type: {}", tipb::ExprType_Name(child.tp())));
}
}

// At least one ColumnRef and one Literal
Expand All @@ -190,7 +198,7 @@ inline RSOperatorPtr parseTiCompareExpr( //
return createUnsupported(
expr.ShortDebugString(),
fmt::format("Multiple Literal in compare expression is not supported, size: {}", values.size()));
// For In type, the first child must be ColumnRef, nested column like `cast(a as signed)` is not supported.
// For In type, the first child must be ColumnRef
if (column_expr_child_idx != 0 && filter_type == FilterParser::RSFilterType::In)
return createUnsupported(expr.ShortDebugString(), "the first child of In expression must be ColumnRef");

Expand Down
15 changes: 15 additions & 0 deletions tests/fullstack-test/expr/in_expression.test
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,18 @@ mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t w
| 981 |
+------+
mysql> drop table test.t;

mysql> create table test.t (a int, b int);
mysql> insert into test.t values (10,30), (50, 60);
mysql> alter table test.t set tiflash replica 1;
func> wait_table test t

mysql> alter table test.t compact tiflash replica;
mysql> set session tidb_isolation_read_engines='tiflash'; select * from test.t where not a not in (0, cast(+ a as signed));
+------+------+
| a | b |
+------+------+
| 10 | 30 |
| 50 | 60 |
+------+------+
mysql> drop table test.t;

0 comments on commit 6cae6e9

Please sign in to comment.