duckdb 0.7.2-dev3546.0 → 0.7.2-dev3710.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 (94) hide show
  1. package/package.json +1 -1
  2. package/src/database.cpp +1 -0
  3. package/src/duckdb/extension/json/buffered_json_reader.cpp +56 -17
  4. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +56 -31
  5. package/src/duckdb/extension/json/include/json_common.hpp +5 -4
  6. package/src/duckdb/extension/json/include/json_executors.hpp +13 -18
  7. package/src/duckdb/extension/json/include/json_functions.hpp +3 -0
  8. package/src/duckdb/extension/json/include/json_scan.hpp +106 -153
  9. package/src/duckdb/extension/json/include/json_transform.hpp +2 -2
  10. package/src/duckdb/extension/json/json_common.cpp +1 -1
  11. package/src/duckdb/extension/json/json_functions/copy_json.cpp +94 -38
  12. package/src/duckdb/extension/json/json_functions/json_contains.cpp +7 -8
  13. package/src/duckdb/extension/json/json_functions/json_create.cpp +7 -7
  14. package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +4 -4
  15. package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +4 -4
  16. package/src/duckdb/extension/json/json_functions/json_structure.cpp +7 -5
  17. package/src/duckdb/extension/json/json_functions/json_transform.cpp +11 -9
  18. package/src/duckdb/extension/json/json_functions/json_valid.cpp +1 -1
  19. package/src/duckdb/extension/json/json_functions/read_json.cpp +166 -169
  20. package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +37 -16
  21. package/src/duckdb/extension/json/json_functions.cpp +11 -4
  22. package/src/duckdb/extension/json/json_scan.cpp +593 -374
  23. package/src/duckdb/extension/parquet/parquet-extension.cpp +5 -0
  24. package/src/duckdb/src/common/exception.cpp +17 -0
  25. package/src/duckdb/src/common/exception_format_value.cpp +14 -0
  26. package/src/duckdb/src/common/file_system.cpp +78 -36
  27. package/src/duckdb/src/common/local_file_system.cpp +5 -16
  28. package/src/duckdb/src/common/types.cpp +1 -1
  29. package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +1 -1
  30. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +12 -6
  31. package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +10 -0
  32. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +2 -2
  33. package/src/duckdb/src/function/pragma/pragma_queries.cpp +6 -4
  34. package/src/duckdb/src/function/table/copy_csv.cpp +66 -12
  35. package/src/duckdb/src/function/table/read_csv.cpp +16 -3
  36. package/src/duckdb/src/function/table/version/pragma_version.cpp +8 -2
  37. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/column_dependency_manager.hpp +1 -1
  38. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +1 -1
  39. package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +1 -1
  40. package/src/duckdb/src/include/duckdb/common/exception.hpp +3 -3
  41. package/src/duckdb/src/include/duckdb/common/exception_format_value.hpp +26 -0
  42. package/src/duckdb/src/include/duckdb/common/file_system.hpp +11 -0
  43. package/src/duckdb/src/include/duckdb/common/http_state.hpp +2 -1
  44. package/src/duckdb/src/include/duckdb/common/hugeint.hpp +6 -6
  45. package/src/duckdb/src/include/duckdb/common/limits.hpp +46 -46
  46. package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +8 -8
  47. package/src/duckdb/src/include/duckdb/common/operator/comparison_operators.hpp +6 -6
  48. package/src/duckdb/src/include/duckdb/common/operator/convert_to_string.hpp +1 -1
  49. package/src/duckdb/src/include/duckdb/common/operator/decimal_cast_operators.hpp +2 -4
  50. package/src/duckdb/src/include/duckdb/common/operator/string_cast.hpp +1 -1
  51. package/src/duckdb/src/include/duckdb/common/operator/subtract.hpp +1 -1
  52. package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +1 -1
  53. package/src/duckdb/src/include/duckdb/common/re2_regex.hpp +1 -1
  54. package/src/duckdb/src/include/duckdb/common/string_util.hpp +25 -7
  55. package/src/duckdb/src/include/duckdb/common/types/chunk_collection.hpp +10 -10
  56. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +12 -12
  57. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection_iterators.hpp +2 -2
  58. package/src/duckdb/src/include/duckdb/common/types/value.hpp +1 -1
  59. package/src/duckdb/src/include/duckdb/common/types.hpp +2 -2
  60. package/src/duckdb/src/include/duckdb/common/winapi.hpp +1 -1
  61. package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +1 -1
  62. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +8 -3
  63. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +10 -14
  64. package/src/duckdb/src/include/duckdb/function/table_function.hpp +1 -1
  65. package/src/duckdb/src/include/duckdb/function/udf_function.hpp +56 -50
  66. package/src/duckdb/src/include/duckdb/main/appender.hpp +2 -2
  67. package/src/duckdb/src/include/duckdb/main/client_context.hpp +2 -2
  68. package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -1
  69. package/src/duckdb/src/include/duckdb/main/connection.hpp +8 -9
  70. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
  71. package/src/duckdb/src/include/duckdb/main/query_result.hpp +3 -3
  72. package/src/duckdb/src/include/duckdb/main/relation.hpp +6 -7
  73. package/src/duckdb/src/include/duckdb/optimizer/optimizer_extension.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/parser/column_list.hpp +7 -7
  75. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
  76. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +2 -2
  77. package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +5 -0
  78. package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +2 -2
  79. package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +1 -1
  80. package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +1 -1
  81. package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +2 -2
  82. package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +2 -2
  83. package/src/duckdb/src/main/db_instance_cache.cpp +5 -3
  84. package/src/duckdb/src/main/extension/extension_install.cpp +22 -18
  85. package/src/duckdb/src/parser/expression/collate_expression.cpp +1 -1
  86. package/src/duckdb/src/parser/keyword_helper.cpp +11 -1
  87. package/src/duckdb/src/parser/query_node/select_node.cpp +1 -1
  88. package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -2
  89. package/src/duckdb/src/parser/tableref.cpp +1 -1
  90. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +9 -4
  91. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +1 -1
  92. package/src/duckdb/src/storage/single_file_block_manager.cpp +0 -4
  93. package/src/duckdb/src/storage/storage_manager.cpp +3 -0
  94. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +5735 -5773
