Skip to content

Conversation

@gord02
Copy link
Contributor

@gord02 gord02 commented Oct 28, 2025

This PR is to change the substrait-java virtualTableScan to use nested structs in place of the now deprecated struct literals.

The issue

Key changes:

  • Add the visitation pattern logic
  • Proto to Rel conversion
  • Rel to proto conversion
  • Spark to Substrait
  • Substrait to Spark
  • SubstraitRelNodeConverter: substrait virtualTableScan to calcite logicalValues, required creating a project for non-literal expressions
  • SubstraitRelVisitor: Calcite to substrait conversion that removes the extra project added to account for non-literal expressions

Testing:

  • LogicalValuesTest tested the conversion from pojo to calcite node back to pojo

Testing:
./gradlew test --tests io.substrait.isthmus.LogicalValuesTest --debug-jvm

@bestbeforetoday
Copy link
Contributor

@gord02 you will need to make sure that the subject line and text of all commits in your pull request conform to the structure dictated by conventional commits. You can look at the output of the Lint commits for semantic-release build check to see problems flagged, and also the CONTRIBUTING guide for tips.

When you have lots of commits that need fixing, it can sometimes be easier to squash them into fewer commits to reduce the number of changes you need to make.

@gord02 gord02 force-pushed the gordon.hamilton/nestedStructSupport branch 2 times, most recently from ef39861 to 17119c8 Compare October 30, 2025 14:39
@nielspardon
Copy link
Member

Does this PR replace #417 which seems to have tried to do a similar change?

@gord02 gord02 marked this pull request as ready for review October 30, 2025 16:01
@gord02
Copy link
Contributor Author

gord02 commented Oct 30, 2025

Hi @nielspardon! This PR completes and builds off of that PR yes. So it can be deleted.

@benbellick
Copy link
Member

I created an issue to track this particular problem @ #587. @gord02 would you mind including it somewhere in your PR description so that it gets linked?

@benbellick benbellick self-requested a review October 30, 2025 18:18
@gord02 gord02 force-pushed the gordon.hamilton/nestedStructSupport branch from 17119c8 to d799bdf Compare October 30, 2025 18:34
Copy link
Member

@benbellick benbellick left a comment

Choose a reason for hiding this comment

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

I have left a few comments on here so far. I think some of them might cause some reshuffling around so I'll save some of the more in-depth suggestions for the future. One other thing, it would be great if you could introduce some test which specifically demonstrates the logic you introduced where deserialized protos can handle either the presence of fields or values, but not both. I can imagine a test in which you constuct two protos, one via values and one via fields, and just demonstrate that once you render them both as POJOs, they are equal. That's just one idea though.

Anyways, thanks for all of your work! Let me know if anything I wrote isn't clear :)

.object(ExtensionDdl.DdlObject.VIEW)
.build();

io.substrait.proto.Rel protoRel = relProtoConverter.toProto(command);
Copy link
Member

Choose a reason for hiding this comment

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

This test has become a test for virtual tables instead of the intended Ddl test. You can see that the virtual table was just fed in as an input the ExtensionDdl builder as a viewDefinition. Were these changes actually necessary?

ProtoExpressionConverter converter =
new ProtoExpressionConverter(lookup, extensions, virtualTableSchema.struct(), this);
List<Expression.StructLiteral> structLiterals = new ArrayList<>(virtualTable.getValuesCount());

Copy link
Member

Choose a reason for hiding this comment

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

instead of handling below the converion of proto -> expression for StructLiterals and StrutNested's inline, could we introduce method to handle conversions of Nested in ProtoExpressionConverter.java (once you do the above of having a Nested interface)? Similar to how it is handled for Literals.

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.

5 participants