Skip to content

Conversation

@ykmr1224
Copy link
Collaborator

@ykmr1224 ykmr1224 commented Nov 19, 2025

This PR is for feature branch feature/permissive

Description

  • Support spath command to extract all fields when output and path are not specified
    • It will parse input field as JSON and extract all the paths into fields.
    • If same field name already exists, it will append the result to existing value (the value becomes an array).
    • Non-existing fields will be added to _MAP(dynamic fields) as we cannot know the contents at planning time.
    • Static fields will become ANY type because append could happen depending on the JSON content.
  • Introduced internal function APPEND to keep existing field scalar, and make single item result scalar
    • Originally, planning to use MVAPPEND which returns array even for single value result, but realized it makes other commands require conversion from array to scalar. I considered automatic type coercion from array to scalar, but it does not align with Splunk behavior where multivalue with single item would be automatically converted as scalar value.

Related Issues

Permissive mode RFC: #4349
Dynamic fields RFC: #4433

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • 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.

@ykmr1224 ykmr1224 added PPL Piped processing language feature calcite calcite migration releated labels Nov 19, 2025
@ykmr1224 ykmr1224 changed the title Support spath command without output parameter Support spath command to extract all fields Nov 19, 2025
@ykmr1224 ykmr1224 force-pushed the dynamic-spath-append branch 3 times, most recently from 09ff0ca to 425da58 Compare November 19, 2025 18:04
Signed-off-by: Tomoyuki Morita <[email protected]>
Signed-off-by: Tomoyuki Morita <[email protected]>
Signed-off-by: Tomoyuki Morita <[email protected]>
Signed-off-by: Tomoyuki Morita <[email protected]>
}

@Test
@Ignore("Join does not work now")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pending this PR: #4746

// 2. Merge dynamic fields with static fields.
// static_field1 = APPEND(static_field1, _MAP[static_field1]), static_attr2 = ...
List<String> staticFieldNames = context.fieldBuilder.getStaticFieldNames();
List<RexNode> fields = new ArrayList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I mentioned in standup this morning that I think we're making this more complex by working directly on the List of fields.

I'd like to consider putting the bulk of this logic in a data class that can start supplying a higher-level interface for most field operations. Can incrementally move more commands to use it over time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one is very special logic for spath to append values to static fields and remove appended ones from dynamic fields. I don't think it is something reusable for other use case, and should be coded in spath implementation rather than abstraction layer.
spath command is special since it generate new dynamic fields while others only consume.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If spath command is special enough for this, I imagine other commands would have their own special cases later. It would still be worth finding an abstraction here in my view. To me it seems like this is one of the main operations of adding dynamic fields to that structure & would eventually be reusable as more dynamic commands are visited.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Expected commands which would add dynamic fields are: multikv and timechart (There are some more with lower priorities: chart, extract, kv, xpath, xmlkv, transpose, xyseries, pivot)

multikv would simply overwrite existing fields.
timechart would also overwrite existing fields (it is a bit different since it would rather make new frame rather than updating existing frame)

There might be a chance we could reuse current logic in the future, but I think we should generalize when we implement that. I don't have very good idea to generalize some part right now. Let me know if you already have clear picture which part should be generalized.

* of the list. See {@ref MVAppendFunctionImplTest} for detailed behavior.
* of the list. See {@ref AppendFunctionImplTest} for detailed behavior.
*/
public static Object collectElements(Object... args) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought: Can we make this typing any more specific than Object?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We cannot since input/output could be any type.

Signed-off-by: Tomoyuki Morita <[email protected]>
@opensearch-trigger-bot
Copy link
Contributor

This PR is stalled because it has been open for 2 weeks with no activity.

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

Labels

calcite calcite migration releated feature PPL Piped processing language stalled

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants