Skip to content

feat(core,isthmus): add DynamicParameter expression support#752

Open
bvolpato wants to merge 1 commit intosubstrait-io:mainfrom
bvolpato:bv/dynamic-parameter-support
Open

feat(core,isthmus): add DynamicParameter expression support#752
bvolpato wants to merge 1 commit intosubstrait-io:mainfrom
bvolpato:bv/dynamic-parameter-support

Conversation

@bvolpato
Copy link
Member

Summary

Add full support for Substrait DynamicParameter expressions, enabling parameterized placeholders (analogous to JDBC ? bind parameters) in plan bodies instead of embedded literals. This maps bidirectionally to Calcite's RexDynamicParam.

DynamicParameter enables plan reuse — the same plan structure can be compiled and cached once, then executed with different parameter values without re-planning. This is essential for prepared statement workflows and for exchanging plans between engines without leaking literal values.

Changes

Core POJO + Proto layer:

  • Expression.DynamicParameter — immutable POJO with type and parameterReference fields
  • ExpressionVisitor / AbstractExpressionVisitor — new visit(DynamicParameter) method
  • ExpressionProtoConverter — POJO→Proto conversion
  • ProtoExpressionConverter — Proto→POJO conversion (DYNAMIC_PARAMETER case)
  • ExpressionCopyOnWriteVisitor — leaf-node handling (returns Optional.empty())

Calcite integration (isthmus):

  • RexExpressionConverter.visitDynamicParam() — replaces UnsupportedOperationException with actual Calcite→Substrait conversion
  • ExpressionRexConverter.visit(DynamicParameter) — Substrait→Calcite conversion

Debug support:

  • ExpressionStringify — added DynamicParameter stringification

Testing

20 tests total, all passing:

  • 8 core proto roundtrip tests (DynamicParameterRoundtripTest in core) — POJO↔Proto↔POJO for I64, nullable STRING, FP64, I32, DATE, BOOLEAN, DECIMAL, TIMESTAMP
  • 5 isthmus unit tests (DynamicParameterTest) — direct Calcite↔Substrait conversions and project roundtrips
  • 7 isthmus end-to-end roundtrip tests (DynamicParameterRoundtripTest in isthmus) — filter/projection/multi-type POJO roundtrips, Calcite-originated RexDynamicParam roundtrips, and full Substrait→Calcite→Substrait bidirectional roundtrips

All existing tests in core and isthmus continue to pass with zero regressions. PMD and Spotless checks are clean.

Implement full support for Substrait DynamicParameter expressions,
enabling parameterized placeholders in plan bodies instead of
embedded literals. This maps bidirectionally to Calcite's
RexDynamicParam (JDBC ? bind parameters).

Changes:
- Add Expression.DynamicParameter POJO with type and parameterReference
- Wire visitor pattern across all expression visitors
- Add proto conversion (POJO<->Proto) in both directions
- Add Calcite conversion (RexDynamicParam<->DynamicParameter)
- Replace UnsupportedOperationException in visitDynamicParam
- Add debug stringification in ExpressionStringify
- Add 20 tests covering proto roundtrips, Calcite conversions,
  and full end-to-end roundtrips
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.

1 participant