risinglight icon indicating copy to clipboard operation
risinglight copied to clipboard

executor: support `select count(1) from table`

Open skyzh opened this issue 2 years ago • 2 comments

related discussion: https://github.com/risinglightdb/risinglight/discussions/503

> select count(1) from t1;
thread 'tokio-runtime-worker' panicked at 'no column to iterate', src/storage/secondary/rowset/rowset_iterator.rs:40:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We definitely need to consider row_handler as a normal column in optimizer, so as to support this case...

skyzh avatar Feb 21 '22 09:02 skyzh

What is the expected result for count(1)? and the difference compared with count(*)?

xiaoyong-z avatar Mar 10 '22 15:03 xiaoyong-z

Should be the same as count(*) in the current framework. Only in edge cases will it be different from count(*) (after we have sub-query)

skyzh avatar Mar 10 '22 15:03 skyzh

Seems that it is supported while select count(*) from table is not supported, or are there any misoperations?

> select count(1) from pg_catalog.contributors;
+-------+
| count |
+-------+
| 30    |
+-------+
in 0.005s
> select count(*) from pg_catalog.contributors;
thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 0 but the index is 0', src/optimizer/plan_nodes/internal.rs:67:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'failed to join query thread: JoinError::Panic(Id(30), ...)', src/main.rs:126:23
`

unconsolable avatar Oct 15 '22 10:10 unconsolable

That's probably a bug. Count star is hard 😇

skyzh avatar Oct 15 '22 16:10 skyzh

This issue will be fixed by #728 in the new planner.

wangrunji0408 avatar Nov 09 '22 10:11 wangrunji0408