Skip to content

Conversation

@LantaoJin
Copy link
Member

@LantaoJin LantaoJin commented Mar 9, 2025

Description

  1. Keep aggregation in Calcite consistent with current PPL behavior. Details in [Enhancement] Keep aggregation results in Calcite consistent with current PPL behavior #3403
  2. Return null if all records are null with group-by. see [BUG] SUM and AVG should return NULL if all the records are NULL #3404
  3. Add ppl rename command with Calcite.

All unit tests in ppl/src/test/java/org/opensearch/sql/ppl/calcite succeed in local
./gradlew :integ-test:integTest --tests '*Calcite*IT' passed in local

Related Issues

Resolves #3403, #3404

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
} else if (node.getKind() == SqlKind.AS) {
return Optional.of((RexLiteral) ((RexCall) node).getOperands().get(1));
} else if (node instanceof RexCall call) {
return call.getOperands().stream()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will we go into this branch? Seems we always pass an alias RexCall here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For by clause in PPL stats command, RexCall branch is useless. But I prefer to add this branch as a general method in ExtendedRexBuilder.

}

/** TODO sort with aliased list will not work, so we add this converting */
private List<RexNode> removeAliasForSort(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about change function name to analyzeAliasForSort? It seems not a process of removing but analyzing or column resolving.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: Lantao Jin <ltjin@amazon.com>
@LantaoJin LantaoJin merged commit 9ff34e2 into opensearch-project:feature/calcite-engine Mar 11, 2025
5 of 13 checks passed
penghuo pushed a commit to penghuo/os-sql that referenced this pull request Mar 12, 2025
…nsearch-project#3405)

* Keep aggregation in Calcite consistent with current PPL behavior

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* remove unrelated code

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* revert some code

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* fix issue 3404

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* add more tests

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* address comments

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* add more tests

Signed-off-by: Lantao Jin <ltjin@amazon.com>

---------

Signed-off-by: Lantao Jin <ltjin@amazon.com>
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* Keep aggregation in Calcite consistent with current PPL behavior

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* remove unrelated code

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* revert some code

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* fix issue 3404

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* add more tests

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* address comments

Signed-off-by: Lantao Jin <ltjin@amazon.com>

* add more tests

Signed-off-by: Lantao Jin <ltjin@amazon.com>

---------

Signed-off-by: Lantao Jin <ltjin@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calcite calcite migration releated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants