Skip to content

Conversation

@ykmr1224
Copy link
Collaborator

@ykmr1224 ykmr1224 commented Nov 5, 2025

This PR is for feature branch feature/permissive

Description

  • Support aggregation/window commands with dynamic fields
    • stats, eventstats, timechart, trendline
  • DebugUtils/JsonUtils are just utility class mainly for tests and debugging.

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 calcite calcite migration releated labels Nov 5, 2025
@ykmr1224 ykmr1224 marked this pull request as ready for review November 5, 2025 16:52
@ykmr1224 ykmr1224 self-assigned this Nov 5, 2025
@ykmr1224 ykmr1224 added the enhancement New feature or request label Nov 5, 2025
@ykmr1224 ykmr1224 force-pushed the dynamic-aggregation branch 2 times, most recently from 33bab3f to 6b2e491 Compare November 7, 2025 00:27
@ykmr1224
Copy link
Collaborator Author

ykmr1224 commented Nov 7, 2025

Updated to utilize type coercion.

Comment on lines 2099 to 2103
if (!context.fieldBuilder.isFieldSpecificType(byFieldName)) {
throw new IllegalArgumentException(
String.format(
"By field `%s` needs to be specific type. Please cast explicitly.", byFieldName));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we cast to string for groupBy field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realized timechart requires bigger change due to type assigned to span function, which prevents automatic type coercion work properly.
Let me address this in a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Found simpler way to solve the problem, and included the change in this PR.

@ykmr1224 ykmr1224 force-pushed the dynamic-aggregation branch from 44e2d10 to 0e2d036 Compare November 12, 2025 00:10
Comment on lines 101 to 112
} else if (SqlTypeUtil.isCharacter(fieldType)) {
// if first argument is string, consider it as timestamp
ScalarFunctionImpl function =
(ScalarFunctionImpl)
ScalarFunctionImpl.create(
Types.lookupMethod(
SpanFunction.class,
"evalTimestamp",
String.class,
int.class,
String.class));
return function.getImplementor().implement(translator, call, RexImpTable.NullAs.NULL);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could u explain it more on this, "// if first argument is string, consider it as timestamp"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

Comment on lines +2052 to +2054
projectDynamicFieldAsString(node.getBinExpression(), context);
projectDynamicFieldAsString(node.getByField(), context);

Copy link
Collaborator

Choose a reason for hiding this comment

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

is it required for all visitor?

Copy link
Collaborator

Choose a reason for hiding this comment

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

could u add a test in CalciteDynamicFieldsTimechartIT to help understand what is correspond logical plan / sql

Copy link
Collaborator Author

@ykmr1224 ykmr1224 Nov 14, 2025

Choose a reason for hiding this comment

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

Added CalcitePPLDynamicFieldsTest.java‎ for spark SQL. Added explains in IT.

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]>
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]>
@ykmr1224 ykmr1224 force-pushed the dynamic-aggregation branch from d6acee2 to d552010 Compare November 15, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calcite calcite migration releated enhancement New feature or request PPL Piped processing language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants