duckdb 0.6.2-dev1114.0 → 0.6.2-dev1124.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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.6.2-dev1114.0",
5
+ "version": "0.6.2-dev1124.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -1,6 +1,10 @@
1
1
  #include "duckdb/execution/operator/schema/physical_drop.hpp"
2
2
  #include "duckdb/main/client_data.hpp"
3
3
  #include "duckdb/main/database_manager.hpp"
4
+ #include "duckdb/main/database.hpp"
5
+ #include "duckdb/main/client_context.hpp"
6
+ #include "duckdb/catalog/catalog_search_path.hpp"
7
+ #include "duckdb/main/settings.hpp"
4
8
 
5
9
  namespace duckdb {
6
10
 
@@ -39,6 +43,24 @@ void PhysicalDrop::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSo
39
43
  db_manager.DetachDatabase(context.client, info->name, info->if_exists);
40
44
  break;
41
45
  }
46
+ case CatalogType::SCHEMA_ENTRY: {
47
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
48
+ catalog.DropEntry(context.client, info.get());
49
+ auto qualified_name = QualifiedName::Parse(info->name);
50
+
51
+ // Check if the dropped schema was set as the current schema
52
+ auto &client_data = ClientData::Get(context.client);
53
+ auto &default_entry = client_data.catalog_search_path->GetDefault();
54
+ auto &current_catalog = default_entry.catalog;
55
+ auto &current_schema = default_entry.schema;
56
+ D_ASSERT(info->name != DEFAULT_SCHEMA);
57
+
58
+ if (info->catalog == current_catalog && current_schema == info->name) {
59
+ // Reset the schema to default
60
+ SchemaSetting::SetLocal(context.client, DEFAULT_SCHEMA);
61
+ }
62
+ break;
63
+ }
42
64
  default: {
43
65
  auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
44
66
  catalog.DropEntry(context.client, info.get());
@@ -7,33 +7,54 @@
7
7
 
8
8
  namespace duckdb {
9
9
 
10
- template <class T, class T2>
11
- struct ArgMinMaxState {
12
- T arg;
13
- T2 value;
10
+ struct ArgMinMaxStateBase {
11
+ ArgMinMaxStateBase() : is_initialized(false) {
12
+ }
13
+
14
+ template <class T>
15
+ static inline void CreateValue(T &value) {
16
+ }
17
+
18
+ template <class T>
19
+ static inline void DestroyValue(T &value) {
20
+ }
21
+
22
+ template <class T>
23
+ static inline void AssignValue(T &target, T new_value, bool is_initialized) {
24
+ target = new_value;
25
+ }
26
+
27
+ template <typename T>
28
+ static inline void ReadValue(Vector &result, T &arg, T *target, idx_t idx) {
29
+ target[idx] = arg;
30
+ }
31
+
14
32
  bool is_initialized;
15
33
  };
16
34
 
17
- template <class T>
18
- static void ArgMinMaxDestroyValue(T value) {
35
+ // Out-of-line specialisations
36
+ template <>
37
+ void ArgMinMaxStateBase::CreateValue(Vector *&value) {
38
+ value = nullptr;
19
39
  }
20
40
 
21
41
  template <>
22
- void ArgMinMaxDestroyValue(string_t value) {
42
+ void ArgMinMaxStateBase::DestroyValue(string_t &value) {
23
43
  if (!value.IsInlined()) {
24
44
  delete[] value.GetDataUnsafe();
25
45
  }
26
46
  }
27
47
 
28
- template <class T>
29
- static void ArgMinMaxAssignValue(T &target, T new_value, bool is_initialized) {
30
- target = new_value;
48
+ template <>
49
+ void ArgMinMaxStateBase::DestroyValue(Vector *&value) {
50
+ delete value;
51
+ value = nullptr;
31
52
  }
32
53
 
33
54
  template <>
34
- void ArgMinMaxAssignValue(string_t &target, string_t new_value, bool is_initialized) {
55
+ void ArgMinMaxStateBase::AssignValue(string_t &target, string_t new_value, bool is_initialized) {
35
56
  if (is_initialized) {
36
- ArgMinMaxDestroyValue(target);
57
+ DestroyValue(target);
37
58
  }
38
59
  if (new_value.IsInlined()) {
39
60
  target = new_value;
@@ -47,27 +68,51 @@ void ArgMinMaxAssignValue(string_t &target, string_t new_value, bool is_initiali
47
68
  }
48
69
  }
49
70
 
71
+ template <>
72
+ void ArgMinMaxStateBase::ReadValue(Vector &result, string_t &arg, string_t *target, idx_t idx) {
73
+ target[idx] = StringVector::AddStringOrBlob(result, arg);
74
+ }
75
+
76
+ template <class A, class B>
77
+ struct ArgMinMaxState : public ArgMinMaxStateBase {
78
+ using ARG_TYPE = A;
79
+ using BY_TYPE = B;
80
+
81
+ ARG_TYPE arg;
82
+ BY_TYPE value;
83
+
84
+ ArgMinMaxState() {
85
+ CreateValue(arg);
86
+ CreateValue(value);
87
+ }
88
+
89
+ ~ArgMinMaxState() {
90
+ if (is_initialized) {
91
+ DestroyValue(arg);
92
+ DestroyValue(value);
93
+ is_initialized = false;
94
+ }
95
+ }
96
+ };
97
+
50
98
  template <class COMPARATOR>
51
99
  struct ArgMinMaxBase {
52
100
  template <class STATE>
53
101
  static void Destroy(STATE *state) {
54
- if (state->is_initialized) {
55
- ArgMinMaxDestroyValue(state->arg);
56
- ArgMinMaxDestroyValue(state->value);
57
- }
102
+ state->~STATE();
58
103
  }
59
104
 
60
105
  template <class STATE>
61
106
  static void Initialize(STATE *state) {
62
- state->is_initialized = false;
107
+ new (state) STATE;
63
108
  }
64
109
 
65
110
  template <class A_TYPE, class B_TYPE, class STATE, class OP>
66
111
  static void Operation(STATE *state, AggregateInputData &, A_TYPE *x_data, B_TYPE *y_data, ValidityMask &amask,
67
112
  ValidityMask &bmask, idx_t xidx, idx_t yidx) {
68
113
  if (!state->is_initialized) {
69
- ArgMinMaxAssignValue<A_TYPE>(state->arg, x_data[xidx], false);
70
- ArgMinMaxAssignValue<B_TYPE>(state->value, y_data[yidx], false);
114
+ STATE::template AssignValue<A_TYPE>(state->arg, x_data[xidx], false);
115
+ STATE::template AssignValue<B_TYPE>(state->value, y_data[yidx], false);
71
116
  state->is_initialized = true;
72
117
  } else {
73
118
  OP::template Execute<A_TYPE, B_TYPE, STATE>(state, x_data[xidx], y_data[yidx]);
@@ -77,8 +122,8 @@ struct ArgMinMaxBase {
77
122
  template <class A_TYPE, class B_TYPE, class STATE>
78
123
  static void Execute(STATE *state, A_TYPE x_data, B_TYPE y_data) {
79
124
  if (COMPARATOR::Operation(y_data, state->value)) {
80
- ArgMinMaxAssignValue<A_TYPE>(state->arg, x_data, true);
81
- ArgMinMaxAssignValue<B_TYPE>(state->value, y_data, true);
125
+ STATE::template AssignValue<A_TYPE>(state->arg, x_data, true);
126
+ STATE::template AssignValue<B_TYPE>(state->value, y_data, true);
82
127
  }
83
128
  }
84
129
 
@@ -88,97 +133,213 @@ struct ArgMinMaxBase {
88
133
  return;
89
134
  }
90
135
  if (!target->is_initialized || COMPARATOR::Operation(source.value, target->value)) {
91
- ArgMinMaxAssignValue(target->arg, source.arg, target->is_initialized);
92
- ArgMinMaxAssignValue(target->value, source.value, target->is_initialized);
136
+ STATE::template AssignValue(target->arg, source.arg, target->is_initialized);
137
+ STATE::template AssignValue(target->value, source.value, target->is_initialized);
93
138
  target->is_initialized = true;
94
139
  }
95
140
  }
96
141
 
97
- static bool IgnoreNull() {
98
- return true;
99
- }
100
- };
101
-
102
- template <class COMPARATOR>
103
- struct StringArgMinMax : public ArgMinMaxBase<COMPARATOR> {
104
142
  template <class T, class STATE>
105
143
  static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
106
144
  if (!state->is_initialized) {
107
145
  mask.SetInvalid(idx);
108
146
  } else {
109
- target[idx] = StringVector::AddStringOrBlob(result, state->arg);
147
+ STATE::template ReadValue(result, state->arg, target, idx);
110
148
  }
111
149
  }
150
+
151
+ static bool IgnoreNull() {
152
+ return true;
153
+ }
112
154
  };
113
155
 
114
- template <class COMPARATOR>
115
- struct NumericArgMinMax : public ArgMinMaxBase<COMPARATOR> {
156
+ template <typename COMPARATOR>
157
+ struct VectorArgMinMaxBase : ArgMinMaxBase<COMPARATOR> {
158
+ template <class STATE>
159
+ static void AssignVector(STATE *state, Vector &arg, const idx_t idx) {
160
+ if (!state->is_initialized) {
161
+ state->arg = new Vector(arg.GetType());
162
+ state->arg->SetVectorType(VectorType::CONSTANT_VECTOR);
163
+ }
164
+ sel_t selv = idx;
165
+ SelectionVector sel(&selv);
166
+ VectorOperations::Copy(arg, *state->arg, sel, 1, 0, 0);
167
+ }
168
+
169
+ template <class STATE>
170
+ static void Update(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector, idx_t count) {
171
+ auto &arg = inputs[0];
172
+ UnifiedVectorFormat adata;
173
+ arg.ToUnifiedFormat(count, adata);
174
+
175
+ using BY_TYPE = typename STATE::BY_TYPE;
176
+ auto &by = inputs[1];
177
+ UnifiedVectorFormat bdata;
178
+ by.ToUnifiedFormat(count, bdata);
179
+ const auto bys = (BY_TYPE *)bdata.data;
180
+
181
+ UnifiedVectorFormat sdata;
182
+ state_vector.ToUnifiedFormat(count, sdata);
183
+
184
+ auto states = (STATE **)sdata.data;
185
+ for (idx_t i = 0; i < count; i++) {
186
+ const auto aidx = adata.sel->get_index(i);
187
+ const auto bidx = bdata.sel->get_index(i);
188
+ if (!bdata.validity.RowIsValid(bidx)) {
189
+ continue;
190
+ }
191
+ const auto bval = bys[bidx];
192
+
193
+ const auto sidx = sdata.sel->get_index(i);
194
+ auto state = states[sidx];
195
+ if (!state->is_initialized) {
196
+ STATE::template AssignValue<BY_TYPE>(state->value, bval, false);
197
+ AssignVector(state, arg, aidx);
198
+ state->is_initialized = true;
199
+
200
+ } else if (COMPARATOR::template Operation<BY_TYPE>(bval, state->value)) {
201
+ STATE::template AssignValue<BY_TYPE>(state->value, bval, true);
202
+ AssignVector(state, arg, aidx);
203
+ }
204
+ }
205
+ }
206
+
207
+ template <class STATE, class OP>
208
+ static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
209
+ if (!source.is_initialized) {
210
+ return;
211
+ }
212
+ if (!target->is_initialized || COMPARATOR::Operation(source.value, target->value)) {
213
+ STATE::template AssignValue(target->value, source.value, target->is_initialized);
214
+ AssignVector(target, *source.arg, 0);
215
+ target->is_initialized = true;
216
+ }
217
+ }
218
+
116
219
  template <class T, class STATE>
117
220
  static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
118
221
  if (!state->is_initialized) {
119
- mask.SetInvalid(idx);
222
+ // we need to use SetNull here
223
+ // since for STRUCT columns only setting the validity mask of the struct is incorrect
224
+ // as for a struct column, we need to also set ALL child columns to NULL
225
+ switch (result.GetVectorType()) {
226
+ case VectorType::FLAT_VECTOR:
227
+ FlatVector::SetNull(result, idx, true);
228
+ break;
229
+ case VectorType::CONSTANT_VECTOR:
230
+ ConstantVector::SetNull(result, true);
231
+ break;
232
+ default:
233
+ throw InternalException("Invalid result vector type for nested arg_min/max");
234
+ }
120
235
  } else {
121
- target[idx] = state->arg;
236
+ VectorOperations::Copy(*state->arg, result, 1, 0, idx);
122
237
  }
123
238
  }
239
+
240
+ static unique_ptr<FunctionData> Bind(ClientContext &context, AggregateFunction &function,
241
+ vector<unique_ptr<Expression>> &arguments) {
242
+ function.arguments[0] = arguments[0]->return_type;
243
+ function.return_type = arguments[0]->return_type;
244
+ return nullptr;
245
+ }
124
246
  };
125
247
 
126
- using NumericArgMinOperation = NumericArgMinMax<LessThan>;
127
- using NumericArgMaxOperation = NumericArgMinMax<GreaterThan>;
128
- using StringArgMinOperation = StringArgMinMax<LessThan>;
129
- using StringArgMaxOperation = StringArgMinMax<GreaterThan>;
248
+ template <class OP, class ARG_TYPE, class BY_TYPE>
249
+ AggregateFunction GetVectorArgMinMaxFunctionInternal(const LogicalType &by_type, const LogicalType &type) {
250
+ using STATE = ArgMinMaxState<ARG_TYPE, BY_TYPE>;
251
+ return AggregateFunction({type, by_type}, type, AggregateFunction::StateSize<STATE>,
252
+ AggregateFunction::StateInitialize<STATE, OP>, OP::template Update<STATE>,
253
+ AggregateFunction::StateCombine<STATE, OP>,
254
+ AggregateFunction::StateFinalize<STATE, void, OP>, nullptr, OP::Bind,
255
+ AggregateFunction::StateDestroy<STATE, OP>);
256
+ }
130
257
 
131
- template <class OP, class T, class T2>
132
- AggregateFunction GetArgMinMaxFunctionInternal(const LogicalType &arg_2, const LogicalType &arg) {
133
- auto function = AggregateFunction::BinaryAggregate<ArgMinMaxState<T, T2>, T, T2, T, OP>(arg, arg_2, arg);
134
- if (arg.InternalType() == PhysicalType::VARCHAR || arg_2.InternalType() == PhysicalType::VARCHAR) {
135
- function.destructor = AggregateFunction::StateDestroy<ArgMinMaxState<T, T2>, OP>;
258
+ template <class OP, class ARG_TYPE>
259
+ AggregateFunction GetVectorArgMinMaxFunctionBy(const LogicalType &by_type, const LogicalType &type) {
260
+ switch (by_type.InternalType()) {
261
+ case PhysicalType::INT32:
262
+ return GetVectorArgMinMaxFunctionInternal<OP, ARG_TYPE, int32_t>(by_type, type);
263
+ case PhysicalType::INT64:
264
+ return GetVectorArgMinMaxFunctionInternal<OP, ARG_TYPE, int64_t>(by_type, type);
265
+ case PhysicalType::DOUBLE:
266
+ return GetVectorArgMinMaxFunctionInternal<OP, ARG_TYPE, double>(by_type, type);
267
+ case PhysicalType::VARCHAR:
268
+ return GetVectorArgMinMaxFunctionInternal<OP, ARG_TYPE, string_t>(by_type, type);
269
+ default:
270
+ throw InternalException("Unimplemented arg_min/arg_max aggregate");
271
+ }
272
+ }
273
+
274
+ template <class OP, class ARG_TYPE>
275
+ void AddVectorArgMinMaxFunctionBy(AggregateFunctionSet &fun, const LogicalType &type) {
276
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::INTEGER, type));
277
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::BIGINT, type));
278
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::DOUBLE, type));
279
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::VARCHAR, type));
280
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::DATE, type));
281
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::TIMESTAMP, type));
282
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::TIMESTAMP_TZ, type));
283
+ fun.AddFunction(GetVectorArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::BLOB, type));
284
+ }
285
+
286
+ template <class OP, class ARG_TYPE, class BY_TYPE>
287
+ AggregateFunction GetArgMinMaxFunctionInternal(const LogicalType &by_type, const LogicalType &type) {
288
+ using STATE = ArgMinMaxState<ARG_TYPE, BY_TYPE>;
289
+ auto function = AggregateFunction::BinaryAggregate<STATE, ARG_TYPE, BY_TYPE, ARG_TYPE, OP>(type, by_type, type);
290
+ if (type.InternalType() == PhysicalType::VARCHAR || by_type.InternalType() == PhysicalType::VARCHAR) {
291
+ function.destructor = AggregateFunction::StateDestroy<STATE, OP>;
136
292
  }
137
293
  return function;
138
294
  }
