-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Autoloading mechanism for extensions #8732
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
Merged
Conversation
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
|
Thanks! |
1 task
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
…ions-2 Autoloading mechanism for extensions
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
…ions-2 Autoloading mechanism for extensions
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
…ions-2 Autoloading mechanism for extensions
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
…ions-2 Autoloading mechanism for extensions
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to krlmlr/duckdb-r
that referenced
this pull request
Sep 2, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to duckdb/duckdb-r
that referenced
this pull request
Sep 5, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to duckdb/duckdb-r
that referenced
this pull request
Sep 6, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to duckdb/duckdb-r
that referenced
this pull request
Sep 7, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
krlmlr
pushed a commit
to duckdb/duckdb-r
that referenced
this pull request
Sep 7, 2023
- Merge pull request duckdb/duckdb#8732 from samansmink/autoload-extensions-2
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.
Basics
This PR introduces a first version of an autoloading mechanism to DuckDB extensions. This can remove the need to run
install/load <extension_name>in many use-cases.There are 2 main settings controlling the mechanism:
autoload_known_extensionsandautoinstall_known_extensions. Both these settings default totruefor the following builds:Note that the defaults for these settings are still behind a flag, since the default when compiling duckdb manually should probably be
false.How to use
With these settings on, DuckDB will now attempt to automatically install and load an extension when a query requires it without it being loaded already. So for example instead of:
you can now just do
And under the hood, DuckDB would install and load the httpfs and json extension.
Note that you could also disable
autoinstall_known_extensions: then just a single install is required and then all consequent calls to functions using that extension will automatically load the extension from~/.duckdb/extensionsWhat can trigger autoloading?
There are many types of queries that can now trigger an autoload/install:
The mapping of these functions is currently hardcoded in the extension_entries.hpp header file. For example, one of the maps in extension_entries.hpp is currently:
When a catalog lookup for a copy function now fails, it will look in this map to see if there is an extension that contains a copy function with that name. Note that this mechanism already previously exists, but then only to throw informed errors in some cases.
Notable yak shavings
INSTALL x FROM y
Firstly, a new syntax was added that allows specifying the endpoint from which to install an extension from. This was already previously possible using
set custom_extension_repository='.....';but that can now be simplified using:INSTALL <ext_name> FROM 'http://url.com'Installing extensions from local directories
Extension repositories can now both be remote http server and a local directory, this is used for testing, but we can expand it to later support using httpfs for extensions.
Centralized config for builtin extensions
In
.github/config/bundled_extensions.cmakewe now specify which extensions are bundled. The idea is to create a central config that specifies which extensions are included in the binary distributions. Note that some extensions are built but not linked, this is because they are used during testing of the to be distributed binaries.Improved
scripts/run_tests_one_by_one.pyThis now prints the number of assertions that are made in each test. This is crucial to confirm that the test you think runs in CI, also actually runs:
How is this all tested?
As this is quite a invasive feature, its important to test this well. To achieve that, we basically run all SQLLogicTests in autoloading mode. An additional test run is launched in
.github/actions/build_extensions/action.yml. What this does is:require <>statement together with some autoloading specific testsTODOs
Adding out of tree extensions
Well since this initial PR only adds the in-tree extensions to this mechanism, we can also start adding out-of-tree extensions now. All infrastructure should be there to do easily: When an extension is added and marked as autoloadable to the autoloading entries in
extension_entries.hpp, it should be immediataly autoloadable. Also, since the autoloading test step in CI also loads the tests for out-of-tree extensions, it should be automatically be tested as autoloadable by running its tests.Making ICU and INET autoloadable
These two in-tree extensions are currently not yet autoloadable: The problem is that to autoload an extension, the extension's init function can not start a transaction. Instead it should use the ExtensionUtils register functions as these use the system transaction making them available immediately in the transaction triggering the autoload. For ICU and INET however, this is currently not possible yet.