|
| 1 | +drop table if exists test_vector; |
| 2 | +create external table test_vector(id string, pid bigint) PARTITIONED BY (full_date int); |
| 3 | +insert into test_vector (pid, full_date, id) values (1, '20240305', '6150'); |
| 4 | + |
| 5 | +-------------------------------------------------------------------------------- |
| 6 | +-- 1. Basic COUNT cases (valid in vectorization) |
| 7 | +-------------------------------------------------------------------------------- |
| 8 | +SELECT COUNT(pid) AS cnt_col, COUNT(*) AS cnt_star, COUNT(20240305) AS cnt_const, COUNT(DISTINCT pid) as cnt_distinct, COUNT(1) AS CNT |
| 9 | +FROM test_vector WHERE full_date=20240305; |
| 10 | +EXPLAIN VECTORIZATION EXPRESSION |
| 11 | +SELECT COUNT(pid) AS cnt_col, COUNT(*) AS cnt_star, COUNT(20240305) AS cnt_const,COUNT(DISTINCT pid) as cnt_distinct, COUNT(1) AS CNT |
| 12 | +FROM test_vector WHERE full_date=20240305; |
| 13 | + |
| 14 | +-------------------------------------------------------------------------------- |
| 15 | +-- 2. COUNT with DISTINCT column + constant (INVALID in vectorization) |
| 16 | +-------------------------------------------------------------------------------- |
| 17 | +SELECT COUNT(DISTINCT pid, 20240305) AS CNT FROM test_vector WHERE full_date=20240305; |
| 18 | +EXPLAIN VECTORIZATION EXPRESSION |
| 19 | +SELECT COUNT(DISTINCT pid, 20240305) AS CNT FROM test_vector WHERE full_date=20240305; |
| 20 | + |
| 21 | +-------------------------------------------------------------------------------- |
| 22 | +-- 3. COUNT(DISTINCT pid, full_date) (multi-col distinct → FAIL) |
| 23 | +-------------------------------------------------------------------------------- |
| 24 | +SELECT COUNT(DISTINCT pid, full_date) AS CNT FROM test_vector WHERE full_date=20240305; |
| 25 | +EXPLAIN VECTORIZATION EXPRESSION |
| 26 | +SELECT COUNT(DISTINCT pid, full_date) AS CNT FROM test_vector WHERE full_date=20240305; |
| 27 | + |
| 28 | +-------------------------------------------------------------------------------- |
| 29 | +-- 4. COUNT(DISTINCT pid, full_date, id) (multi-col distinct → FAIL) |
| 30 | +-------------------------------------------------------------------------------- |
| 31 | +SELECT COUNT(DISTINCT pid, full_date, id) AS CNT FROM test_vector WHERE full_date=20240305; |
| 32 | +EXPLAIN VECTORIZATION EXPRESSION |
| 33 | +SELECT COUNT(DISTINCT pid, full_date, id) AS CNT FROM test_vector WHERE full_date=20240305; |
| 34 | + |
| 35 | +DROP TABLE test_vector; |
0 commit comments