forked from duckdb/substrait
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
Add functions to substrait extension #1
Draft
drin
wants to merge
26
commits into
main
Choose a base branch
from
eval-coop-decomp
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reorganization is partially for my own benefit (readability and internalizing the structure), though I did add some improvements such as how substrait types are used in switch statements. The other motivation for this reorganization is so that I can have a better overall structure/framework for also "translating" a substrait plan to a logical duckdb plan (instead of only a physical duckdb plan). In this code, I use "translation" to refer to a _lowering_ from a logical substrait plan to a physical duckdb plan.
In this code, which is an initial placeholder, I use "transpilation" to refer to a translation (general sense of the word) from a logical substrait plan to a logical duckdb plan. Thus, going forward I will be using "translation" to refer to a lowering (e.g. logical to physical) and "transpilation" to refer to a transformation to another language (dialect?) of the same level (e.g. logical to logical).
This worked with the updated code for translation, but I have not yet begun to work on code for transpilation, so this is certain to not work at the moment (though, deleting everything transpilation related should get it to work).
NOTE: these sources can potentially be dropped
NOTE: these can potentially be dropped in the future now that there's a clear transformation path from duckdb::Relation to duckdb::LogicalOperator
updated some types and changed TranspilePlanMessage to call TranslateMessage then transform duckdb::Relation into duckdb::LogicalOperator. This makes the layers of abstraction I expected ("translation", "transpilation") basically wrong, but I will update that when I get more clarity on it.
I still have to figure out how to execute a physical plan, but otherwise I have updated to convert from duckdb::Relation to duckdb::LogicalOperator, optimize duckdb::LogicalOperator, then create a physical plan (duckdb::PhysicalOperator) from a logical plan (duckdb::LogicalOperator). Most of the above is to be sure that I'm correctly doing the transformations, etc. and they will be migrated once I better figure out the various interfaces to extensions (rather than just a TableFunction).
Since they aren't necessary at the moment
Now that the transpilation path goes from Relation -> LogicalOperator, the transpilation functions are unnecessary.
This unused function caused linking issues, and it won't be needed in the future
While transpilation (via transforming Relation -> LogicalOperator) was straightforward, it was necessary to figure out how execution of the logical plan is done. These changes include optimization of the logical plan, transformation from logical to physical, and execution of the physical plan.
This probably isn't necessary but I am making it just to make it
this way, plans.hpp and plans.cpp can provide a structure for engine-agnostic hooks (though it doesn't seem very good right now)
this is because EnginePlan has been changed to SystemPlan and engine specific code has been removed.
TableFunctions have been renamed to reflect a better understanding of the process. Currently the added functions are "exec_mohair" and "translate_mohair" where "mohair" is a reference to substrait plans as a cross-engine plan representation
I apparently merged in changes to substrait extension that depend on duckdb v0.10.1. Instead of reverting the changes, I decided to update duckdb dependency
In my branch of duckdb (coop-decomp) I added an `ExplainSubstrait` function for the python API to show the physical plan generated from a substrait plan (instead of just a single TableFunction node)
Debian 20240408-slim seems to have cmake 3.25.1, so I downgraded to that version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds functions
translate_mohair
andexecute_mohair
to add more ways to interact with substrait:translate_mohair
converts the substrait plan to a DuckDB logical plan (duckdb::LogicalOperator
), optimizes it, then converts it to a DuckDB physical plan (duckdb::PhysicalOperator
).execute_mohair
callstranslate_mohair
, then executes the physical plan. This is potentially different execution path fromfrom_substrait
which goes directly toduckdb::Relation
and executes that (which I believe does not go through the optimizer).More functionality to come.