-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Description
Describe the bug
When using select condition like -1=-1 may cause errCode = 2, detailMessage = Unexpected exception: null.
This is due toSelectNode.cardinality computing error.
This cardinality may be less than 0.
To Reproduce
Steps to reproduce the behavior:
- Create a table
CREATE TABLE `table1` (
`city_id` bigint(20) NULL,
`tag_id` bigint(20) NULL,
`dt` bigint(20) NULL,
`num` bigint(20) NULL
) ENGINE=OLAP
DUPLICATE KEY(`city_id`, `tag_id`, `dt`)
COMMENT "OLAP"
PARTITION BY RANGE(`dt`)
(PARTITION p20200102 VALUES [("20200101"), ("20200102")),
PARTITION p20200103 VALUES [("20200102"), ("20200103")))
DISTRIBUTED BY HASH(`city_id`) BUCKETS 5
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);- Insert some data
INSERT INTO table1 VALUES (1, 2, 20200102, 3);You may need to wait for the cardinality to be > 0 (I still dont know how the cardinality works).
- Launch a query
SELECT rank, tag_id
FROM (
SELECT row_number() OVER (ORDER BY num DESC) AS rank, tag_id
FROM table1
) t
WHERE -1=-1 or tag_id in (-1)
LIMIT 10
;When the table is not empty (maybe cardinality means row number?), cardinality will be > 0, computeSelectivity() < 0, then the error occur.
I tried to remove some elements and this is the minimum sql to reproduce the bug.
Could someone explain what doe cardinality and selectivity means?
Is Preconditions.checkState(cardinality >= 0); necessary?
ppyaxinppyaxin
Metadata
Metadata
Assignees
Labels
No labels