-
Notifications
You must be signed in to change notification settings - Fork 79
feat(isthmus): convert Calcite RelRoot to Substrait Plan.Root #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
public static Rel convert(RelRoot root, SimpleExtension.ExtensionCollection extensions) { | ||
return convert(root.rel, extensions, FEATURES_DEFAULT); | ||
public static Plan.Root convert(RelRoot relRoot, SimpleExtension.ExtensionCollection extensions) { | ||
return convert(relRoot, extensions, FEATURES_DEFAULT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking API change.
A CalciteRelRoot
corresponds to POJO Plan.Root
, not a POJO Rel
.
assertEquals(expectedNames, substraitRelRoot.getNames()); | ||
|
||
org.apache.calcite.rel.RelRoot calciteRelRoot2 = substraitToCalcite.convert(substraitRelRoot); | ||
assertEquals(expectedNames, calciteRelRoot2.validatedRowType.getFieldNames()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to be able to use to the new Plan.Root
based assertFullRoundTrip
to test this, but it doesn't quite work: #371
Rel pojo1 = SubstraitRelVisitor.convert(relRoot, EXTENSION_COLLECTION); | ||
List<RelRoot> relRoots = s.sqlToRelNode(query, creates); | ||
assertEquals(1, relRoots.size()); | ||
RelRoot relRoot1 = relRoots.get(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice we only ever generate a single RelRoot. Capturing this here and removing the looping to simplify our test code.
This is the other direction of #339, which was implemented by @nielspardon I added a test for this in e230dcc which failed in CI (as expected). The failure was
Effectively, the names were lost when going from Calcite to Substrait and back because we were converting the Calcite RelRoot to a Substrait Rel, which has nowhere to stash the names. Calcite then generates names based on the table definition, and as the colums are capitalized it uses the capitalized names. |
fe400a6
to
2479476
Compare
…isitor RelRoots must be converted to Plan.Roots in order to ensure that names are handled correctly. BREAKING CHANGE: converting a Calcite RelRoot no longer produces a Substrait Rel
2479476
to
0e7ad03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense + looks good to me, thanks!
The fix for the breaking change is quite easy to figure out too
In the SubstraitRelVisitor, RelRoots must be converted to Plan.Roots in order to
ensure that names are handled correctly.
BREAKING CHANGE: converting a Calcite RelRoot no longer produces a Substrait Rel