Skip to content

feat(pojo): support ExecutionContextVariable (#802)#867

Open
nielspardon wants to merge 1 commit into
substrait-io:mainfrom
nielspardon:feat/execution-context-variable
Open

feat(pojo): support ExecutionContextVariable (#802)#867
nielspardon wants to merge 1 commit into
substrait-io:mainfrom
nielspardon:feat/execution-context-variable

Conversation

@nielspardon

Copy link
Copy Markdown
Member

Summary

Adds support for the Expression.ExecutionContextVariable message introduced in Substrait v0.87.0, modeling the three execution-context-dependent variables as POJO expressions:

  • CURRENT_TIMESTAMP (CurrentTimestamp, carries a fractional-second precision)
  • CURRENT_TIMEZONE (CurrentTimezone)
  • CURRENT_DATE (CurrentDate)

All three implement a shared ExecutionContextVariable marker interface (extending Expression, mirroring the Literal/Nested/Subquery precedent). Per the spec, each is a leaf expression whose result type always has NULLABILITY_REQUIRED nullability.

Resolves #802 (part of the v0.87.0 epic #790; sibling to the ExecutionBehavior work in #791).

Changes

  • POJO model (Expression.java): marker interface + three @Value.Immutable classes.
  • Visitor: new visit methods on ExpressionVisitor, fallback defaults on AbstractExpressionVisitor, and handlers in the direct implementors (ExpressionProtoConverter, ExpressionCopyOnWriteVisitor, examples ExpressionStringify).
  • Proto conversion: POJO→proto in ExpressionProtoConverter; proto→POJO EXECUTION_CONTEXT_VARIABLE case in ProtoExpressionConverter.
  • Ergonomics: ExpressionCreator factories and SubstraitBuilder DSL helpers (currentTimestamp(precision), currentTimezone(), currentDate()).
  • Tests: ExecutionContextVariableRoundtripTest covering getType() and POJO↔proto round-trip for all three variants.

Verification

:core:test, :core:spotlessCheck, and compilation of :isthmus, :spark:spark-3.5_2.12, and :examples:substrait-spark all pass.

🤖 Generated with AI

Add CURRENT_TIMESTAMP, CURRENT_TIMEZONE, and CURRENT_DATE execution
context variables as POJO expressions, modeled under a shared
ExecutionContextVariable marker interface. Each is a leaf expression
whose result type has NULLABILITY_REQUIRED nullability per the Substrait
spec.

Includes visitor support (ExpressionVisitor / AbstractExpressionVisitor
and direct implementors), bidirectional protobuf conversion, and
ExpressionCreator / SubstraitBuilder helpers, plus a round-trip test.
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.

add ExecutionContextVariable support (CURRENT_DATE, CURRENT_TIMESTAMP, CURRENT_TIMEZONE)

1 participant