duckdb 0.8.2-dev4711.0 → 0.8.2-dev5002.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 (98) hide show
  1. package/binding.gyp +0 -1
  2. package/binding.gyp.in +0 -1
  3. package/package.json +1 -1
  4. package/src/connection.cpp +10 -23
  5. package/src/data_chunk.cpp +1 -3
  6. package/src/database.cpp +4 -9
  7. package/src/duckdb/extension/icu/icu-datepart.cpp +12 -8
  8. package/src/duckdb/extension/json/json_functions/json_transform.cpp +8 -6
  9. package/src/duckdb/extension/json/json_functions.cpp +4 -6
  10. package/src/duckdb/src/common/enum_util.cpp +10 -5
  11. package/src/duckdb/src/common/operator/cast_operators.cpp +18 -0
  12. package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
  13. package/src/duckdb/src/common/row_operations/row_matcher.cpp +375 -0
  14. package/src/duckdb/src/common/types/data_chunk.cpp +48 -11
  15. package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +3 -3
  16. package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +28 -17
  17. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +44 -43
  18. package/src/duckdb/src/common/types/vector.cpp +0 -1
  19. package/src/duckdb/src/common/types.cpp +1 -1
  20. package/src/duckdb/src/common/vector_operations/vector_hash.cpp +1 -0
  21. package/src/duckdb/src/core_functions/function_list.cpp +1 -1
  22. package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +86 -50
  23. package/src/duckdb/src/core_functions/scalar/generic/hash.cpp +3 -0
  24. package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +5 -1
  25. package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +10 -1
  26. package/src/duckdb/src/core_functions/scalar/map/map_concat.cpp +0 -2
  27. package/src/duckdb/src/core_functions/scalar/string/repeat.cpp +8 -5
  28. package/src/duckdb/src/execution/aggregate_hashtable.cpp +5 -4
  29. package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +13 -0
  30. package/src/duckdb/src/execution/join_hashtable.cpp +71 -59
  31. package/src/duckdb/src/execution/nested_loop_join/nested_loop_join_inner.cpp +20 -27
  32. package/src/duckdb/src/execution/nested_loop_join/nested_loop_join_mark.cpp +21 -9
  33. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +7 -7
  34. package/src/duckdb/src/execution/operator/csv_scanner/csv_reader_options.cpp +1 -1
  35. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +9 -4
  36. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +0 -2
  37. package/src/duckdb/src/execution/reservoir_sample.cpp +3 -9
  38. package/src/duckdb/src/function/cast/time_casts.cpp +12 -0
  39. package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +8 -2
  40. package/src/duckdb/src/function/function_binder.cpp +10 -9
  41. package/src/duckdb/src/function/pragma/pragma_queries.cpp +3 -0
  42. package/src/duckdb/src/function/scalar/string/like.cpp +0 -3
  43. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  44. package/src/duckdb/src/include/duckdb/common/enums/date_part_specifier.hpp +11 -3
  45. package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -0
  46. package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +27 -0
  47. package/src/duckdb/src/include/duckdb/common/operator/comparison_operators.hpp +38 -2
  48. package/src/duckdb/src/include/duckdb/common/row_operations/row_matcher.hpp +63 -0
  49. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +6 -2
  50. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +2 -2
  51. package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +4 -1
  52. package/src/duckdb/src/include/duckdb/core_functions/scalar/bit_functions.hpp +4 -4
  53. package/src/duckdb/src/include/duckdb/core_functions/scalar/blob_functions.hpp +4 -4
  54. package/src/duckdb/src/include/duckdb/core_functions/scalar/date_functions.hpp +5 -5
  55. package/src/duckdb/src/include/duckdb/core_functions/scalar/enum_functions.hpp +7 -7
  56. package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +12 -12
  57. package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +12 -12
  58. package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +3 -3
  59. package/src/duckdb/src/include/duckdb/core_functions/scalar/math_functions.hpp +33 -33
  60. package/src/duckdb/src/include/duckdb/core_functions/scalar/operators_functions.hpp +2 -2
  61. package/src/duckdb/src/include/duckdb/core_functions/scalar/random_functions.hpp +3 -3
  62. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +13 -13
  63. package/src/duckdb/src/include/duckdb/core_functions/scalar/struct_functions.hpp +2 -2
  64. package/src/duckdb/src/include/duckdb/core_functions/scalar/union_functions.hpp +2 -2
  65. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +4 -0
  66. package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +14 -8
  67. package/src/duckdb/src/include/duckdb/main/relation.hpp +4 -0
  68. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -0
  69. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +1 -2
  70. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -1
  71. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -1
  72. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -1
  75. package/src/duckdb/src/main/config.cpp +1 -1
  76. package/src/duckdb/src/main/relation.cpp +10 -0
  77. package/src/duckdb/src/optimizer/rule/date_part_simplification.cpp +0 -3
  78. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +28 -6
  79. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +3 -0
  80. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +12 -4
  81. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +14 -6
  82. package/src/duckdb/src/planner/operator/logical_create_table.cpp +3 -3
  83. package/src/duckdb/src/planner/operator/logical_delete.cpp +3 -2
  84. package/src/duckdb/src/planner/operator/logical_insert.cpp +3 -2
  85. package/src/duckdb/src/planner/operator/logical_update.cpp +3 -2
  86. package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +2 -3
  87. package/src/duckdb/src/storage/data_table.cpp +18 -8
  88. package/src/duckdb/src/storage/local_storage.cpp +2 -3
  89. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +64 -80
  90. package/src/duckdb/src/storage/storage_manager.cpp +6 -2
  91. package/src/duckdb/src/storage/table/row_group.cpp +6 -0
  92. package/src/duckdb/src/storage/table/row_group_collection.cpp +4 -3
  93. package/src/duckdb/src/storage/table/struct_column_data.cpp +2 -0
  94. package/src/duckdb/src/transaction/duck_transaction.cpp +1 -0
  95. package/src/duckdb/ub_src_common_row_operations.cpp +1 -1
  96. package/src/statement.cpp +2 -4
  97. package/test/database_fail.test.ts +6 -0
  98. package/src/duckdb/src/common/row_operations/row_match.cpp +0 -359