@@ -16,7 +16,7 @@ namespace duckdb {
16
16
  struct UDFWrapper {
17
17
  public:
18
18
  template <typename TR, typename... Args>
19
- static scalar_function_t CreateScalarFunction(const string &name, TR (*udf_func)(Args...)) {
19
+ inline static scalar_function_t CreateScalarFunction(const string &name, TR (*udf_func)(Args...)) {
20
20
  const std::size_t num_template_argc = sizeof...(Args);
21
21
  switch (num_template_argc) {
22
22
  case 1:
@@ -31,8 +31,8 @@ public:
31
31
  }
32
32
 
33
33
  template <typename TR, typename... Args>
34
- static scalar_function_t CreateScalarFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
35
- TR (*udf_func)(Args...)) {
34
+ inline static scalar_function_t CreateScalarFunction(const string &name, vector<LogicalType> args,
35
+ LogicalType ret_type, TR (*udf_func)(Args...)) {
36
36
  if (!TypesMatch<TR>(ret_type)) { // LCOV_EXCL_START
37
37
  throw std::runtime_error("Return type doesn't match with the first template type.");
38
38
  } // LCOV_EXCL_STOP
@@ -56,8 +56,8 @@ public:
56
56
  }
57
57
 
58
58
  template <typename TR, typename... Args>
59
- static void RegisterFunction(const string &name, scalar_function_t udf_function, ClientContext &context,
60
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID)) {
59
+ inline static void RegisterFunction(const string &name, scalar_function_t udf_function, ClientContext &context,
60
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID)) {
61
61
  vector<LogicalType> arguments;
62
62
  GetArgumentTypesRecursive<Args...>(arguments);
63
63
 
@@ -66,23 +66,24 @@ public:
66
66
  RegisterFunction(name, arguments, ret_type, udf_function, context, varargs);
67
67
  }
68
68
 
69
- DUCKDB_API static void RegisterFunction(string name, vector<LogicalType> args, LogicalType ret_type,
70
- scalar_function_t udf_function, ClientContext &context,
71
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
69
+ static void RegisterFunction(string name, vector<LogicalType> args, LogicalType ret_type,
70
+ scalar_function_t udf_function, ClientContext &context,
71
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
72
72
 
73
73
  //--------------------------------- Aggregate UDFs ------------------------------------//
74
74
  template <typename UDF_OP, typename STATE, typename TR, typename TA>
75
- static AggregateFunction CreateAggregateFunction(const string &name) {
75
+ inline static AggregateFunction CreateAggregateFunction(const string &name) {
76
76
  return CreateUnaryAggregateFunction<UDF_OP, STATE, TR, TA>(name);
77
77
  }
78
78
 
79
79
  template <typename UDF_OP, typename STATE, typename TR, typename TA, typename TB>
80
- static AggregateFunction CreateAggregateFunction(const string &name) {
80
+ inline static AggregateFunction CreateAggregateFunction(const string &name) {
81
81
  return CreateBinaryAggregateFunction<UDF_OP, STATE, TR, TA, TB>(name);
82
82
  }
83
83
 
84
84
  template <typename UDF_OP, typename STATE, typename TR, typename TA>
85
- static AggregateFunction CreateAggregateFunction(const string &name, LogicalType ret_type, LogicalType input_type) {
85
+ inline static AggregateFunction CreateAggregateFunction(const string &name, LogicalType ret_type,
86
+ LogicalType input_type) {
86
87
  if (!TypesMatch<TR>(ret_type)) { // LCOV_EXCL_START
87
88
  throw std::runtime_error("The return argument don't match!");
88
89
  } // LCOV_EXCL_STOP
@@ -95,8 +96,8 @@ public:
95
96
  }
96
97
 
97
98
  template <typename UDF_OP, typename STATE, typename TR, typename TA, typename TB>
98
- static AggregateFunction CreateAggregateFunction(const string &name, LogicalType ret_type, LogicalType input_typeA,
99
- LogicalType input_typeB) {
99
+ inline static AggregateFunction CreateAggregateFunction(const string &name, LogicalType ret_type,
100
+ LogicalType input_typeA, LogicalType input_typeB) {
100
101
  if (!TypesMatch<TR>(ret_type)) { // LCOV_EXCL_START
101
102
  throw std::runtime_error("The return argument don't match!");
102
103
  }
@@ -113,13 +114,12 @@ public:
113
114
  }
114
115
 
115
116
  //! A generic CreateAggregateFunction ---------------------------------------------------------------------------//
116
- static AggregateFunction CreateAggregateFunction(string name, vector<LogicalType> arguments,
117
- LogicalType return_type, aggregate_size_t state_size,
118
- aggregate_initialize_t initialize, aggregate_update_t update,
119
- aggregate_combine_t combine, aggregate_finalize_t finalize,
120
- aggregate_simple_update_t simple_update = nullptr,
121
- bind_aggregate_function_t bind = nullptr,
122
- aggregate_destructor_t destructor = nullptr) {
117
+ inline static AggregateFunction
118
+ CreateAggregateFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
119
+ aggregate_size_t state_size, aggregate_initialize_t initialize, aggregate_update_t update,
120
+ aggregate_combine_t combine, aggregate_finalize_t finalize,
121
+ aggregate_simple_update_t simple_update = nullptr, bind_aggregate_function_t bind = nullptr,
122
+ aggregate_destructor_t destructor = nullptr) {
123
123
 
124
124
  AggregateFunction aggr_function(std::move(name), std::move(arguments), std::move(return_type), state_size,
125
125
  initialize, update, combine, finalize, simple_update, bind, destructor);
@@ -127,8 +127,8 @@ public:
127
127
  return aggr_function;
128
128
  }
129
129
 
130
- DUCKDB_API static void RegisterAggrFunction(AggregateFunction aggr_function, ClientContext &context,
131
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
130
+ static void RegisterAggrFunction(AggregateFunction aggr_function, ClientContext &context,
131
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
132
132
 
133
133
  private:
134
134
  //-------------------------------- Templated functions --------------------------------//
@@ -142,7 +142,7 @@ private:
142
142
  };
143
143
 
144
144
  template <typename TR, typename TA>
145
- static scalar_function_t CreateUnaryFunction(const string &name, TR (*udf_func)(TA)) {
145
+ inline static scalar_function_t CreateUnaryFunction(const string &name, TR (*udf_func)(TA)) {
146
146
  scalar_function_t udf_function = [=](DataChunk &input, ExpressionState &state, Vector &result) -> void {
147
147
  UnaryExecutor::GenericExecute<TA, TR, UnaryUDFExecutor>(input.data[0], result, input.size(),
148
148
  (void *)udf_func);
@@ -151,7 +151,7 @@ private:
151
151
  }
152
152
 
153
153
  template <typename TR, typename TA, typename TB>
154
- static scalar_function_t CreateBinaryFunction(const string &name, TR (*udf_func)(TA, TB)) {
154
+ inline static scalar_function_t CreateBinaryFunction(const string &name, TR (*udf_func)(TA, TB)) {
155
155
  scalar_function_t udf_function = [=](DataChunk &input, ExpressionState &state, Vector &result) -> void {
156
156
  BinaryExecutor::Execute<TA, TB, TR>(input.data[0], input.data[1], result, input.size(), udf_func);
157
157
  };
@@ -159,7 +159,7 @@ private:
159
159
  }
160
160
 
161
161
  template <typename TR, typename TA, typename TB, typename TC>
162
- static scalar_function_t CreateTernaryFunction(const string &name, TR (*udf_func)(TA, TB, TC)) {
162
+ inline static scalar_function_t CreateTernaryFunction(const string &name, TR (*udf_func)(TA, TB, TC)) {
163
163
  scalar_function_t udf_function = [=](DataChunk &input, ExpressionState &state, Vector &result) -> void {
164
164
  TernaryExecutor::Execute<TA, TB, TC, TR>(input.data[0], input.data[1], input.data[2], result, input.size(),
165
165
  udf_func);
@@ -168,22 +168,25 @@ private:
168
168
  }
169
169
 
170
170
  template <typename TR, typename... Args>
171
- static scalar_function_t CreateUnaryFunction(const string &name, TR (*udf_func)(Args...)) { // LCOV_EXCL_START
171
+ inline static scalar_function_t CreateUnaryFunction(const string &name,
172
+ TR (*udf_func)(Args...)) { // LCOV_EXCL_START
172
173
  throw std::runtime_error("Incorrect number of arguments for unary function");
173
174
  } // LCOV_EXCL_STOP
174
175
 
175
176
  template <typename TR, typename... Args>
176
- static scalar_function_t CreateBinaryFunction(const string &name, TR (*udf_func)(Args...)) { // LCOV_EXCL_START
177
+ inline static scalar_function_t CreateBinaryFunction(const string &name,
178
+ TR (*udf_func)(Args...)) { // LCOV_EXCL_START
177
179
  throw std::runtime_error("Incorrect number of arguments for binary function");
178
180
  } // LCOV_EXCL_STOP
179
181
 
180
182
  template <typename TR, typename... Args>
181
- static scalar_function_t CreateTernaryFunction(const string &name, TR (*udf_func)(Args...)) { // LCOV_EXCL_START
183
+ inline static scalar_function_t CreateTernaryFunction(const string &name,
184
+ TR (*udf_func)(Args...)) { // LCOV_EXCL_START
182
185
  throw std::runtime_error("Incorrect number of arguments for ternary function");
183
186
  } // LCOV_EXCL_STOP
184
187
 
185
188
  template <typename T>
186
- static LogicalType GetArgumentType() {
189
+ inline static LogicalType GetArgumentType() {
187
190
  if (std::is_same<T, bool>()) {
188
191
  return LogicalType(LogicalTypeId::BOOLEAN);
189
192
  } else if (std::is_same<T, int8_t>()) {
@@ -206,13 +209,13 @@ private:
206
209
  }
207
210
 
208
211
  template <typename TA, typename TB, typename... Args>
209
- static void GetArgumentTypesRecursive(vector<LogicalType> &arguments) {
212
+ inline static void GetArgumentTypesRecursive(vector<LogicalType> &arguments) {
210
213
  arguments.push_back(GetArgumentType<TA>());
211
214
  GetArgumentTypesRecursive<TB, Args...>(arguments);
212
215
  }
213
216
 
214
217
  template <typename TA>
215
- static void GetArgumentTypesRecursive(vector<LogicalType> &arguments) {
218
+ inline static void GetArgumentTypesRecursive(vector<LogicalType> &arguments) {
216
219
  arguments.push_back(GetArgumentType<TA>());
217
220
  }
218
221
 
@@ -220,14 +223,15 @@ private:
220
223
  //-------------------------------- Argumented functions --------------------------------//
221
224
 
222
225
  template <typename TR, typename... Args>
223
- static scalar_function_t CreateUnaryFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
224
- TR (*udf_func)(Args...)) { // LCOV_EXCL_START
226
+ inline static scalar_function_t CreateUnaryFunction(const string &name, vector<LogicalType> args,
227
+ LogicalType ret_type,
228
+ TR (*udf_func)(Args...)) { // LCOV_EXCL_START
225
229
  throw std::runtime_error("Incorrect number of arguments for unary function");
226
230
  } // LCOV_EXCL_STOP
227
231
 
228
232
  template <typename TR, typename TA>
229
- static scalar_function_t CreateUnaryFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
230
- TR (*udf_func)(TA)) {
233
+ inline static scalar_function_t CreateUnaryFunction(const string &name, vector<LogicalType> args,
234
+ LogicalType ret_type, TR (*udf_func)(TA)) {
231
235
  if (args.size() != 1) { // LCOV_EXCL_START
232
236
  throw std::runtime_error("The number of LogicalType arguments (\"args\") should be 1!");
233
237
  }
@@ -243,14 +247,15 @@ private:
243
247
  }
244
248
 
245
249
  template <typename TR, typename... Args>
246
- static scalar_function_t CreateBinaryFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
247
- TR (*udf_func)(Args...)) { // LCOV_EXCL_START
250
+ inline static scalar_function_t CreateBinaryFunction(const string &name, vector<LogicalType> args,
251
+ LogicalType ret_type,
252
+ TR (*udf_func)(Args...)) { // LCOV_EXCL_START
248
253
  throw std::runtime_error("Incorrect number of arguments for binary function");
249
254
  } // LCOV_EXCL_STOP
250
255
 
251
256
  template <typename TR, typename TA, typename TB>
252
- static scalar_function_t CreateBinaryFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
253
- TR (*udf_func)(TA, TB)) {
257
+ inline static scalar_function_t CreateBinaryFunction(const string &name, vector<LogicalType> args,
258
+ LogicalType ret_type, TR (*udf_func)(TA, TB)) {
254
259
  if (args.size() != 2) { // LCOV_EXCL_START
255
260
  throw std::runtime_error("The number of LogicalType arguments (\"args\") should be 2!");
256
261
  }
@@ -268,14 +273,15 @@ private:
268
273
  }
269
274
 
270
275
  template <typename TR, typename... Args>
271
- static scalar_function_t CreateTernaryFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
272
- TR (*udf_func)(Args...)) { // LCOV_EXCL_START
276
+ inline static scalar_function_t CreateTernaryFunction(const string &name, vector<LogicalType> args,
277
+ LogicalType ret_type,
278
+ TR (*udf_func)(Args...)) { // LCOV_EXCL_START
273
279
  throw std::runtime_error("Incorrect number of arguments for ternary function");
274
280
  } // LCOV_EXCL_STOP
275
281
 
276
282
  template <typename TR, typename TA, typename TB, typename TC>
277
- static scalar_function_t CreateTernaryFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
278
- TR (*udf_func)(TA, TB, TC)) {
283
+ inline static scalar_function_t CreateTernaryFunction(const string &name, vector<LogicalType> args,
284
+ LogicalType ret_type, TR (*udf_func)(TA, TB, TC)) {
279
285
  if (args.size() != 3) { // LCOV_EXCL_START
280
286
  throw std::runtime_error("The number of LogicalType arguments (\"args\") should be 3!");
281
287
  }
@@ -297,7 +303,7 @@ private:
297
303
  }
298
304
 
299
305
  template <typename T>
300
- static bool TypesMatch(const LogicalType &sql_type) {
306
+ inline static bool TypesMatch(const LogicalType &sql_type) {
301
307
  switch (sql_type.id()) {
302
308
  case LogicalTypeId::BOOLEAN:
303
309
  return std::is_same<T, bool>();
@@ -336,15 +342,15 @@ private:
336
342
  private:
337
343
  //-------------------------------- Aggregate functions --------------------------------//
338
344
  template <typename UDF_OP, typename STATE, typename TR, typename TA>
339
- static AggregateFunction CreateUnaryAggregateFunction(const string &name) {
345
+ inline static AggregateFunction CreateUnaryAggregateFunction(const string &name) {
340
346
  LogicalType return_type = GetArgumentType<TR>();
341
347
  LogicalType input_type = GetArgumentType<TA>();
342
348
  return CreateUnaryAggregateFunction<UDF_OP, STATE, TR, TA>(name, return_type, input_type);
343
349
  }
344
350
 
345
351
  template <typename UDF_OP, typename STATE, typename TR, typename TA>
346
- static AggregateFunction CreateUnaryAggregateFunction(const string &name, LogicalType ret_type,
347
- LogicalType input_type) {
352
+ inline static AggregateFunction CreateUnaryAggregateFunction(const string &name, LogicalType ret_type,
353
+ LogicalType input_type) {
348
354
  AggregateFunction aggr_function =
349
355
  AggregateFunction::UnaryAggregate<STATE, TR, TA, UDF_OP>(input_type, ret_type);
350
356
  aggr_function.name = name;
@@ -352,7 +358,7 @@ private:
352
358
  }
353
359
 
354
360
  template <typename UDF_OP, typename STATE, typename TR, typename TA, typename TB>
355
- static AggregateFunction CreateBinaryAggregateFunction(const string &name) {
361
+ inline static AggregateFunction CreateBinaryAggregateFunction(const string &name) {
356
362
  LogicalType return_type = GetArgumentType<TR>();
357
363
  LogicalType input_typeA = GetArgumentType<TA>();
358
364
  LogicalType input_typeB = GetArgumentType<TB>();
@@ -360,8 +366,8 @@ private:
360
366
  }
361
367
 
362
368
  template <typename UDF_OP, typename STATE, typename TR, typename TA, typename TB>
363
- static AggregateFunction CreateBinaryAggregateFunction(const string &name, LogicalType ret_type,
364
- LogicalType input_typeA, LogicalType input_typeB) {
369
+ inline static AggregateFunction CreateBinaryAggregateFunction(const string &name, LogicalType ret_type,
370
+ LogicalType input_typeA, LogicalType input_typeB) {
365
371
  AggregateFunction aggr_function =
366
372
  AggregateFunction::BinaryAggregate<STATE, TR, TA, TB, UDF_OP>(input_typeA, input_typeB, ret_type);
367
373
  aggr_function.name = name;
@@ -77,10 +77,10 @@ public:
77
77
  //! Flush the changes made by the appender and close it. The appender cannot be used after this point
78
78
  DUCKDB_API void Close();
79
79
 
80
- DUCKDB_API vector<LogicalType> &GetTypes() {
80
+ vector<LogicalType> &GetTypes() {
81
81
  return types;
82
82
  }
83
- DUCKDB_API idx_t CurrentColumn() {
83
+ idx_t CurrentColumn() {
84
84
  return column;
85
85
  }
86
86
  DUCKDB_API void AppendDataChunk(DataChunk &value);
@@ -86,7 +86,7 @@ public:
86
86
  TransactionContext transaction;
87
87
 
88
88
  public:
89
- DUCKDB_API MetaTransaction &ActiveTransaction() {
89
+ MetaTransaction &ActiveTransaction() {
90
90
  return transaction.ActiveTransaction();
91
91
  }
92
92
 
@@ -276,7 +276,7 @@ private:
276
276
 
277
277
  class ClientContextWrapper {
278
278
  public:
279
- DUCKDB_API explicit ClientContextWrapper(const shared_ptr<ClientContext> &context)
279
+ explicit ClientContextWrapper(const shared_ptr<ClientContext> &context)
280
280
  : client_context(context) {
281
281
 
282
282
  };
@@ -63,7 +63,9 @@ struct ClientData {
63
63
  string file_search_path;
64
64
 
65
65
  //! The Max Line Length Size of Last Query Executed on a CSV File. (Only used for testing)
66
- idx_t max_line_length = 0;
66
+ //! FIXME: this should not be done like this
67
+ bool debug_set_max_line_length = false;
68
+ idx_t debug_max_line_length = 0;
67
69
 
68
70
  public:
69
71
  DUCKDB_API static ClientData &Get(ClientContext &context);
@@ -180,8 +180,8 @@ public:
180
180
  UDFWrapper::RegisterFunction<TR, Args...>(name, udf_func, *context, std::move(varargs));
181
181
  }
182
182
 
183
- DUCKDB_API void CreateVectorizedFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
184
- scalar_function_t udf_func, LogicalType varargs = LogicalType::INVALID) {
183
+ void CreateVectorizedFunction(const string &name, vector<LogicalType> args, LogicalType ret_type,
184
+ scalar_function_t udf_func, LogicalType varargs = LogicalType::INVALID) {
185
185
  UDFWrapper::RegisterFunction(name, std::move(args), std::move(ret_type), udf_func, *context,
186
186
  std::move(varargs));
187
187
  }
@@ -214,13 +214,12 @@ public:
214
214
  UDFWrapper::RegisterAggrFunction(function, *context);
215
215
  }
216
216
 
217
- DUCKDB_API void CreateAggregateFunction(const string &name, vector<LogicalType> arguments, LogicalType return_type,
218
- aggregate_size_t state_size, aggregate_initialize_t initialize,
219
- aggregate_update_t update, aggregate_combine_t combine,
220
- aggregate_finalize_t finalize,
221
- aggregate_simple_update_t simple_update = nullptr,
222
- bind_aggregate_function_t bind = nullptr,
223
- aggregate_destructor_t destructor = nullptr) {
217
+ void CreateAggregateFunction(const string &name, vector<LogicalType> arguments, LogicalType return_type,
218
+ aggregate_size_t state_size, aggregate_initialize_t initialize,
219
+ aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize,
220
+ aggregate_simple_update_t simple_update = nullptr,
221
+ bind_aggregate_function_t bind = nullptr,
222
+ aggregate_destructor_t destructor = nullptr) {
224
223
  AggregateFunction function =
225
224
  UDFWrapper::CreateAggregateFunction(name, arguments, return_type, state_size, initialize, update, combine,
226
225
  finalize, simple_update, bind, destructor);
@@ -70,6 +70,7 @@ static constexpr ExtensionEntry EXTENSION_FUNCTIONS[] = {
70
70
  {"read_json", "json"},
71
71
  {"read_json_auto", "json"},
72
72
  {"read_json_objects", "json"},
73
+ {"read_json_objects_auto", "json"},
73
74
  {"read_ndjson", "json"},
74
75
  {"read_ndjson_auto", "json"},
75
76
  {"read_ndjson_objects", "json"},
@@ -108,7 +108,7 @@ public:
108
108
  //! Fetch() until both results are exhausted. The data in the results will be lost.
109
109
  DUCKDB_API bool Equals(QueryResult &other);
110
110
 
111
- DUCKDB_API bool TryFetch(unique_ptr<DataChunk> &result, PreservedError &error) {
111
+ bool TryFetch(unique_ptr<DataChunk> &result, PreservedError &error) {
112
112
  try {
113
113
  result = Fetch();
114
114
  return success;
@@ -191,10 +191,10 @@ private:
191
191
  };
192
192
 
193
193
  public:
194
- DUCKDB_API QueryResultIterator begin() {
194
+ QueryResultIterator begin() {
195
195
  return QueryResultIterator(this);
196
196
  }
197
- DUCKDB_API QueryResultIterator end() {
197
+ QueryResultIterator end() {
198
198
  return QueryResultIterator(nullptr);
199
199
  }
200
200
 
@@ -32,12 +32,11 @@ class TableRef;
32
32
 
33
33
  class Relation : public std::enable_shared_from_this<Relation> {
34
34
  public:
35
- DUCKDB_API Relation(const std::shared_ptr<ClientContext> &context, RelationType type)
36
- : context(context), type(type) {
35
+ Relation(const std::shared_ptr<ClientContext> &context, RelationType type) : context(context), type(type) {
37
36
  }
38
- DUCKDB_API Relation(ClientContextWrapper &context, RelationType type) : context(context.GetContext()), type(type) {
37
+ Relation(ClientContextWrapper &context, RelationType type) : context(context.GetContext()), type(type) {
39
38
  }
40
- DUCKDB_API virtual ~Relation() {
39
+ virtual ~Relation() {
41
40
  }
42
41
 
43
42
  ClientContextWrapper context;
@@ -70,7 +69,7 @@ public:
70
69
  DUCKDB_API unique_ptr<QueryResult> Explain(ExplainType type = ExplainType::EXPLAIN_STANDARD);
71
70
 
72
71
  DUCKDB_API virtual unique_ptr<TableRef> GetTableRef();
73
- DUCKDB_API virtual bool IsReadOnly() {
72
+ virtual bool IsReadOnly() {
74
73
  return true;
75
74
  }
76
75
 
@@ -154,10 +153,10 @@ public:
154
153
 
155
154
  public:
156
155
  //! Whether or not the relation inherits column bindings from its child or not, only relevant for binding
157
- DUCKDB_API virtual bool InheritsColumnBindings() {
156
+ virtual bool InheritsColumnBindings() {
158
157
  return false;
159
158
  }
160
- DUCKDB_API virtual Relation *ChildRelation() {
159
+ virtual Relation *ChildRelation() {
161
160
  return nullptr;
162
161
  }
163
162
  DUCKDB_API vector<shared_ptr<ExternalDependency>> GetAllDependencies();
@@ -15,7 +15,7 @@ namespace duckdb {
15
15
 
16
16
  //! The OptimizerExtensionInfo holds static information relevant to the optimizer extension
17
17
  struct OptimizerExtensionInfo {
18
- DUCKDB_API virtual ~OptimizerExtensionInfo() {
18
+ virtual ~OptimizerExtensionInfo() {
19
19
  }
20
20
  };
21
21
 
@@ -76,7 +76,7 @@ public:
76
76
  // logical iterator
77
77
  class ColumnListIterator {
78
78
  public:
79
- DUCKDB_API ColumnListIterator(const ColumnList &list, bool physical) : list(list), physical(physical) {
79
+ ColumnListIterator(const ColumnList &list, bool physical) : list(list), physical(physical) {
80
80
  }
81
81
 
82
82
  private:
@@ -86,7 +86,7 @@ public:
86
86
  private:
87
87
  class ColumnLogicalIteratorInternal {
88
88
  public:
89
- DUCKDB_API ColumnLogicalIteratorInternal(const ColumnList &list, bool physical, idx_t pos, idx_t end)
89
+ ColumnLogicalIteratorInternal(const ColumnList &list, bool physical, idx_t pos, idx_t end)
90
90
  : list(list), physical(physical), pos(pos), end(end) {
91
91
  }
92
92
 
@@ -96,14 +96,14 @@ public:
96
96
  idx_t end;
97
97
 
98
98
  public:
99
- DUCKDB_API ColumnLogicalIteratorInternal &operator++() {
99
+ ColumnLogicalIteratorInternal &operator++() {
100
100
  pos++;
101
101
  return *this;
102
102
  }
103
- DUCKDB_API bool operator!=(const ColumnLogicalIteratorInternal &other) const {
103
+ bool operator!=(const ColumnLogicalIteratorInternal &other) const {
104
104
  return pos != other.pos || end != other.end || &list != &other.list;
105
105
  }
106
- DUCKDB_API const ColumnDefinition &operator*() const {
106
+ const ColumnDefinition &operator*() const {
107
107
  if (physical) {
108
108
  return list.GetColumn(PhysicalIndex(pos));
109
109
  } else {
@@ -117,10 +117,10 @@ public:
117
117
  return physical ? list.PhysicalColumnCount() : list.LogicalColumnCount();
118
118
  }
119
119
 
120
- DUCKDB_API ColumnLogicalIteratorInternal begin() {
120
+ ColumnLogicalIteratorInternal begin() {
121
121
  return ColumnLogicalIteratorInternal(list, physical, 0, Size());
122
122
  }
123
- DUCKDB_API ColumnLogicalIteratorInternal end() {
123
+ ColumnLogicalIteratorInternal end() {
124
124
  return ColumnLogicalIteratorInternal(list, physical, Size(), Size());
125
125
  }
126
126
  };
@@ -92,7 +92,7 @@ public:
92
92
  result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
93
93
  return child->alias.empty() || !add_alias
94
94
  ? child->ToString()
95
- : KeywordHelper::WriteOptionallyQuoted(child->alias) + " := " + child->ToString();
95
+ : StringUtil::Format("%s := %s", SQLIdentifier(child->alias), child->ToString());
96
96
  });
97
97
  // ordered aggregate
98
98
  if (order_bys && !order_bys->orders.empty()) {
@@ -96,8 +96,8 @@ public:
96
96
  auto child_string = entry.children[1]->ToString();
97
97
  D_ASSERT(child_string.size() >= 3);
98
98
  D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
99
- return "(" + entry.children[0]->ToString() + ")." +
100
- KeywordHelper::WriteOptionallyQuoted(child_string.substr(1, child_string.size() - 2));
99
+ return StringUtil::Format("(%s).%s", entry.children[0]->ToString(),
100
+ SQLIdentifier(child_string.substr(1, child_string.size() - 2)));
101
101
  }
102
102
  case ExpressionType::ARRAY_CONSTRUCTOR: {
103
103
  string result = "(ARRAY[";
@@ -17,9 +17,14 @@ public:
17
17
  //! Returns true if the given text matches a keyword of the parser
18
18
  static bool IsKeyword(const string &text);
19
19
 
20
+ static string EscapeQuotes(const string &text, char quote = '"');
21
+
20
22
  //! Returns true if the given string needs to be quoted when written as an identifier
21
23
  static bool RequiresQuotes(const string &text, bool allow_caps = true);
22
24
 
25
+ //! Writes a string that is quoted
26
+ static string WriteQuoted(const string &text, char quote = '\'');
27
+
23
28
  //! Writes a string that is optionally quoted + escaped so it can be used as an identifier
24
29
  static string WriteOptionallyQuoted(const string &text, char quote = '"', bool allow_caps = true);
25
30
  };
@@ -17,7 +17,7 @@ namespace duckdb {
17
17
  //! The ParserExtensionInfo holds static information relevant to the parser extension
18
18
  //! It is made available in the parse_function, and will be kept alive as long as the database system is kept alive
19
19
  struct ParserExtensionInfo {
20
- DUCKDB_API virtual ~ParserExtensionInfo() {
20
+ virtual ~ParserExtensionInfo() {
21
21
  }
22
22
  };
23
23
 
@@ -29,7 +29,7 @@ enum class ParserExtensionResultType : uint8_t { PARSE_SUCCESSFUL, DISPLAY_ORIGI
29
29
  //! The ParserExtensionParseData holds the result of a successful parse step
30
30
  //! It will be passed along to the subsequent plan function
31
31
  struct ParserExtensionParseData {
32
- DUCKDB_API virtual ~ParserExtensionParseData() {
32
+ virtual ~ParserExtensionParseData() {
33
33
  }
34
34
 
35
35
  virtual unique_ptr<ParserExtensionParseData> Copy() const = 0;
@@ -41,7 +41,7 @@ protected:
41
41
  SQLStatement(const SQLStatement &other) = default;
42
42
 
43
43
  public:
44
- DUCKDB_API virtual string ToString() const {
44
+ virtual string ToString() const {
45
45
  throw InternalException("ToString not supported for this type of SQLStatement: '%s'",
46
46
  StatementTypeToString(type));
47
47
  }
@@ -26,7 +26,7 @@ public:
26
26
  static constexpr const StatementType TYPE = StatementType::SELECT_STATEMENT;
27
27
 
28
28
  public:
29
- DUCKDB_API SelectStatement() : SQLStatement(StatementType::SELECT_STATEMENT) {
29
+ SelectStatement() : SQLStatement(StatementType::SELECT_STATEMENT) {
30
30
  }
31
31
 
32
32
  //! The main query node
@@ -16,7 +16,7 @@ namespace duckdb {
16
16
 
17
17
  //! The OperatorExtensionInfo holds static information relevant to the operator extension
18
18
  struct OperatorExtensionInfo {
19
- DUCKDB_API virtual ~OperatorExtensionInfo() {
19
+ virtual ~OperatorExtensionInfo() {
20
20
  }
21
21
  };
22
22
 
@@ -37,7 +37,7 @@ public:
37
37
  virtual unique_ptr<LogicalExtensionOperator> Deserialize(LogicalDeserializationState &state,
38
38
  FieldReader &reader) = 0;
39
39
 
40
- DUCKDB_API virtual ~OperatorExtension() {
40
+ virtual ~OperatorExtension() {
41
41
  }
42
42
  };
43
43
 
@@ -20,7 +20,7 @@ class TransactionManager;
20
20
 
21
21
  //! The StorageExtensionInfo holds static information relevant to the storage extension
22
22
  struct StorageExtensionInfo {
23
- DUCKDB_API virtual ~StorageExtensionInfo() {
23
+ virtual ~StorageExtensionInfo() {
24
24
  }
25
25
  };
26
26
 
@@ -43,7 +43,7 @@ public:
43
43
  //! Additional info passed to the various storage functions
44
44
  shared_ptr<StorageExtensionInfo> storage_info;
45
45
 
46
- DUCKDB_API virtual ~StorageExtension() {
46
+ virtual ~StorageExtension() {
47
47
  }
48
48
  };
49
49
 
@@ -1,8 +1,10 @@
1
1
  #include "duckdb/main/db_instance_cache.hpp"
2
2
  #include "duckdb/main/extension_helper.hpp"
3
+
3
4
  namespace duckdb {
4
5
 
5
- string GetDBAbsolutePath(const string &database) {
6
+ string GetDBAbsolutePath(const string &database_p) {
7
+ auto database = FileSystem::ExpandPath(database_p, nullptr);
6
8
  if (database.empty()) {
7
9
  return ":memory:";
8
10
  }
@@ -15,9 +17,9 @@ string GetDBAbsolutePath(const string &database) {
15
17
  return database;
16
18
  }
17
19
  if (FileSystem::IsPathAbsolute(database)) {
18
- return database;
20
+ return FileSystem::NormalizeAbsolutePath(database);
19
21
  }
20
- return FileSystem::JoinPath(FileSystem::GetWorkingDirectory(), database);
22
+ return FileSystem::NormalizeAbsolutePath(FileSystem::JoinPath(FileSystem::GetWorkingDirectory(), database));
21
23
  }
22
24
 
23
25
  shared_ptr<DuckDB> DBInstanceCache::GetInstanceInternal(const string &database, const DBConfig &config) {