139
- template <class OP, class T>
140
- AggregateFunction GetArgMinMaxFunctionArg2(const LogicalType &arg_2, const LogicalType &arg) {
141
- switch (arg_2.InternalType()) {
295
+
296
+ template <class OP, class ARG_TYPE>
297
+ AggregateFunction GetArgMinMaxFunctionBy(const LogicalType &by_type, const LogicalType &type) {
298
+ switch (by_type.InternalType()) {
142
299
  case PhysicalType::INT32:
143
- return GetArgMinMaxFunctionInternal<OP, T, int32_t>(arg_2, arg);
300
+ return GetArgMinMaxFunctionInternal<OP, ARG_TYPE, int32_t>(by_type, type);
144
301
  case PhysicalType::INT64:
145
- return GetArgMinMaxFunctionInternal<OP, T, int64_t>(arg_2, arg);
302
+ return GetArgMinMaxFunctionInternal<OP, ARG_TYPE, int64_t>(by_type, type);
146
303
  case PhysicalType::DOUBLE:
147
- return GetArgMinMaxFunctionInternal<OP, T, double>(arg_2, arg);
304
+ return GetArgMinMaxFunctionInternal<OP, ARG_TYPE, double>(by_type, type);
148
305
  case PhysicalType::VARCHAR:
149
- return GetArgMinMaxFunctionInternal<OP, T, string_t>(arg_2, arg);
306
+ return GetArgMinMaxFunctionInternal<OP, ARG_TYPE, string_t>(by_type, type);
150
307
  default:
151
308
  throw InternalException("Unimplemented arg_min/arg_max aggregate");
152
309
  }
153
310
  }
154
311
 
155
- template <class OP, class T>
156
- void AddArgMinMaxFunctionArg2(AggregateFunctionSet &fun, const LogicalType &arg) {
157
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::INTEGER, arg));
158
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::BIGINT, arg));
159
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::DOUBLE, arg));
160
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::VARCHAR, arg));
161
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::DATE, arg));
162
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::TIMESTAMP, arg));
163
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::TIMESTAMP_TZ, arg));
164
- fun.AddFunction(GetArgMinMaxFunctionArg2<OP, T>(LogicalType::BLOB, arg));
312
+ template <class OP, class ARG_TYPE>
313
+ void AddArgMinMaxFunctionBy(AggregateFunctionSet &fun, const LogicalType &type) {
314
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::INTEGER, type));
315
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::BIGINT, type));
316
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::DOUBLE, type));
317
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::VARCHAR, type));
318
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::DATE, type));
319
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::TIMESTAMP, type));
320
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::TIMESTAMP_TZ, type));
321
+ fun.AddFunction(GetArgMinMaxFunctionBy<OP, ARG_TYPE>(LogicalType::BLOB, type));
165
322
  }
