Skip to content

fix: optimize count over non-null constants#155

Open
LuciferYang wants to merge 1 commit into
lance-format:mainfrom
LuciferYang:fix/142-count-constant-pushdown
Open

fix: optimize count over non-null constants#155
LuciferYang wants to merge 1 commit into
lance-format:mainfrom
LuciferYang:fix/142-count-constant-pushdown

Conversation

@LuciferYang

Copy link
Copy Markdown
Contributor

Summary

  • Treat COUNT(non-null constant) as a row-count aggregate so it can use the existing manifest-backed count fast path.
  • Keep filtered, distinct, NULL, column, sorted, grouped, and multi-aggregate cases on the normal path.
  • Add metadata and connector tests for the new pushdown and its boundary cases.

Fixes #142

Verification

  • git diff --check
  • JAVA_HOME=/Users/yangjie01/Tools/zulu25 ./mvnw test -pl plugin/trino-lance -Dtest=TestLanceMetadata#testCountNonNullConstantAggregationPushdown+testCountNullConstantAggregationNotPushedDown+testFilteredCountConstantAggregationNotPushedDown+testCountConstantAggregationWithTableFilterNotPushedDown+testDistinctCountConstantAggregationNotPushedDown+testCountColumnAggregationNotPushedDown+testSortedCountConstantAggregationNotPushedDown,TestLanceConnectorTest#testCountNonNullConstantPushdown -Dair.check.skip-enforcer=true -Dsurefire.forkCount=1

@LuciferYang

Copy link
Copy Markdown
Contributor Author

I'll resolve these conflicting PRs when I get back next week.

Treat COUNT(non-null constant) as a row-count aggregate so it can use the existing manifest-backed fast path. Keep filtered, distinct, NULL, column, sorted, and grouped aggregates out of this optimization.

Fixes lance-format#142
@LuciferYang LuciferYang force-pushed the fix/142-count-constant-pushdown branch from cc67553 to 6c1c232 Compare June 17, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slow execution of count queries

1 participant