-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Initial version of extension to allow creating operators outside of duckdb core lib #5144
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
Merged
Mytherin
merged 8 commits into
duckdb:master
from
motherduckdb:rj/operator-extension-proposal
Nov 12, 2022
+118
−13
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
77e11da
Initial version of extension to allow creating operators outside of d…
rjatwal bcd613d
Changing extension operators planning to use a virtual method on the …
rjatwal 3ab2d97
Moved extension bind hook up the call stack from binder.cpp into plan…
rjatwal e612716
Removing forward-declaration made redundant by refactoring
rjatwal 42ba867
Formatting
rjatwal b2c92e8
Fixing ctidy check
rjatwal cc2eff0
Adding if clause that I staged incorrectly
rjatwal 0bbd8b3
Fixing edge case brought up by fuzzer
rjatwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
26 changes: 26 additions & 0 deletions
26
src/include/duckdb/planner/operator/logical_extension_operator.hpp
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // DuckDB | ||
| // | ||
| // duckdb/planner/operator/logical_extension.operator.hpp | ||
| // | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "duckdb/planner/logical_operator.hpp" | ||
| #include "duckdb/planner/operator_extension.hpp" | ||
|
|
||
| namespace duckdb { | ||
|
|
||
| struct LogicalExtensionOperator : public LogicalOperator { | ||
|
|
||
| LogicalExtensionOperator() : LogicalOperator(LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR) { | ||
| } | ||
| LogicalExtensionOperator(vector<unique_ptr<Expression>> expressions) | ||
| : LogicalOperator(LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR, move(expressions)) { | ||
| } | ||
|
|
||
| virtual unique_ptr<PhysicalOperator> CreatePlan(ClientContext &context, PhysicalPlanGenerator &generator) = 0; | ||
| }; | ||
| } // namespace duckdb |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // DuckDB | ||
| // | ||
| // duckdb/planner/operator_extension.hpp | ||
| // | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "duckdb/common/common.hpp" | ||
| #include "duckdb/execution/physical_plan_generator.hpp" | ||
| #include "duckdb/planner/binder.hpp" | ||
|
|
||
| namespace duckdb { | ||
|
|
||
| //! The OperatorExtensionInfo holds static information relevant to the operator extension | ||
| struct OperatorExtensionInfo { | ||
| DUCKDB_API virtual ~OperatorExtensionInfo() { | ||
| } | ||
| }; | ||
|
|
||
| typedef BoundStatement (*bind_function_t)(ClientContext &context, Binder &binder, OperatorExtensionInfo *info, | ||
| SQLStatement &statement); | ||
|
|
||
| class OperatorExtension { | ||
| public: | ||
| bind_function_t Bind; | ||
|
|
||
| //! Additional info passed to the CreatePlan & Bind functions | ||
| shared_ptr<OperatorExtensionInfo> operator_info; | ||
|
|
||
| DUCKDB_API virtual ~OperatorExtension() { | ||
| } | ||
| }; | ||
|
|
||
| } // namespace duckdb |
This file contains hidden or 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 file contains hidden or 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 file contains hidden or 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 file contains hidden or 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
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.
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.
Won't this still throw the exception - as this break only breaks out of the loop and into the
throwstatement?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.
Thanks for taking close look at my PR. Indeed I staged my commit incorrectly and forgot the guard check. Doing another round of testing and will push the update.