Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: do not bind column for count(*) in binder #388

Closed
skyzh opened this issue Jan 31, 2022 · 1 comment
Closed

expression: do not bind column for count(*) in binder #388

skyzh opened this issue Jan 31, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@skyzh
Copy link
Member

skyzh commented Jan 31, 2022

if args.is_empty() {
for ref_id in self.context.regular_tables.values() {
let table = self.catalog.get_table(ref_id).unwrap();
if let Some(col) = table.get_column_by_id(0) {
let column_ref_id = ColumnRefId::from_table(*ref_id, col.id());
self.record_regular_table_column(
&table.name(),
col.name(),
col.id(),
col.desc().clone(),
);
let expr = BoundExpr::ColumnRef(BoundColumnRef {
table_name: table.name(),
column_ref_id,
is_primary_key: col.is_primary(),
desc: col.desc().clone(),
});
args.push(expr);
break;

Currently, we always select the 0th column in binder for count(*). This has caused problems like #200. In the future, we should be able to do both of the following:

  • bind all columns in binder, and do column prune in optimizer
  • rewrite count(*) to using statistics information (only for queries like select count(*) from table)
@skyzh skyzh added the enhancement New feature or request label Feb 3, 2022
@likg227
Copy link
Contributor

likg227 commented Feb 3, 2022

I will solve this problem after @st1page finishes his work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants