duckdb 0.8.2-dev3300.0 → 0.8.2-dev3456.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/binding.gyp +3 -1
  2. package/configure.py +3 -0
  3. package/package.json +1 -1
  4. package/src/duckdb/src/catalog/catalog.cpp +144 -63
  5. package/src/duckdb/src/common/exception.cpp +13 -0
  6. package/src/duckdb/src/common/file_system.cpp +21 -6
  7. package/src/duckdb/src/core_functions/scalar/enum/enum_functions.cpp +16 -12
  8. package/src/duckdb/src/core_functions/scalar/generic/current_setting.cpp +3 -1
  9. package/src/duckdb/src/execution/operator/helper/physical_load.cpp +2 -1
  10. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +3 -1
  11. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +3 -1
  12. package/src/duckdb/src/function/pragma/pragma_queries.cpp +2 -1
  13. package/src/duckdb/src/function/table/read_csv.cpp +8 -3
  14. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  15. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +20 -5
  16. package/src/duckdb/src/include/duckdb/common/exception.hpp +15 -1
  17. package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
  18. package/src/duckdb/src/include/duckdb/main/config.hpp +12 -0
  19. package/src/duckdb/src/include/duckdb/main/extension/generated_extension_loader.hpp +6 -1
  20. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +209 -151
  21. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +34 -3
  22. package/src/duckdb/src/include/duckdb/main/settings.hpp +30 -0
  23. package/src/duckdb/src/include/duckdb/parser/parsed_data/load_info.hpp +4 -0
  24. package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
  25. package/src/duckdb/src/main/config.cpp +3 -0
  26. package/src/duckdb/src/main/extension/extension_helper.cpp +57 -0
  27. package/src/duckdb/src/main/extension/extension_install.cpp +46 -7
  28. package/src/duckdb/src/main/settings/settings.cpp +46 -0
  29. package/src/duckdb/src/parser/transform/statement/transform_load.cpp +1 -0
  30. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +69 -23
  31. package/src/duckdb/src/planner/expression_binder/order_binder.cpp +5 -4
  32. package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +2 -0
  33. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -0
  34. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +8747 -8821
@@ -80,7 +80,8 @@ enum class ExceptionType {
80
80
  PARAMETER_NOT_ALLOWED = 36, // parameter types not allowed
81
81
  DEPENDENCY = 37, // dependency
82
82
  HTTP = 38,
83
- MISSING_EXTENSION = 39 // Thrown when an extension is used but not loaded
83
+ MISSING_EXTENSION = 39, // Thrown when an extension is used but not loaded
84
+ AUTOLOAD = 40 // Thrown when an extension is used but not loaded
84
85
  };
85
86
  class HTTPException;
86
87
 
@@ -290,6 +291,19 @@ public:
290
291
  }
291
292
  };
292
293
 
294
+ class AutoloadException : public Exception {
295
+ public:
296
+ DUCKDB_API explicit AutoloadException(const string &extension_name, Exception &e);
297
+
298
+ template <typename... Args>
299
+ explicit AutoloadException(const string &extension_name, Exception &e, Args... params)
300
+ : AutoloadException(ConstructMessage(extension_name, e, params...)) {
301
+ }
302
+
303
+ protected:
304
+ Exception &wrapped_exception;
305
+ };
306
+
293
307
  class HTTPException : public IOException {
294
308
  public:
295
309
  template <typename>
@@ -91,6 +91,8 @@ struct ClientConfig {
91
91
 
92
92
  //! Override for the default extension repository
93
93
  string custom_extension_repo = "";
94
+ //! Override for the default autoload extensoin repository
95
+ string autoinstall_extension_repo = "";
94
96
 
95
97
  //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
96
98
  ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
@@ -95,6 +95,18 @@ struct DBConfigOptions {
95
95
  bool use_direct_io = false;
96
96
  //! Whether extensions should be loaded on start-up
97
97
  bool load_extensions = true;
98
+ #ifdef DUCKDB_EXTENSION_AUTOLOAD_DEFAULT
99
+ //! Whether known extensions are allowed to be automatically loaded when a query depends on them
100
+ bool autoload_known_extensions = DUCKDB_EXTENSION_AUTOLOAD_DEFAULT;
101
+ #else
102
+ bool autoload_known_extensions = false;
103
+ #endif
104
+ #ifdef DUCKDB_EXTENSION_AUTOINSTALL_DEFAULT
105
+ //! Whether known extensions are allowed to be automatically installed when a query depends on them
106
+ bool autoinstall_known_extensions = DUCKDB_EXTENSION_AUTOINSTALL_DEFAULT;
107
+ #else
108
+ bool autoinstall_known_extensions = false;
109
+ #endif
98
110
  //! The maximum memory used by the database system (in bytes). Default: 80% of System available memory
99
111
  idx_t maximum_memory = (idx_t)-1;
100
112
  //! The maximum amount of CPU threads used by the database system. Default: all available.
@@ -8,13 +8,18 @@
8
8
 
9
9
  #pragma once
10
10
 
11
+ #include "duckdb/main/database.hpp"
12
+ #include "duckdb/common/string.hpp"
13
+ #include "duckdb/common/vector.hpp"
14
+
11
15
  #if defined(GENERATED_EXTENSION_HEADERS) and !defined(DUCKDB_AMALGAMATION)
12
16
  #include "generated_extension_headers.hpp"
17
+ #include "duckdb/common/common.hpp"
13
18
 
14
19
  namespace duckdb {
15
20
 
16
21
  //! Looks through the CMake-generated list of extensions that are linked into DuckDB currently to try load <extension>
17
- bool TryLoadLinkedExtension(DuckDB &db, const std::string &extension);
22
+ bool TryLoadLinkedExtension(DuckDB &db, const string &extension);
18
23
  extern vector<string> linked_extensions;
19
24
  extern vector<string> loaded_extension_test_paths;
20
25
 
@@ -10,6 +10,9 @@
10
10
 
11
11
  #include "duckdb/common/unordered_map.hpp"
12
12
 
13
+ // NOTE: this file is generated by scripts/generate_extensions_function.py. Check out the check-load-install-extensions
14
+ // job in .github/workflows/LinuxRelease.yml on how to use it
15
+
13
16
  namespace duckdb {
14
17
 
15
18
  struct ExtensionEntry {
@@ -17,165 +20,172 @@ struct ExtensionEntry {
17
20
  char extension[48];
18
21
  };
19
22
 
20
- static constexpr ExtensionEntry EXTENSION_FUNCTIONS[] = {{"->>", "json"},
21
- {"array_to_json", "json"},
22
- {"create_fts_index", "fts"},
23
- {"current_localtime", "icu"},
24
- {"current_localtimestamp", "icu"},
25
- {"dbgen", "tpch"},
26
- {"drop_fts_index", "fts"},
27
- {"dsdgen", "tpcds"},
28
- {"excel_text", "excel"},
29
- {"from_json", "json"},
30
- {"from_json_strict", "json"},
31
- {"from_substrait", "substrait"},
32
- {"from_substrait_json", "substrait"},
33
- {"get_substrait", "substrait"},
34
- {"get_substrait_json", "substrait"},
35
- {"iceberg_scan", "iceberg"},
36
- {"iceberg_metadata", "iceberg"},
37
- {"iceberg_snapshots", "iceberg"},
38
- {"icu_calendar_names", "icu"},
39
- {"icu_sort_key", "icu"},
40
- {"json", "json"},
41
- {"json_array", "json"},
42
- {"json_array_length", "json"},
43
- {"json_contains", "json"},
44
- {"json_extract", "json"},
45
- {"json_extract_path", "json"},
46
- {"json_extract_path_text", "json"},
47
- {"json_extract_string", "json"},
48
- {"json_group_array", "json"},
49
- {"json_group_object", "json"},
50
- {"json_group_structure", "json"},
51
- {"json_keys", "json"},
52
- {"json_merge_patch", "json"},
53
- {"json_object", "json"},
54
- {"json_quote", "json"},
55
- {"json_structure", "json"},
56
- {"json_transform", "json"},
57
- {"json_transform_strict", "json"},
58
- {"json_type", "json"},
59
- {"json_valid", "json"},
60
- {"json_serialize_sql", "json"},
61
- {"json_deserialize_sql", "json"},
62
- {"json_serialize_sql", "json"},
63
- {"json_execute_serialized_sql", "json"},
64
- {"load_aws_credentials", "aws"},
65
- {"make_timestamptz", "icu"},
66
- {"parquet_metadata", "parquet"},
67
- {"parquet_scan", "parquet"},
68
- {"parquet_schema", "parquet"},
69
- {"pg_timezone_names", "icu"},
70
- {"postgres_attach", "postgres_scanner"},
71
- {"postgres_scan", "postgres_scanner"},
72
- {"postgres_scan_pushdown", "postgres_scanner"},
73
- {"read_json", "json"},
74
- {"read_json_auto", "json"},
75
- {"read_json_objects", "json"},
76
- {"read_json_objects_auto", "json"},
77
- {"read_ndjson", "json"},
78
- {"read_ndjson_auto", "json"},
79
- {"read_ndjson_objects", "json"},
80
- {"read_parquet", "parquet"},
81
- {"row_to_json", "json"},
82
- {"scan_arrow_ipc", "arrow"},
83
- {"sqlite_attach", "sqlite_scanner"},
84
- {"sqlite_scan", "sqlite_scanner"},
85
- {"stem", "fts"},
86
- {"text", "excel"},
87
- {"to_arrow_ipc", "arrow"},
88
- {"to_json", "json"},
89
- {"tpcds", "tpcds"},
90
- {"tpcds_answers", "tpcds"},
91
- {"tpcds_queries", "tpcds"},
92
- {"tpch", "tpch"},
93
- {"tpch_answers", "tpch"},
94
- {"tpch_queries", "tpch"},
95
- {"visualize_diff_profiling_output", "visualizer"},
96
- {"visualize_json_profiling_output", "visualizer"},
97
- {"visualize_last_profiling_output", "visualizer"},
98
- {"st_distance_spheroid", "spatial"},
99
- {"st_boundary", "spatial"},
100
- {"st_makeline", "spatial"},
101
- {"st_buffer", "spatial"},
102
- {"st_x", "spatial"},
103
- {"st_isring", "spatial"},
104
- {"st_centroid", "spatial"},
105
- {"st_read", "spatial"},
106
- {"st_geomfromwkb", "spatial"},
107
- {"st_list_proj_crs", "spatial"},
108
- {"st_isvalid", "spatial"},
109
- {"st_polygon2dfromwkb", "spatial"},
110
- {"st_disjoint", "spatial"},
111
- {"st_length", "spatial"},
112
- {"st_difference", "spatial"},
113
- {"st_area", "spatial"},
114
- {"st_union", "spatial"},
115
- {"st_isclosed", "spatial"},
116
- {"st_asgeojson", "spatial"},
117
- {"st_intersection", "spatial"},
118
- {"st_transform", "spatial"},
119
- {"st_dwithin", "spatial"},
120
- {"st_perimeter", "spatial"},
121
- {"st_issimple", "spatial"},
122
- {"st_geometrytype", "spatial"},
123
- {"st_simplifypreservetopology", "spatial"},
124
- {"st_distance", "spatial"},
125
- {"st_astext", "spatial"},
126
- {"st_overlaps", "spatial"},
127
- {"st_convexhull", "spatial"},
128
- {"st_normalize", "spatial"},
129
- {"st_drivers", "spatial"},
130
- {"st_point2dfromwkb", "spatial"},
131
- {"st_point2d", "spatial"},
132
- {"st_y", "spatial"},
133
- {"st_dwithin_spheroid", "spatial"},
134
- {"st_isempty", "spatial"},
135
- {"st_simplify", "spatial"},
136
- {"st_area_spheroid", "spatial"},
137
- {"st_within", "spatial"},
138
- {"st_length_spheroid", "spatial"},
139
- {"st_point3d", "spatial"},
140
- {"st_containsproperly", "spatial"},
141
- {"st_contains", "spatial"},
142
- {"st_collect", "spatial"},
143
- {"st_touches", "spatial"},
144
- {"st_linestring2dfromwkb", "spatial"},
145
- {"st_flipcoordinates", "spatial"},
146
- {"st_ashexwkb", "spatial"},
147
- {"st_geomfromtext", "spatial"},
148
- {"st_point4d", "spatial"},
149
- {"st_point", "spatial"},
150
- {"st_coveredby", "spatial"},
151
- {"st_perimeter_spheroid", "spatial"},
152
- {"st_intersects", "spatial"},
153
- {"st_crosses", "spatial"},
154
- {"st_covers", "spatial"},
155
- {"st_envelope", "spatial"},
156
- {"st_aswkb", "spatial"},
157
- {"st_equals", "spatial"},
158
- {"st_collectionextract", "spatial"},
159
- {"st_npoints", "spatial"},
160
- {"st_pointonsurface", "spatial"},
161
- {"st_dimension", "spatial"},
162
- {"st_removerepeatedpoints", "spatial"},
163
- {"st_geomfromgeojson", "spatial"},
164
- {"st_readosm", "spatial"},
165
- {"st_reduceprecision", "spatial"},
166
- {"st_geomfromhexwkb", "spatial"},
167
- {"st_geomfromhexewkb", "spatial"},
168
- {"st_numpoints", "spatial"}};
23
+ static constexpr ExtensionEntry EXTENSION_FUNCTIONS[] = {
24
+ {"->>", "json"},
25
+ {"array_to_json", "json"},
26
+ {"create_fts_index", "fts"},
27
+ {"current_localtime", "icu"},
28
+ {"current_localtimestamp", "icu"},
29
+ {"dbgen", "tpch"},
30
+ {"drop_fts_index", "fts"},
31
+ {"dsdgen", "tpcds"},
32
+ {"excel_text", "excel"},
33
+ {"from_json", "json"},
34
+ {"from_json_strict", "json"},
35
+ {"from_substrait", "substrait"},
36
+ {"from_substrait_json", "substrait"},
37
+ {"fuzz_all_functions", "sqlsmith"},
38
+ {"fuzzyduck", "sqlsmith"},
39
+ {"get_substrait", "substrait"},
40
+ {"get_substrait_json", "substrait"},
41
+ {"host", "inet"},
42
+ {"iceberg_metadata", "iceberg"},
43
+ {"iceberg_scan", "iceberg"},
44
+ {"iceberg_snapshots", "iceberg"},
45
+ {"icu_calendar_names", "icu"},
46
+ {"icu_sort_key", "icu"},
47
+ {"json", "json"},
48
+ {"json_array", "json"},
49
+ {"json_array_length", "json"},
50
+ {"json_contains", "json"},
51
+ {"json_deserialize_sql", "json"},
52
+ {"json_execute_serialized_sql", "json"},
53
+ {"json_extract", "json"},
54
+ {"json_extract_path", "json"},
55
+ {"json_extract_path_text", "json"},
56
+ {"json_extract_string", "json"},
57
+ {"json_group_array", "json"},
58
+ {"json_group_object", "json"},
59
+ {"json_group_structure", "json"},
60
+ {"json_keys", "json"},
61
+ {"json_merge_patch", "json"},
62
+ {"json_object", "json"},
63
+ {"json_quote", "json"},
64
+ {"json_serialize_sql", "json"},
65
+ {"json_structure", "json"},
66
+ {"json_transform", "json"},
67
+ {"json_transform_strict", "json"},
68
+ {"json_type", "json"},
69
+ {"json_valid", "json"},
70
+ {"load_aws_credentials", "aws"},
71
+ {"make_timestamptz", "icu"},
72
+ {"parquet_metadata", "parquet"},
73
+ {"parquet_scan", "parquet"},
74
+ {"parquet_schema", "parquet"},
75
+ {"pg_timezone_names", "icu"},
76
+ {"postgres_attach", "postgres_scanner"},
77
+ {"postgres_scan", "postgres_scanner"},
78
+ {"postgres_scan_pushdown", "postgres_scanner"},
79
+ {"read_json", "json"},
80
+ {"read_json_auto", "json"},
81
+ {"read_json_objects", "json"},
82
+ {"read_json_objects_auto", "json"},
83
+ {"read_ndjson", "json"},
84
+ {"read_ndjson_auto", "json"},
85
+ {"read_ndjson_objects", "json"},
86
+ {"read_parquet", "parquet"},
87
+ {"reduce_sql_statement", "sqlsmith"},
88
+ {"row_to_json", "json"},
89
+ {"scan_arrow_ipc", "arrow"},
90
+ {"sql_auto_complete", "autocomplete"},
91
+ {"sqlite_attach", "sqlite_scanner"},
92
+ {"sqlite_scan", "sqlite_scanner"},
93
+ {"sqlsmith", "sqlsmith"},
94
+ {"st_area", "spatial"},
95
+ {"st_area_spheroid", "spatial"},
96
+ {"st_asgeojson", "spatial"},
97
+ {"st_ashexwkb", "spatial"},
98
+ {"st_astext", "spatial"},
99
+ {"st_aswkb", "spatial"},
100
+ {"st_boundary", "spatial"},
101
+ {"st_buffer", "spatial"},
102
+ {"st_centroid", "spatial"},
103
+ {"st_collect", "spatial"},
104
+ {"st_collectionextract", "spatial"},
105
+ {"st_contains", "spatial"},
106
+ {"st_containsproperly", "spatial"},
107
+ {"st_convexhull", "spatial"},
108
+ {"st_coveredby", "spatial"},
109
+ {"st_covers", "spatial"},
110
+ {"st_crosses", "spatial"},
111
+ {"st_difference", "spatial"},
112
+ {"st_dimension", "spatial"},
113
+ {"st_disjoint", "spatial"},
114
+ {"st_distance", "spatial"},
115
+ {"st_distance_spheroid", "spatial"},
116
+ {"st_drivers", "spatial"},
117
+ {"st_dwithin", "spatial"},
118
+ {"st_dwithin_spheroid", "spatial"},
119
+ {"st_envelope", "spatial"},
120
+ {"st_equals", "spatial"},
121
+ {"st_flipcoordinates", "spatial"},
122
+ {"st_geometrytype", "spatial"},
123
+ {"st_geomfromgeojson", "spatial"},
124
+ {"st_geomfromhexewkb", "spatial"},
125
+ {"st_geomfromhexwkb", "spatial"},
126
+ {"st_geomfromtext", "spatial"},
127
+ {"st_geomfromwkb", "spatial"},
128
+ {"st_intersection", "spatial"},
129
+ {"st_intersects", "spatial"},
130
+ {"st_isclosed", "spatial"},
131
+ {"st_isempty", "spatial"},
132
+ {"st_isring", "spatial"},
133
+ {"st_issimple", "spatial"},
134
+ {"st_isvalid", "spatial"},
135
+ {"st_length", "spatial"},
136
+ {"st_length_spheroid", "spatial"},
137
+ {"st_linestring2dfromwkb", "spatial"},
138
+ {"st_list_proj_crs", "spatial"},
139
+ {"st_makeline", "spatial"},
140
+ {"st_normalize", "spatial"},
141
+ {"st_npoints", "spatial"},
142
+ {"st_numpoints", "spatial"},
143
+ {"st_overlaps", "spatial"},
144
+ {"st_perimeter", "spatial"},
145
+ {"st_perimeter_spheroid", "spatial"},
146
+ {"st_point", "spatial"},
147
+ {"st_point2d", "spatial"},
148
+ {"st_point2dfromwkb", "spatial"},
149
+ {"st_point3d", "spatial"},
150
+ {"st_point4d", "spatial"},
151
+ {"st_pointonsurface", "spatial"},
152
+ {"st_polygon2dfromwkb", "spatial"},
153
+ {"st_read", "spatial"},
154
+ {"st_readosm", "spatial"},
155
+ {"st_reduceprecision", "spatial"},
156
+ {"st_removerepeatedpoints", "spatial"},
157
+ {"st_simplify", "spatial"},
158
+ {"st_simplifypreservetopology", "spatial"},
159
+ {"st_touches", "spatial"},
160
+ {"st_transform", "spatial"},
161
+ {"st_union", "spatial"},
162
+ {"st_within", "spatial"},
163
+ {"st_x", "spatial"},
164
+ {"st_y", "spatial"},
165
+ {"stem", "fts"},
166
+ {"text", "excel"},
167
+ {"to_arrow_ipc", "arrow"},
168
+ {"to_json", "json"},
169
+ {"tpcds", "tpcds"},
170
+ {"tpcds_answers", "tpcds"},
171
+ {"tpcds_queries", "tpcds"},
172
+ {"tpch", "tpch"},
173
+ {"tpch_answers", "tpch"},
174
+ {"tpch_queries", "tpch"},
175
+ {"visualize_diff_profiling_output", "visualizer"},
176
+ {"visualize_json_profiling_output", "visualizer"},
177
+ {"visualize_last_profiling_output", "visualizer"},
178
+ }; // END_OF_EXTENSION_FUNCTIONS
169
179
 
170
180
  static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
171
181
  {"azure_storage_connection_string", "azure"},
172
182
  {"binary_as_string", "parquet"},
173
183
  {"calendar", "icu"},
184
+ {"force_download", "httpfs"},
174
185
  {"http_retries", "httpfs"},
175
186
  {"http_retry_backoff", "httpfs"},
176
187
  {"http_retry_wait_ms", "httpfs"},
177
188
  {"http_timeout", "httpfs"},
178
- {"force_download", "httpfs"},
179
189
  {"s3_access_key_id", "httpfs"},
180
190
  {"s3_endpoint", "httpfs"},
181
191
  {"s3_region", "httpfs"},
@@ -189,5 +199,53 @@ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
189
199
  {"s3_use_ssl", "httpfs"},
190
200
  {"sqlite_all_varchar", "sqlite_scanner"},
191
201
  {"timezone", "icu"},
192
- };
202
+ }; // END_OF_EXTENSION_SETTINGS
203
+
204
+ // Note: these are currently hardcoded in scripts/generate_extensions_function.py
205
+ // TODO: automate by passing though to script via duckdb
206
+ static constexpr ExtensionEntry EXTENSION_COPY_FUNCTIONS[] = {{"parquet", "parquet"},
207
+ {"json", "json"}}; // END_OF_EXTENSION_COPY_FUNCTIONS
208
+
209
+ // Note: these are currently hardcoded in scripts/generate_extensions_function.py
210
+ // TODO: automate by passing though to script via duckdb
211
+ static constexpr ExtensionEntry EXTENSION_TYPES[] = {
212
+ {"json", "json"}, {"inet", "inet"}, {"geometry", "spatial"}}; // END_OF_EXTENSION_TYPES
213
+
214
+ // Note: these are currently hardcoded in scripts/generate_extensions_function.py
215
+ // TODO: automate by passing though to script via duckdb
216
+ static constexpr ExtensionEntry EXTENSION_FILE_PREFIXES[] = {
217
+ {"http://", "httpfs"}, {"https://", "httpfs"}, {"s3://", "httpfs"},
218
+ // {"azure://", "azure"}
219
+ }; // END_OF_EXTENSION_FILE_PREFIXES
220
+
221
+ // Note: these are currently hardcoded in scripts/generate_extensions_function.py
222
+ // TODO: automate by passing though to script via duckdb
223
+ static constexpr ExtensionEntry EXTENSION_FILE_POSTFIXES[] = {{".parquet", "parquet"},
224
+ {".json", "json"},
225
+ {".jsonl", "json"},
226
+ {".ndjson", "json"}}; // END_OF_EXTENSION_FILE_POSTFIXES
227
+
228
+ // Note: these are currently hardcoded in scripts/generate_extensions_function.py
229
+ // TODO: automate by passing though to script via duckdb
230
+ static constexpr ExtensionEntry EXTENSION_FILE_CONTAINS[] = {{".parquet?", "parquet"},
231
+ {".json?", "json"},
232
+ {".ndjson?", ".jsonl?"},
233
+ {".jsonl?", ".ndjson?"}}; // EXTENSION_FILE_CONTAINS
234
+
235
+ static constexpr const char *AUTOLOADABLE_EXTENSIONS[] = {
236
+ // "azure",
237
+ "autocomplete",
238
+ "excel",
239
+ "fts",
240
+ "httpfs",
241
+ // "inet",
242
+ // "icu",
243
+ "json",
244
+ "parquet",
245
+ "sqlsmith",
246
+ "tpcds",
247
+ "tpch",
248
+ "visualizer",
249
+ }; // END_OF_AUTOLOADABLE_EXTENSIONS
250
+
193
251
  } // namespace duckdb
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include <string>
12
12
  #include "duckdb.hpp"
13
+ #include "duckdb/main/extension_entries.hpp"
13
14
 
14
15
  namespace duckdb {
15
16
  class DuckDB;
@@ -40,11 +41,16 @@ public:
40
41
 
41
42
  static ExtensionLoadResult LoadExtension(DuckDB &db, const std::string &extension);
42
43
 
43
- static void InstallExtension(ClientContext &context, const string &extension, bool force_install);
44
- static void InstallExtension(DBConfig &config, FileSystem &fs, const string &extension, bool force_install);
44
+ static void InstallExtension(ClientContext &context, const string &extension, bool force_install,
45
+ const string &respository = "");
46
+ static void InstallExtension(DBConfig &config, FileSystem &fs, const string &extension, bool force_install,
47
+ const string &respository = "");
45
48
  static void LoadExternalExtension(ClientContext &context, const string &extension);
46
49
  static void LoadExternalExtension(DatabaseInstance &db, FileSystem &fs, const string &extension);
47
50
 
51
+ //! Autoload an extension by name. Depending on the current settings, this will either load or install+load
52
+ static void AutoLoadExtension(ClientContext &context, const string &extension_name);
53
+
48
54
  static string ExtensionDirectory(ClientContext &context);
49
55
  static string ExtensionDirectory(DBConfig &config, FileSystem &fs);
50
56
 
@@ -65,9 +71,34 @@ public:
65
71
  static string GetExtensionName(const string &extension);
66
72
  static bool IsFullPath(const string &extension);
67
73
 
74
+ //! Lookup a name in an ExtensionEntry list
75
+ template <size_t N>
76
+ static string FindExtensionInEntries(const string &name, const ExtensionEntry (&entries)[N]) {
77
+ auto lcase = StringUtil::Lower(name);
78
+
79
+ auto it =
80
+ std::find_if(entries, entries + N, [&](const ExtensionEntry &element) { return element.name == lcase; });
81
+
82
+ if (it != entries + N && it->name == lcase) {
83
+ return it->extension;
84
+ }
85
+ return "";
86
+ }
87
+
88
+ //! Whether an extension can be autoloaded (i.e. it's registered as an autoloadable extension in
89
+ //! extension_entries.hpp)
90
+ static bool CanAutoloadExtension(const string &ext_name);
91
+
92
+ //! Utility functions for creating meaningful error messages regarding missing extensions
93
+ static string WrapAutoLoadExtensionErrorMsg(ClientContext &context, const string &base_error,
94
+ const string &extension_name);
95
+ static string AddExtensionInstallHintToErrorMsg(ClientContext &context, const string &base_error,
96
+ const string &extension_name);
97
+
68
98
  private:
69
99
  static void InstallExtensionInternal(DBConfig &config, ClientConfig *client_config, FileSystem &fs,
70
- const string &local_path, const string &extension, bool force_install);
100
+ const string &local_path, const string &extension, bool force_install,
101
+ const string &repository);
71
102
  static const vector<string> PathComponents();
72
103
  static bool AllowAutoInstall(const string &extension);
73
104
  static ExtensionInitResult InitialLoad(DBConfig &config, FileSystem &fs, const string &extension);
@@ -188,6 +188,36 @@ struct CustomExtensionRepository {
188
188
  static Value GetSetting(ClientContext &context);
189
189
  };
190
190
 
191
+ struct AutoloadExtensionRepository {
192
+ static constexpr const char *Name = "autoinstall_extension_repository";
193
+ static constexpr const char *Description =
194
+ "Overrides the custom endpoint for extension installation on autoloading";
195
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::VARCHAR;
196
+ static void SetLocal(ClientContext &context, const Value &parameter);
197
+ static void ResetLocal(ClientContext &context);
198
+ static Value GetSetting(ClientContext &context);
199
+ };
200
+
201
+ struct AutoinstallKnownExtensions {
202
+ static constexpr const char *Name = "autoinstall_known_extensions";
203
+ static constexpr const char *Description =
204
+ "Whether known extensions are allowed to be automatically installed when a query depends on them";
205
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
206
+ static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
207
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
208
+ static Value GetSetting(ClientContext &context);
209
+ };
210
+
211
+ struct AutoloadKnownExtensions {
212
+ static constexpr const char *Name = "autoload_known_extensions";
213
+ static constexpr const char *Description =
214
+ "Whether known extensions are allowed to be automatically loaded when a query depends on them";
215
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
216
+ static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
217
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
218
+ static Value GetSetting(ClientContext &context);
219
+ };
220
+
191
221
  struct EnableObjectCacheSetting {
192
222
  static constexpr const char *Name = "enable_object_cache";
193
223
  static constexpr const char *Description = "Whether or not object cache is used to cache e.g. Parquet metadata";
@@ -24,12 +24,14 @@ public:
24
24
  }
25
25
 
26
26
  string filename;
27
+ string repository;
27
28
  LoadType load_type;
28
29
 
29
30
  public:
30
31
  unique_ptr<LoadInfo> Copy() const {
31
32
  auto result = make_uniq<LoadInfo>();
32
33
  result->filename = filename;
34
+ result->repository = repository;
33
35
  result->load_type = load_type;
34
36
  return result;
35
37
  }
@@ -37,6 +39,7 @@ public:
37
39
  void Serialize(Serializer &serializer) const {
38
40
  FieldWriter writer(serializer);
39
41
  writer.WriteString(filename);
42
+ writer.WriteString(repository);
40
43
  writer.WriteField<LoadType>(load_type);
41
44
  writer.Finalize();
42
45
  }
@@ -45,6 +48,7 @@ public:
45
48
  FieldReader reader(deserializer);
46
49
  auto load_info = make_uniq<LoadInfo>();
47
50
  load_info->filename = reader.ReadRequired<string>();
51
+ load_info->repository = reader.ReadRequired<string>();
48
52
  load_info->load_type = reader.ReadRequired<LoadType>();
49
53
  reader.Finalize();
50
54
  return std::move(load_info);
@@ -234,6 +234,10 @@ private:
234
234
  //! Move correlated expressions from the child binder to this binder
235
235
  void MoveCorrelatedExpressions(Binder &other);
236
236
 
237
+ //! Tries to bind the table name with replacement scans
238
+ unique_ptr<BoundTableRef> BindWithReplacementScan(ClientContext &context, const string &table_name,
239
+ BaseTableRef &ref);
240
+
237
241
  BoundStatement Bind(SelectStatement &stmt);
238
242
  BoundStatement Bind(InsertStatement &stmt);
239
243
  BoundStatement Bind(CopyStatement &stmt);