@@ -134,6 +134,10 @@ BoundCastInfo DefaultCasts::TimestampMsCastSwitch(BindCastInput &input, const Lo
134
134
  // timestamp (ms) to timestamp (us)
135
135
  return BoundCastInfo(
136
136
  &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampMsToUs>);
137
+ case LogicalTypeId::TIMESTAMP_NS:
138
+ // timestamp (ms) to timestamp (ns)
139
+ return BoundCastInfo(
140
+ &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampMsToNs>);
137
141
  default:
138
142
  return TryVectorNullCast;
139
143
  }
@@ -146,10 +150,18 @@ BoundCastInfo DefaultCasts::TimestampSecCastSwitch(BindCastInput &input, const L
146
150
  case LogicalTypeId::VARCHAR:
147
151
  // timestamp (sec) to varchar
148
152
  return BoundCastInfo(&VectorCastHelpers::StringCast<timestamp_t, duckdb::CastFromTimestampSec>);
153
+ case LogicalTypeId::TIMESTAMP_MS:
154
+ // timestamp (s) to timestamp (ms)
155
+ return BoundCastInfo(
156
+ &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToMs>);
149
157
  case LogicalTypeId::TIMESTAMP:
150
158
  // timestamp (s) to timestamp (us)
151
159
  return BoundCastInfo(
152
160
  &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToUs>);
161
+ case LogicalTypeId::TIMESTAMP_NS:
162
+ // timestamp (s) to timestamp (ns)
163
+ return BoundCastInfo(
164
+ &VectorCastHelpers::TemplatedCastLoop<timestamp_t, timestamp_t, duckdb::CastTimestampSecToNs>);
153
165
  default:
154
166
  return TryVectorNullCast;
155
167
  }
@@ -20,10 +20,16 @@ inline static void SkipWhitespace(const char *buf, idx_t &pos, idx_t len) {
20
20
  static bool SkipToCloseQuotes(idx_t &pos, const char *buf, idx_t &len) {
21
21
  char quote = buf[pos];
22
22
  pos++;
23
+ bool escaped = false;
23
24
 
24
25
  while (pos < len) {
25
- if (buf[pos] == quote) {
26
- return true;
26
+ if (buf[pos] == '\\') {
27
+ escaped = !escaped;
28
+ } else {
29
+ if (buf[pos] == quote && !escaped) {
30
+ return true;
31
+ }
32
+ escaped = false;
27
33
  }
28
34
  pos++;
29
35
  }
@@ -1,16 +1,16 @@
1
1
  #include "duckdb/function/function_binder.hpp"
2
- #include "duckdb/common/limits.hpp"
3
2
 
4
- #include "duckdb/planner/expression/bound_cast_expression.hpp"
5
- #include "duckdb/planner/expression/bound_aggregate_expression.hpp"
6
- #include "duckdb/planner/expression/bound_function_expression.hpp"
7
- #include "duckdb/planner/expression/bound_constant_expression.hpp"
3
+ #include "duckdb/catalog/catalog.hpp"
8
4
  #include "duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp"
9
-
10
- #include "duckdb/planner/expression_binder.hpp"
5
+ #include "duckdb/common/limits.hpp"
6
+ #include "duckdb/execution/expression_executor.hpp"
11
7
  #include "duckdb/function/aggregate_function.hpp"
12
8
  #include "duckdb/function/cast_rules.hpp"
13
- #include "duckdb/catalog/catalog.hpp"
9
+ #include "duckdb/planner/expression/bound_aggregate_expression.hpp"
10
+ #include "duckdb/planner/expression/bound_cast_expression.hpp"
11
+ #include "duckdb/planner/expression/bound_constant_expression.hpp"
12
+ #include "duckdb/planner/expression/bound_function_expression.hpp"
13
+ #include "duckdb/planner/expression_binder.hpp"
14
14
 
15
15
  namespace duckdb {
16
16
 
@@ -268,7 +268,8 @@ unique_ptr<Expression> FunctionBinder::BindScalarFunction(ScalarFunctionCatalogE
268
268
 
269
269
  if (bound_function.null_handling == FunctionNullHandling::DEFAULT_NULL_HANDLING) {
270
270
  for (auto &child : children) {
271
- if (child->return_type == LogicalTypeId::SQLNULL) {
271
+ if (child->return_type == LogicalTypeId::SQLNULL ||
272
+ (child->IsFoldable() && ExpressionExecutor::EvaluateScalar(context, *child).IsNull())) {
272
273
  return make_uniq<BoundConstantExpression>(Value(LogicalType::SQLNULL));
273
274
  }
274
275
  }
@@ -124,12 +124,15 @@ string PragmaShow(ClientContext &context, const FunctionParameters &parameters)
124
124
  ON cols.column_name = pragma_table_info.name
125
125
  AND cols.table_name='%table_name%'
126
126
  AND cols.schema_name='%table_schema%'
127
+ AND cols.database_name = '%table_database%'
127
128
  ORDER BY column_index;)";
128
129
  // clang-format on
129
130
 
130
131
  sql = StringUtil::Replace(sql, "%func_param_table%", parameters.values[0].ToString());
131
132
  sql = StringUtil::Replace(sql, "%table_name%", table.name);
132
133
  sql = StringUtil::Replace(sql, "%table_schema%", table.schema.empty() ? DEFAULT_SCHEMA : table.schema);
134
+ sql = StringUtil::Replace(sql, "%table_database%",
135
+ table.catalog.empty() ? DatabaseManager::GetDefaultDatabase(context) : table.catalog);
133
136
  return sql;
134
137
  }
135
138
 
@@ -196,9 +196,6 @@ static unique_ptr<FunctionData> LikeBindFunction(ClientContext &context, ScalarF
196
196
  D_ASSERT(arguments.size() == 2 || arguments.size() == 3);
197
197
  if (arguments[1]->IsFoldable()) {
198
198
  Value pattern_str = ExpressionExecutor::EvaluateScalar(context, *arguments[1]);
199
- if (pattern_str.IsNull()) {
200
- return nullptr;
201
- }
202
199
  return LikeMatcher::CreateLikeMatcher(pattern_str.ToString());
203
200
  }
204
201
  return nullptr;
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.8.2-dev4711"
2
+ #define DUCKDB_VERSION "0.8.2-dev5002"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "474a0bd683"
5
+ #define DUCKDB_SOURCE_ID "239f51293c"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -25,7 +25,6 @@ enum class DatePartSpecifier : uint8_t {
25
25
  SECOND,
26
26
  MINUTE,
27
27
  HOUR,
28
- EPOCH,
29
28
  DOW,
30
29
  ISODOW,
31
30
  WEEK,
@@ -39,11 +38,20 @@ enum class DatePartSpecifier : uint8_t {
39
38
  TIMEZONE_MINUTE,
40
39
 
41
40
  // DOUBLE values
42
- JULIAN_DAY
41
+ EPOCH,
42
+ JULIAN_DAY,
43
+
44
+ // Invalid
45
+ INVALID,
46
+
47
+ // Type ranges
48
+ BEGIN_BIGINT = YEAR,
49
+ BEGIN_DOUBLE = EPOCH,
50
+ BEGIN_INVALID = INVALID,
43
51
  };
44
52
 
45
53
  inline bool IsBigintDatepart(DatePartSpecifier part_code) {
46
- return size_t(part_code) < size_t(DatePartSpecifier::JULIAN_DAY);
54
+ return size_t(part_code) < size_t(DatePartSpecifier::BEGIN_DOUBLE);
47
55
  }
48
56
 
49
57
  DUCKDB_API bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
@@ -182,6 +182,11 @@ struct MultiFileReader {
182
182
  }
183
183
  }
184
184
  for (idx_t r = 0; r < data.union_readers.size(); r++) {
185
+ if (!data.union_readers[r]) {
186
+ data.union_readers.erase(data.union_readers.begin() + r);
187
+ r--;
188
+ continue;
189
+ }
185
190
  // check if the union reader should still be read or not
186
191
  auto entry = file_set.find(data.union_readers[r]->GetFileName());
187
192
  if (entry == file_set.end()) {
@@ -632,6 +632,13 @@ struct CastTimestampMsToUs {
632
632
  }
633
633
  };
634
634
 
635
+ struct CastTimestampMsToNs {
636
+ template <class SRC, class DST>
637
+ static inline DST Operation(SRC input) {
638
+ throw duckdb::NotImplementedException("Cast to TIMESTAMP_NS could not be performed!");
639
+ }
640
+ };
641
+
635
642
  struct CastTimestampNsToUs {
636
643
  template <class SRC, class DST>
637
644
  static inline DST Operation(SRC input) {
@@ -639,6 +646,13 @@ struct CastTimestampNsToUs {
639
646
  }
640
647
  };
641
648
 
649
+ struct CastTimestampSecToMs {
650
+ template <class SRC, class DST>
651
+ static inline DST Operation(SRC input) {
652
+ throw duckdb::NotImplementedException("Cast to TIMESTAMP_MS could not be performed!");
653
+ }
654
+ };
655
+
642
656
  struct CastTimestampSecToUs {
643
657
  template <class SRC, class DST>
644
658
  static inline DST Operation(SRC input) {
@@ -646,6 +660,13 @@ struct CastTimestampSecToUs {
646
660
  }
647
661
  };
648
662
 
663
+ struct CastTimestampSecToNs {
664
+ template <class SRC, class DST>
665
+ static inline DST Operation(SRC input) {
666
+ throw duckdb::NotImplementedException("Cast to TIMESTAMP_NS could not be performed!");
667
+ }
668
+ };
669
+
649
670
  template <>
650
671
  duckdb::timestamp_t CastTimestampUsToMs::Operation(duckdb::timestamp_t input);
651
672
  template <>
@@ -655,9 +676,15 @@ duckdb::timestamp_t CastTimestampUsToSec::Operation(duckdb::timestamp_t input);
655
676
  template <>
656
677
  duckdb::timestamp_t CastTimestampMsToUs::Operation(duckdb::timestamp_t input);
657
678
  template <>
679
+ duckdb::timestamp_t CastTimestampMsToNs::Operation(duckdb::timestamp_t input);
680
+ template <>
658
681
  duckdb::timestamp_t CastTimestampNsToUs::Operation(duckdb::timestamp_t input);
659
682
  template <>
683
+ duckdb::timestamp_t CastTimestampSecToMs::Operation(duckdb::timestamp_t input);
684
+ template <>
660
685
  duckdb::timestamp_t CastTimestampSecToUs::Operation(duckdb::timestamp_t input);
686
+ template <>
687
+ duckdb::timestamp_t CastTimestampSecToNs::Operation(duckdb::timestamp_t input);
661
688
 
662
689
  template <>
663
690
  duckdb::string_t CastFromTimestampNS::Operation(duckdb::timestamp_t input, Vector &result);
@@ -8,11 +8,11 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/common/types/string_type.hpp"
11
+ #include "duckdb/common/helper.hpp"
12
12
  #include "duckdb/common/types.hpp"
13
13
  #include "duckdb/common/types/hugeint.hpp"
14
14
  #include "duckdb/common/types/interval.hpp"
15
- #include "duckdb/common/helper.hpp"
15
+ #include "duckdb/common/types/string_type.hpp"
16
16
 
17
17
  #include <cstring>
18
18
 
@@ -142,6 +142,42 @@ struct DistinctLessThanEquals {
142
142
  }
143
143
  };
144
144
 
145
+ //===--------------------------------------------------------------------===//
146
+ // Comparison Operator Wrappers (so (Not)DistinctFrom have the same API)
147
+ //===--------------------------------------------------------------------===//
148
+ template <class OP>
149
+ struct ComparisonOperationWrapper {
150
+ static constexpr const bool COMPARE_NULL = false;
151
+
152
+ template <class T>
153
+ static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
154
+ if (right_null || left_null) {
155
+ return false;
156
+ }
157
+ return OP::template Operation<T>(left, right);
158
+ }
159
+ };
160
+
161
+ template <>
162
+ struct ComparisonOperationWrapper<DistinctFrom> {
163
+ static constexpr const bool COMPARE_NULL = true;
164
+
165
+ template <class T>
166
+ static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
167
+ return DistinctFrom::template Operation<T>(left, right, left_null, right_null);
168
+ }
169
+ };
170
+
171
+ template <>
172
+ struct ComparisonOperationWrapper<NotDistinctFrom> {
173
+ static constexpr const bool COMPARE_NULL = true;
174
+
175
+ template <class T>
176
+ static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
177
+ return NotDistinctFrom::template Operation<T>(left, right, left_null, right_null);
178
+ }
179
+ };
180
+
145
181
  //===--------------------------------------------------------------------===//
146
182
  // Specialized Boolean Comparison Operators
147
183
  //===--------------------------------------------------------------------===//
@@ -0,0 +1,63 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/common/row_operations/row_matcher.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/common/enums/expression_type.hpp"
12
+ #include "duckdb/common/types.hpp"
13
+
14
+ namespace duckdb {
15
+
16
+ class Vector;
17
+ class DataChunk;
18
+ class TupleDataLayout;
19
+ struct TupleDataVectorFormat;
20
+ struct SelectionVector;
21
+ struct MatchFunction;
22
+
23
+ typedef idx_t (*match_function_t)(Vector &lhs_vector, const TupleDataVectorFormat &lhs_format, SelectionVector &sel,
24
+ const idx_t count, const TupleDataLayout &rhs_layout, Vector &rhs_row_locations,
25
+ const idx_t col_idx, const vector<MatchFunction> &child_functions,
26
+ SelectionVector *no_match_sel, idx_t &no_match_count);
27
+
28
+ struct MatchFunction {
29
+ match_function_t function;
30
+ vector<MatchFunction> child_functions;
31
+ };
32
+
33
+ struct RowMatcher {
34
+ public:
35
+ using Predicates = vector<ExpressionType>;
36
+
37
+ //! Initializes the RowMatcher, filling match_functions using layout and predicates
38
+ void Initialize(const bool no_match_sel, const TupleDataLayout &layout, const Predicates &predicates);
39
+ //! Given a DataChunk on the LHS, on which we've called TupleDataCollection::ToUnifiedFormat,
40
+ //! we match it with rows on the RHS, according to the given layout and locations.
41
+ //! Initially, 'sel' has 'count' entries which point to what needs to be compared.
42
+ //! After matching is done, this returns how many matching entries there are, which 'sel' is modified to point to
43
+ idx_t Match(DataChunk &lhs, const vector<TupleDataVectorFormat> &lhs_formats, SelectionVector &sel, idx_t count,
44
+ const TupleDataLayout &rhs_layout, Vector &rhs_row_locations, SelectionVector *no_match_sel,
45
+ idx_t &no_match_count);
46
+
47
+ private:
48
+ //! Gets the templated match function for a given column
49
+ MatchFunction GetMatchFunction(const bool no_match_sel, const LogicalType &type, const ExpressionType predicate);
50
+ template <bool NO_MATCH_SEL>
51
+ MatchFunction GetMatchFunction(const LogicalType &type, const ExpressionType predicate);
52
+ template <bool NO_MATCH_SEL, class T>
53
+ MatchFunction GetMatchFunction(const ExpressionType predicate);
54
+ template <bool NO_MATCH_SEL>
55
+ MatchFunction GetStructMatchFunction(const LogicalType &type, const ExpressionType predicate);
56
+ template <bool NO_MATCH_SEL>
57
+ MatchFunction GetListMatchFunction(const ExpressionType predicate);
58
+
59
+ private:
60
+ vector<MatchFunction> match_functions;
61
+ };
62
+
63
+ } // namespace duckdb
@@ -21,7 +21,7 @@ struct RowOperationsState;
21
21
 
22
22
  typedef void (*tuple_data_scatter_function_t)(const Vector &source, const TupleDataVectorFormat &source_format,
23
23
  const SelectionVector &append_sel, const idx_t append_count,
24
- const TupleDataLayout &layout, Vector &row_locations,
24
+ const TupleDataLayout &layout, const Vector &row_locations,
25
25
  Vector &heap_locations, const idx_t col_idx,
26
26
  const UnifiedVectorFormat &list_format,
27
27
  const vector<TupleDataScatterFunction> &child_functions);
@@ -84,7 +84,11 @@ public:
84
84
  TupleDataPinProperties = TupleDataPinProperties::UNPIN_AFTER_DONE);
85
85
  //! Initializes the Chunk state of an Append state
86
86
  //! - Useful for optimizing many appends made to the same tuple data collection
87
- void InitializeAppend(TupleDataChunkState &chunk_state, vector<column_t> column_ids = {});
87
+ void InitializeChunkState(TupleDataChunkState &chunk_state, vector<column_t> column_ids = {});
88
+ //! Initializes the Chunk state of an Append state
89
+ //! - Useful for optimizing many appends made to the same tuple data collection
90
+ static void InitializeChunkState(TupleDataChunkState &chunk_state, const vector<LogicalType> &types,
91
+ vector<column_t> column_ids = {});
88
92
  //! Append a DataChunk directly to this TupleDataCollection - calls InitializeAppend and Append internally
89
93
  void Append(DataChunk &new_chunk, const SelectionVector &append_sel = *FlatVector::IncrementalSelectionVector(),
90
94
  idx_t append_count = DConstants::INVALID_INDEX);
@@ -42,8 +42,8 @@ struct TupleDataVectorFormat {
42
42
  const SelectionVector *original_sel;
43
43
  SelectionVector original_owned_sel;
44
44
 
45
- UnifiedVectorFormat data;
46
- vector<TupleDataVectorFormat> child_formats;
45
+ UnifiedVectorFormat unified;
46
+ vector<TupleDataVectorFormat> children;
47
47
  unique_ptr<CombinedListData> combined_list_data;
48
48
  };
49
49
 
@@ -148,6 +148,9 @@ public:
148
148
  if (!validity_mask) {
149
149
  return ValidityBuffer::MAX_ENTRY;
150
150
  }
151
+ return GetValidityEntryUnsafe(entry_idx);
152
+ }
153
+ inline V &GetValidityEntryUnsafe(idx_t entry_idx) const {
151
154
  return validity_mask[entry_idx];
152
155
  }
153
156
  static inline bool AllValid(V entry) {
@@ -156,7 +159,7 @@ public:
156
159
  static inline bool NoneValid(V entry) {
157
160
  return entry == 0;
158
161
  }
159
- static inline bool RowIsValid(V entry, idx_t idx_in_entry) {
162
+ static inline bool RowIsValid(const V &entry, const idx_t &idx_in_entry) {
160
163
  return entry & (V(1) << V(idx_in_entry));
161
164
  }
162
165
  static inline void GetEntryIndex(idx_t row_idx, idx_t &entry_idx, idx_t &idx_in_entry) {
@@ -18,7 +18,7 @@ namespace duckdb {
18
18
  struct GetBitFun {
19
19
  static constexpr const char *Name = "get_bit";
20
20
  static constexpr const char *Parameters = "bitstring,index";
21
- static constexpr const char *Description = "Extracts the nth bit from bitstring; the first (leftmost) bit is indexed 0.";
21
+ static constexpr const char *Description = "Extracts the nth bit from bitstring; the first (leftmost) bit is indexed 0";
22
22
  static constexpr const char *Example = "get_bit('0110010'::BIT, 2)";
23
23
 
24
24
  static ScalarFunction GetFunction();
@@ -27,7 +27,7 @@ struct GetBitFun {
27
27
  struct SetBitFun {
28
28
  static constexpr const char *Name = "set_bit";
29
29
  static constexpr const char *Parameters = "bitstring,index,new_value";
30
- static constexpr const char *Description = "Sets the nth bit in bitstring to newvalue; the first (leftmost) bit is indexed 0. Returns a new bitstring.";
30
+ static constexpr const char *Description = "Sets the nth bit in bitstring to newvalue; the first (leftmost) bit is indexed 0. Returns a new bitstring";
31
31
  static constexpr const char *Example = "set_bit('0110010'::BIT, 2, 0)";
32
32
 
33
33
  static ScalarFunction GetFunction();
@@ -36,7 +36,7 @@ struct SetBitFun {
36
36
  struct BitPositionFun {
37
37
  static constexpr const char *Name = "bit_position";
38
38
  static constexpr const char *Parameters = "substring,bitstring";
39
- static constexpr const char *Description = "Returns first starting index of the specified substring within bits, or zero if it’s not present. The first (leftmost) bit is indexed 1";
39
+ static constexpr const char *Description = "Returns first starting index of the specified substring within bits, or zero if it is not present. The first (leftmost) bit is indexed 1";
40
40
  static constexpr const char *Example = "bit_position('010'::BIT, '1110101'::BIT)";
41
41
 
42
42
  static ScalarFunction GetFunction();
@@ -45,7 +45,7 @@ struct BitPositionFun {
45
45
  struct BitStringFun {
46
46
  static constexpr const char *Name = "bitstring";
47
47
  static constexpr const char *Parameters = "bitstring,length";
48
- static constexpr const char *Description = "Pads the bitstring until the specified length.";
48
+ static constexpr const char *Description = "Pads the bitstring until the specified length";
49
49
  static constexpr const char *Example = "bitstring('1010'::BIT, 7)";
50
50
 
51
51
  static ScalarFunction GetFunction();
@@ -18,7 +18,7 @@ namespace duckdb {
18
18
  struct DecodeFun {
19
19
  static constexpr const char *Name = "decode";
20
20
  static constexpr const char *Parameters = "blob";
21
- static constexpr const char *Description = "Convert blob to varchar. Fails if blob is not valid utf-8.";
21
+ static constexpr const char *Description = "Convert blob to varchar. Fails if blob is not valid utf-8";
22
22
  static constexpr const char *Example = "decode('\\xC3\\xBC'::BLOB)";
23
23
 
24
24
  static ScalarFunction GetFunction();
@@ -27,7 +27,7 @@ struct DecodeFun {
27
27
  struct EncodeFun {
28
28
  static constexpr const char *Name = "encode";
29
29
  static constexpr const char *Parameters = "string";
30
- static constexpr const char *Description = "Convert varchar to blob. Converts utf-8 characters into literal encoding.";
30
+ static constexpr const char *Description = "Convert varchar to blob. Converts utf-8 characters into literal encoding";
31
31
  static constexpr const char *Example = "encode('my_string_with_ü')";
32
32
 
33
33
  static ScalarFunction GetFunction();
@@ -36,7 +36,7 @@ struct EncodeFun {
36
36
  struct FromBase64Fun {
37
37
  static constexpr const char *Name = "from_base64";
38
38
  static constexpr const char *Parameters = "string";
39
- static constexpr const char *Description = "Convert a base64 encoded string to a character string.";
39
+ static constexpr const char *Description = "Convert a base64 encoded string to a character string";
40
40
  static constexpr const char *Example = "from_base64('QQ==')";
41
41
 
42
42
  static ScalarFunction GetFunction();
@@ -45,7 +45,7 @@ struct FromBase64Fun {
45
45
  struct ToBase64Fun {
46
46
  static constexpr const char *Name = "to_base64";
47
47
  static constexpr const char *Parameters = "blob";
48
- static constexpr const char *Description = "Convert a blob to a base64 encoded string.";
48
+ static constexpr const char *Description = "Convert a blob to a base64 encoded string";
49
49
  static constexpr const char *Example = "base64('A'::blob)";
50
50
 
51
51
  static ScalarFunction GetFunction();
@@ -120,7 +120,7 @@ struct DayFun {
120
120
  struct DayNameFun {
121
121
  static constexpr const char *Name = "dayname";
122
122
  static constexpr const char *Parameters = "ts";
123
- static constexpr const char *Description = "The (English) name of the weekday.";
123
+ static constexpr const char *Description = "The (English) name of the weekday";
124
124
  static constexpr const char *Example = "dayname(TIMESTAMP '1992-03-22')";
125
125
 
126
126
  static ScalarFunctionSet GetFunctions();
@@ -357,7 +357,7 @@ struct MonthFun {
357
357
  struct MonthNameFun {
358
358
  static constexpr const char *Name = "monthname";
359
359
  static constexpr const char *Parameters = "ts";
360
- static constexpr const char *Description = "The (English) name of the month.";
360
+ static constexpr const char *Description = "The (English) name of the month";
361
361
  static constexpr const char *Example = "monthname(TIMESTAMP '1992-09-20')";
362
362
 
363
363
  static ScalarFunctionSet GetFunctions();
@@ -393,7 +393,7 @@ struct StrfTimeFun {
393
393
  struct StrpTimeFun {
394
394
  static constexpr const char *Name = "strptime";
395
395
  static constexpr const char *Parameters = "text,format";
396
- static constexpr const char *Description = "Converts string to timestamp with time zone according to the format string if %Z is specified.";
396
+ static constexpr const char *Description = "Converts string to timestamp with time zone according to the format string if %Z is specified";
397
397
  static constexpr const char *Example = "strptime('Wed, 1 January 1992 - 08:38:40 PST', '%a, %-d %B %Y - %H:%M:%S %Z')";
398
398
 
399
399
  static ScalarFunctionSet GetFunctions();
@@ -402,7 +402,7 @@ struct StrpTimeFun {
402
402
  struct TimeBucketFun {
403
403
  static constexpr const char *Name = "time_bucket";
404
404
  static constexpr const char *Parameters = "bucket_width,timestamp,origin";
405
- static constexpr const char *Description = "Truncate timestamptz by the specified interval bucket_width. Buckets are aligned relative to origin timestamptz. origin defaults to 2000-01-03 00:00:00+00 for buckets that don’t include a month or year interval, and to 2000-01-01 00:00:00+00 for month and year buckets.";
405
+ static constexpr const char *Description = "Truncate TIMESTAMPTZ by the specified interval bucket_width. Buckets are aligned relative to origin TIMESTAMPTZ. The origin defaults to 2000-01-03 00:00:00+00 for buckets that do not include a month or year interval, and to 2000-01-01 00:00:00+00 for month and year buckets";
406
406
  static constexpr const char *Example = "time_bucket(INTERVAL '2 weeks', TIMESTAMP '1992-04-20 15:26:00-07', TIMESTAMP '1992-04-01 00:00:00-07')";
407
407
 
408
408
  static ScalarFunctionSet GetFunctions();
@@ -519,7 +519,7 @@ struct ToYearsFun {
519
519
  struct TryStrpTimeFun {
520
520
  static constexpr const char *Name = "try_strptime";
521
521
  static constexpr const char *Parameters = "text,format";
522
- static constexpr const char *Description = "Converts string to timestamp using the format string (timestamp with time zone if %Z is specified). Returns NULL on failure.";
522
+ static constexpr const char *Description = "Converts string to timestamp using the format string (timestamp with time zone if %Z is specified). Returns NULL on failure";
523
523
  static constexpr const char *Example = "try_strptime('Wed, 1 January 1992 - 08:38:40 PM', '%a, %-d %B %Y - %I:%M:%S %p')";
524
524
 
525
525
  static ScalarFunctionSet GetFunctions();
@@ -18,8 +18,8 @@ namespace duckdb {
18
18
  struct EnumFirstFun {
19
19
  static constexpr const char *Name = "enum_first";
20
20
  static constexpr const char *Parameters = "enum";
21
- static constexpr const char *Description = "Returns the first value of the input enum type.";
22
- static constexpr const char *Example = "enum_first(null::mood)";
21
+ static constexpr const char *Description = "Returns the first value of the input enum type";
22
+ static constexpr const char *Example = "enum_first(NULL::mood)";
23
23
 
24
24
  static ScalarFunction GetFunction();
25
25
  };
@@ -27,8 +27,8 @@ struct EnumFirstFun {
27
27
  struct EnumLastFun {
28
28
  static constexpr const char *Name = "enum_last";
29
29
  static constexpr const char *Parameters = "enum";
30
- static constexpr const char *Description = "Returns the last value of the input enum type.";
31
- static constexpr const char *Example = "enum_last(null::mood)";
30
+ static constexpr const char *Description = "Returns the last value of the input enum type";
31
+ static constexpr const char *Example = "enum_last(NULL::mood)";
32
32
 
33
33
  static ScalarFunction GetFunction();
34
34
  };
@@ -45,8 +45,8 @@ struct EnumCodeFun {
45
45
  struct EnumRangeFun {
46
46
  static constexpr const char *Name = "enum_range";
47
47
  static constexpr const char *Parameters = "enum";
48
- static constexpr const char *Description = "Returns all values of the input enum type as an array.";
49
- static constexpr const char *Example = "enum_range(null::mood)";
48
+ static constexpr const char *Description = "Returns all values of the input enum type as an array";
49
+ static constexpr const char *Example = "enum_range(NULL::mood)";
50
50
 
51
51
  static ScalarFunction GetFunction();
52
52
  };
@@ -54,7 +54,7 @@ struct EnumRangeFun {
54
54
  struct EnumRangeBoundaryFun {
55
55
  static constexpr const char *Name = "enum_range_boundary";
56
56
  static constexpr const char *Parameters = "start,end";
57
- static constexpr const char *Description = "Returns the range between the two given enum values as an array. The values must be of the same enum type. When the first parameter is NULL, the result starts with the first value of the enum type. When the second parameter is NULL, the result ends with the last value of the enum type.";
57
+ static constexpr const char *Description = "Returns the range between the two given enum values as an array. The values must be of the same enum type. When the first parameter is NULL, the result starts with the first value of the enum type. When the second parameter is NULL, the result ends with the last value of the enum type";
58
58
  static constexpr const char *Example = "enum_range_boundary(NULL, 'happy'::mood)";
59
59
 
60
60
  static ScalarFunction GetFunction();