166
323
 
167
- template <class OP, class STRING_OP>
324
+ template <class COMPARATOR>
168
325
  static void AddArgMinMaxFunctions(AggregateFunctionSet &fun) {
169
- AddArgMinMaxFunctionArg2<OP, int32_t>(fun, LogicalType::INTEGER);
170
- AddArgMinMaxFunctionArg2<OP, int64_t>(fun, LogicalType::BIGINT);
171
- AddArgMinMaxFunctionArg2<OP, double>(fun, LogicalType::DOUBLE);
172
- AddArgMinMaxFunctionArg2<STRING_OP, string_t>(fun, LogicalType::VARCHAR);
173
- AddArgMinMaxFunctionArg2<OP, date_t>(fun, LogicalType::DATE);
174
- AddArgMinMaxFunctionArg2<OP, timestamp_t>(fun, LogicalType::TIMESTAMP);
175
- AddArgMinMaxFunctionArg2<OP, timestamp_t>(fun, LogicalType::TIMESTAMP_TZ);
176
- AddArgMinMaxFunctionArg2<STRING_OP, string_t>(fun, LogicalType::BLOB);
326
+ using OP = ArgMinMaxBase<COMPARATOR>;
327
+ AddArgMinMaxFunctionBy<OP, int32_t>(fun, LogicalType::INTEGER);
328
+ AddArgMinMaxFunctionBy<OP, int64_t>(fun, LogicalType::BIGINT);
329
+ AddArgMinMaxFunctionBy<OP, double>(fun, LogicalType::DOUBLE);
330
+ AddArgMinMaxFunctionBy<OP, string_t>(fun, LogicalType::VARCHAR);
331
+ AddArgMinMaxFunctionBy<OP, date_t>(fun, LogicalType::DATE);
332
+ AddArgMinMaxFunctionBy<OP, timestamp_t>(fun, LogicalType::TIMESTAMP);
333
+ AddArgMinMaxFunctionBy<OP, timestamp_t>(fun, LogicalType::TIMESTAMP_TZ);
334
+ AddArgMinMaxFunctionBy<OP, string_t>(fun, LogicalType::BLOB);
335
+
336
+ using VECTOR_OP = VectorArgMinMaxBase<COMPARATOR>;
337
+ AddVectorArgMinMaxFunctionBy<VECTOR_OP, Vector *>(fun, LogicalType::ANY);
177
338
  }
