Skip to content

[BUG] Agg pushdown not work with two equivalent count(FIELD) #4347

@LantaoJin

Description

@LantaoJin

What is the bug?

source=accounts 
| eval account_number_alias = account_number 
| stats count(account_number), count(account_number_alias) as c2 by gender

Explain

{
  "calcite": {
    "logical": """LogicalSystemLimit(fetch=[10000], type=[QUERY_SIZE_LIMIT])
  LogicalProject(count(account_number)=[$1], c2=[$2], gender=[$0])
    LogicalAggregate(group=[{0}], count(account_number)=[COUNT($1)], c2=[COUNT($2)])
      LogicalProject(gender=[$4], account_number=[$0], account_number_alias=[$0])
        CalciteLogicalIndexScan(table=[[OpenSearch, accounts]])
""",
    "physical": """EnumerableLimit(fetch=[10000])
  EnumerableCalc(expr#0..2=[{inputs}], count(account_number)=[$t1], c2=[$t2], gender=[$t0])
    EnumerableAggregate(group=[{0}], count(account_number)=[COUNT($1)], c2=[COUNT($1)])
      CalciteEnumerableIndexScan(table=[[OpenSearch, accounts]], PushDownContext=[[PROJECT->[gender, account_number]], OpenSearchRequestBuilder(sourceBuilder={"from":0,"timeout":"1m","_source":{"includes":["gender","account_number"],"excludes":[]}}, requestedTotalSize=2147483647, pageSize=null, startFrom=0)])
"""
  }
}

What is the expected behavior?
Two count aggregations should be pushed down.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpushdownpushdown related issues

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions