Skip to content
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

feat: support output order remapping #132

Merged
merged 8 commits into from
Mar 8, 2023

Conversation

vbarua
Copy link
Member

@vbarua vbarua commented Mar 6, 2023

  • Makes fields in SubstraitRelNodeConverter protected to allow for re-use when extending it with custom behaviours.
  • Adds deriveRecordType to Cross to make it consistent with other Rels.
  • Adds SubstraitBuilder, which encodes a DSL to make it easier to build plans programmatically.
  • Adds SubstraitToCalcite, to convert directly from Substrait to Calcite. Includes functionality to extract a schema from the Substrait Rel directly.
  • Bumps the junit-jupiter version for access to the assertInstanceOf method.
  • Adds tests to verify the layout of Rels when converted w/ both Direct and Remap output ordering.
  • Adds support for the Remap output type to SubstraitRelNodeConverter.

@vbarua vbarua force-pushed the vbarua/remapping branch from 535a711 to faf23fb Compare March 6, 2023 16:29
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SubstraitBuilder {
Copy link
Member Author

@vbarua vbarua Mar 6, 2023

Choose a reason for hiding this comment

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

See SubstraitRelNodeConverter for an example of how the methods in this class are used.

Could make this internal only as well to limit committing to an external API for this.

Choose a reason for hiding this comment

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

I like the idea of moving towards an easier to write wrapper for generating plans, but any "usability" API would almost certainly need to come with proper docs, ideally containing short usage examples. An undocumented usability API, or one only documented by having to read the source code of other code, is going to be of limited use.

Copy link
Member Author

Choose a reason for hiding this comment

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

This got merged before I circled back to hiding this.

Looking at https://substrait.io/spec/versioning/, because we're pre-1.0 I'm more comfortable with having it in. It is super useful for writing tests, both in substream-java and downstream.

but any "usability" API would almost certainly need to come with proper docs, ideally containing short usage examples.

100% something to have in place before 1.0.

@vbarua vbarua force-pushed the vbarua/remapping branch from faf23fb to 0fa44ad Compare March 6, 2023 16:53
@vbarua vbarua marked this pull request as ready for review March 6, 2023 16:54
import org.immutables.value.Value;

@Value.Immutable
public abstract class Cross extends BiRel {

@Override
protected Type.Struct deriveRecordType() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I've realised that adding this removes the deriveRecordType method from the ImmutableCross.Builder, meaning this is technically a breaking change.

* <p>Can be extended to customize the {@link RelBuilder} and {@link SubstraitRelNodeConverter} used
* in the conversion.
*/
public class SubstraitToCalcite {
Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about this some more, though I'm pretty happy with this I don't know if I'm "happy as public API forever" kind of happy. Could make this protected and keep it internal only for now.

Copy link

Choose a reason for hiding this comment

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

I think if you're uncertain, it might be best to be conservative and leave it protected until someone needs it.

Copy link
Member Author

Choose a reason for hiding this comment

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

This got merged before I circled back to hiding this.

Looking at https://substrait.io/spec/versioning/, because we're pre-1.0 I'm more comfortable with having it in. It is actually helpful to have as downstream user and it does make it easier for folks experiment with converting substrait plans directly to Calcite.

Copy link
Contributor

@JamesRTaylor JamesRTaylor left a comment

Choose a reason for hiding this comment

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

Nice improvement. Thanks for the fixes too.

@JamesRTaylor JamesRTaylor merged commit 6d94059 into substrait-io:main Mar 8, 2023
ajegou pushed a commit to ajegou/substrait-java that referenced this pull request Mar 29, 2024
* refactor: expand access to SubstraitRelNodeConverter fields
* feat: add deriveRecordType to Cross
* feat: substrait builder dsl
* feat: self-contained Substrait to Calcite converter
* chore: bump junit-jupiter
* test: check for application of remappings
* feat: apply remaps
* refactor: move RelOutputTest to SubstraitRelNodeConverterTest
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.

4 participants