178
339
 
179
340
  void ArgMinFun::RegisterFunction(BuiltinFunctions &set) {
180
341
  AggregateFunctionSet fun("argmin");
181
- AddArgMinMaxFunctions<NumericArgMinOperation, StringArgMinOperation>(fun);
342
+ AddArgMinMaxFunctions<LessThan>(fun);
182
343
  set.AddFunction(fun);
183
344
 
184
345
  //! Add min_by alias
@@ -192,7 +353,7 @@ void ArgMinFun::RegisterFunction(BuiltinFunctions &set) {
192
353
 
193
354
  void ArgMaxFun::RegisterFunction(BuiltinFunctions &set) {
194
355
  AggregateFunctionSet fun("argmax");
195
- AddArgMinMaxFunctions<NumericArgMaxOperation, StringArgMaxOperation>(fun);
356
+ AddArgMinMaxFunctions<GreaterThan>(fun);
196
357
  set.AddFunction(fun);
197
358
 
198
359
  //! Add max_by alias
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.6.2-dev1114"
2
+ #define DUCKDB_VERSION "0.6.2-dev1124"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "51945c68c0"
5
+ #define DUCKDB_SOURCE_ID "aa44cebfc5"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -875,7 +875,8 @@ void SchemaSetting::SetLocal(ClientContext &context, const Value &input) {
875
875
  }
876
876
 
877
877
  Value SchemaSetting::GetSetting(ClientContext &context) {
878
- return SearchPathSetting::GetSetting(context);
878
+ auto &client_data = ClientData::Get(context);
879
+ return client_data.catalog_search_path->GetDefault().schema;
879
880
  }
880
881
 
881
882
  //===--------------------------------------------------------------------===//
@@ -44,15 +44,24 @@ unique_ptr<SQLStatement> Transformer::TransformDrop(duckdb_libpgquery::PGNode *n
44
44
  }
45
45
 
46
46
  switch (stmt->removeType) {
47
- case duckdb_libpgquery::PG_OBJECT_SCHEMA:
48
- info.name = ((duckdb_libpgquery::PGValue *)stmt->objects->head->data.ptr_value)->val.str;
49
- break;
50
47
  case duckdb_libpgquery::PG_OBJECT_TYPE: {
51
48
  auto view_list = (duckdb_libpgquery::PGList *)stmt->objects;
52
49
  auto target = (duckdb_libpgquery::PGTypeName *)(view_list->head->data.ptr_value);
53
50
  info.name = (reinterpret_cast<duckdb_libpgquery::PGValue *>(target->names->tail->data.ptr_value)->val.str);
54
51
  break;
55
52
  }
53
+ case duckdb_libpgquery::PG_OBJECT_SCHEMA: {
54
+ auto view_list = (duckdb_libpgquery::PGList *)stmt->objects->head->data.ptr_value;
55
+ if (view_list->length == 2) {
56
+ info.catalog = ((duckdb_libpgquery::PGValue *)view_list->head->data.ptr_value)->val.str;
57
+ info.name = ((duckdb_libpgquery::PGValue *)view_list->head->next->data.ptr_value)->val.str;
58
+ } else if (view_list->length == 1) {
59
+ info.name = ((duckdb_libpgquery::PGValue *)view_list->head->data.ptr_value)->val.str;
60
+ } else {
61
+ throw ParserException("Expected \"catalog.schema\" or \"schema\"");
62
+ }
63
+ break;
64
+ }
56
65
  default: {
57
66
  auto view_list = (duckdb_libpgquery::PGList *)stmt->objects->head->data.ptr_value;
58
67
  if (view_list->length == 3) {
@@ -1065,7 +1065,7 @@ typedef union YYSTYPE
1065
1065
  PGSubLinkType subquerytype;
1066
1066
  PGViewCheckOption viewcheckoption;
1067
1067
  }
1068
- /* Line 1489 of yacc.c. */
1068
+ /* Line 1529 of yacc.c. */
1069
1069
  #line 1070 "third_party/libpg_query/grammar/grammar_out.hpp"
1070
1070
  YYSTYPE;
1071
1071
  # define yystype YYSTYPE /* obsolescent; will be withdrawn */