Skip to content

[FEATURE] Push down project operator into scan after aggregation push down #4230

Closed

Description

@qianheng-aws

Is your feature request related to a problem?
In current code, for PPL with stats command, there is always a project operator upon the scan operator after optimization, because we don't support pushing down project operator after aggregation as putting the fields in _source is no longer appropriate for aggregations DSL.

On the other hand, this project is needed as it adjusts the order of columns output from aggregation. In PPL, we expect the schema starts with aggregate value from aggregation while Calcite starts with group by columns.

PPL: 
source=opensearch-sql_test_index_bank | stats count() by span(birthdate,1M)

FINAL PLAN:
EnumerableCalc(expr#0..1=[{inputs}], count()=[$t1], span(birthdate,1M)=[$t0])
  CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_bank]], PushDownContext=[[AGGREGATION->...

What solution would you like?
Implement this by updating the row type of scan operator.

What alternatives have you considered?

Do you have any additional context?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLcalciteenhancementpushdownv3.3.0

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions