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

fix: project rel to and from substrait to include pass through columns #135

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

scgkiran
Copy link
Contributor

@scgkiran scgkiran commented Jan 8, 2025

No description provided.

common = &sop.project().common();
break;
default:
throw InternalException("Unsupported relation type " + to_string(sop.rel_type_case()));
Copy link
Member

Choose a reason for hiding this comment

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

Almost every relation should be in this list. I'd consider calling anything missing not yet implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah..! Thanks for pointing out, I missed this.

This also reminds me that I could avoid a project by using output mapping, whenever I only have to change the column order of a give relation.

default:
throw InternalException("Unsupported relation type " + to_string(sop.rel_type_case()));
}
if (!common->has_emit()) {
Copy link
Member

Choose a reason for hiding this comment

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

It may be useful to break this into code to get the common table and code to get the emit from the mapping. That way you can use .the common structure to update direct and emit if necessary. You might be able to use templates to get the RelCommon which could reduce the overall amount of code.

auto mapping = GetOutputMapping(sop);
auto num_input_columns = input_rel->Columns().size();
if (mapping.empty()) {
for (int i = 1; i <= num_input_columns; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

The first column is numbered at zero. I found https://substrait.io/tutorial/sql_to_substrait/#field-indices to be useful (in addition to the individual relation pages).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The index i is used to create the duckdb column reference not substrait. For reference please see here.

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.

2 participants