Skip to content

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 <Kenrick.Yap@improving.com>
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.

Signed-off-by: Kenrick Yap <Kenrick.Yap@improving.com>
Signed-off-by: Kenrick Yap <Kenrick.Yap@improving.com>
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