Skip to content

Commit

Permalink
[BugFix] fix unique table skip short circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-ju committed Mar 15, 2024
1 parent 2f3a2cc commit 77895ea
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public LogicalPlanChecker(boolean allowFilter, boolean allowLimit, boolean allow
public Boolean visitLogicalTableScan(OptExpression optExpression, Void context) {
LogicalScanOperator scanOp = optExpression.getOp().cast();
Table table = scanOp.getTable();
if (!(table instanceof OlapTable) && !(((OlapTable) table).getKeysType().equals(KeysType.PRIMARY_KEYS))) {
if (!(table instanceof OlapTable) || !(KeysType.PRIMARY_KEYS.equals(((OlapTable) table).getKeysType()))) {
return false;
}

Expand Down
17 changes: 17 additions & 0 deletions test/sql/test_spill/R/test_short_circuit_unique
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- name: test_short_circuit_unique
create table unique_tbl(a int, b string)
unique key(a)
distributed by hash(a)
PROPERTIES('replication_num' = '1');
-- result:
-- !result
insert into unique_tbl values(1,'hi'),(2,'hello');
-- result:
-- !result
set global enable_short_circuit = true;
-- result:
-- !result
select * from unique_tbl where a=1;
-- result:
1 hi
-- !result
10 changes: 10 additions & 0 deletions test/sql/test_spill/T/test_short_circuit_unique
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- name: test_short_circuit_unique
--
-- for issue: https://github.com/StarRocks/starrocks/issues/23491
create table unique_tbl(a int, b string)
unique key(a)
distributed by hash(a)
PROPERTIES('replication_num' = '1');
insert into unique_tbl values(1,'hi'),(2,'hello');
set global enable_short_circuit = true;
select * from unique_tbl where a=1;

0 comments on commit 77895ea

Please sign in to comment.