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

#3026 PPL - fieldsummary command #3320

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kenrickyap
Copy link
Contributor

Description

Implement fieldsummary command. Similar to spark implementation https://github.com/opensearch-project/opensearch-spark/pull/766/files#diff-e70358b83b0ba411a94e8e338f5542f44d184d5dbc49baa08ba41391d8f8ad7d

Related Issues

Resolves #3026

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: Kenrick Yap <[email protected]>
Copy link
Collaborator

@acarbonetto acarbonetto left a comment

Choose a reason for hiding this comment

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

needs w

List<String> includeFields =
node.getIncludeFields().stream()
.map(expr -> ((Field) expr).getField().toString())
.toList();
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can do your filter and collect to map in your stream, and then return a map.

Map<String, ExprType> fieldsMap = env.lookupAllFields(Namespace.FIELD_NAME);

if (node.getIncludeFields() != null) {
List<String> includeFields =
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider: for each key in fieldsMap, check to see if it's in includedFields, and if not, remove it from the map.

context.push();
TypeEnvironment newEnv = context.peek();

newEnv.define(new Symbol(Namespace.FIELD_NAME, "Field"), ExprCoreType.STRING);
Copy link
Collaborator

Choose a reason for hiding this comment

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

consider encapsulating all the types and lists for FieldSummary within a class, like a FieldSummaryAggregationExpression. Then you can define enums for each column, and builders for the analyzer and parser.

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.

[FEATURE]New fieldsummary PPL command
2 participants