duckdb 0.5.2-dev1203.0 → 0.5.2-dev1229.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/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "575117f6b"
15
- #define DUCKDB_VERSION "v0.5.2-dev1203"
14
+ #define DUCKDB_SOURCE_ID "e4ee601c8"
15
+ #define DUCKDB_VERSION "v0.5.2-dev1229"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -830,6 +830,8 @@ struct list_entry_t {
830
830
  uint64_t length;
831
831
  };
832
832
 
833
+ using union_tag_t = uint8_t;
834
+
833
835
  //===--------------------------------------------------------------------===//
834
836
  // Internal Types
835
837
  //===--------------------------------------------------------------------===//
@@ -1003,7 +1005,8 @@ enum class LogicalTypeId : uint8_t {
1003
1005
  TABLE = 103,
1004
1006
  ENUM = 104,
1005
1007
  AGGREGATE_STATE = 105,
1006
- LAMBDA = 106
1008
+ LAMBDA = 106,
1009
+ UNION = 107
1007
1010
  };
1008
1011
 
1009
1012
  struct ExtraTypeInfo;
@@ -1140,6 +1143,7 @@ public:
1140
1143
  DUCKDB_API static LogicalType AGGREGATE_STATE(aggregate_state_t state_type); // NOLINT
1141
1144
  DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
1142
1145
  DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
1146
+ DUCKDB_API static LogicalType UNION( child_list_t<LogicalType> members); // NOLINT
1143
1147
  DUCKDB_API static LogicalType ENUM(const string &enum_name, Vector &ordered_data, idx_t size); // NOLINT
1144
1148
  DUCKDB_API static LogicalType DEDUP_POINTER_ENUM(); // NOLINT
1145
1149
  DUCKDB_API static LogicalType USER(const string &user_type_name); // NOLINT
@@ -1192,6 +1196,14 @@ struct MapType {
1192
1196
  DUCKDB_API static const LogicalType &ValueType(const LogicalType &type);
1193
1197
  };
1194
1198
 
1199
+ struct UnionType {
1200
+ DUCKDB_API static const idx_t MAX_UNION_MEMBERS = 256;
1201
+ DUCKDB_API static idx_t GetMemberCount(const LogicalType &type);
1202
+ DUCKDB_API static const LogicalType &GetMemberType(const LogicalType &type, idx_t index);
1203
+ DUCKDB_API static const string &GetMemberName(const LogicalType &type, idx_t index);
1204
+ DUCKDB_API static const child_list_t<LogicalType> CopyMemberTypes(const LogicalType &type);
1205
+ };
1206
+
1195
1207
  struct AggregateStateType {
1196
1208
  DUCKDB_API static const string GetTypeName(const LogicalType &type);
1197
1209
  DUCKDB_API static const aggregate_state_t &GetStateType(const LogicalType &type);
@@ -2893,6 +2905,7 @@ class Value {
2893
2905
  friend struct StringValue;
2894
2906
  friend struct StructValue;
2895
2907
  friend struct ListValue;
2908
+ friend struct UnionValue;
2896
2909
 
2897
2910
  public:
2898
2911
  //! Create an empty NULL value of the specified type
@@ -3021,6 +3034,8 @@ public:
3021
3034
  DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
3022
3035
  //! Create a map value from a (key, value) pair
3023
3036
  DUCKDB_API static Value MAP(Value key, Value value);
3037
+ //! Create a union value from a selected value and a tag from a set of alternatives.
3038
+ DUCKDB_API static Value UNION(child_list_t<LogicalType> members, uint8_t tag, Value value);
3024
3039
 
3025
3040
  //! Create a blob Value from a data pointer and a length: no bytes are interpreted
3026
3041
  DUCKDB_API static Value BLOB(const_data_ptr_t data, idx_t len);
@@ -3258,6 +3273,11 @@ struct ListValue {
3258
3273
  DUCKDB_API static const vector<Value> &GetChildren(const Value &value);
3259
3274
  };
3260
3275
 
3276
+ struct UnionValue {
3277
+ DUCKDB_API static const Value &GetValue(const Value &value);
3278
+ DUCKDB_API static uint8_t GetTag(const Value &value);
3279
+ };
3280
+
3261
3281
  //! Return the internal integral value for any type that is stored as an integral value internally
3262
3282
  //! This can be used on values of type integer, uinteger, but also date, timestamp, decimal, etc
3263
3283
  struct IntegralValue {
@@ -4182,6 +4202,7 @@ class Vector {
4182
4202
  friend struct StringVector;
4183
4203
  friend struct FSSTVector;
4184
4204
  friend struct StructVector;
4205
+ friend struct UnionVector;
4185
4206
  friend struct SequenceVector;
4186
4207
 
4187
4208
  friend class DataChunk;
@@ -4272,6 +4293,7 @@ public:
4272
4293
  DUCKDB_API void Verify(idx_t count);
4273
4294
  //! Asserts that the CheckMapValidity returns MapInvalidReason::VALID
4274
4295
  DUCKDB_API static void VerifyMap(Vector &map, const SelectionVector &sel, idx_t count);
4296
+ DUCKDB_API static void VerifyUnion(Vector &map, const SelectionVector &sel, idx_t count);
4275
4297
  DUCKDB_API static void Verify(Vector &vector, const SelectionVector &sel, idx_t count);
4276
4298
  DUCKDB_API void UTFVerify(idx_t count);
4277
4299
  DUCKDB_API void UTFVerify(const SelectionVector &sel, idx_t count);
@@ -4552,6 +4574,41 @@ struct StructVector {
4552
4574
  DUCKDB_API static vector<unique_ptr<Vector>> &GetEntries(Vector &vector);
4553
4575
  };
4554
4576
 
4577
+ struct UnionVector {
4578
+ // Unions are stored as structs, but the first child is always the "tag"
4579
+ // vector, specifying the currently selected member for that row.
4580
+ // The remaining children are the members of the union.
4581
+ // INVARIANTS:
4582
+ // 1. Only one member vector (the one "selected" by the tag) can be
4583
+ // non-NULL in each row.
4584
+ //
4585
+ // 2. The validity of the tag vector always matches the validity of the
4586
+ // union vector itself.
4587
+ //
4588
+ // 3. For each tag in the tag vector, 0 <= tag < |members|
4589
+
4590
+ //! Get the tag vector of a union vector
4591
+ DUCKDB_API static const Vector &GetTags(const Vector &v);
4592
+ DUCKDB_API static Vector &GetTags(Vector &v);
4593
+
4594
+ //! Get the tag at the specific index of the union vector
4595
+ DUCKDB_API static union_tag_t GetTag(const Vector &vector, idx_t index);
4596
+
4597
+ //! Get the member vector of a union vector by index
4598
+ DUCKDB_API static const Vector &GetMember(const Vector &vector, idx_t member_index);
4599
+ DUCKDB_API static Vector &GetMember(Vector &vector, idx_t member_index);
4600
+
4601
+ //! Set every entry in the UnionVector to a specific member.
4602
+ //! This is useful to set the entire vector to a single member, e.g. when "creating"
4603
+ //! a union to return in a function, when you only have one alternative to return.
4604
+ //! if 'keep_tags_for_null' is false, the tags will be set to NULL where the member is NULL.
4605
+ //! (the validity of the tag vector will match the selected member vector)
4606
+ //! otherwise, they are all set to the 'tag'.
4607
+ //! This will also handle invalidation of the non-selected members
4608
+ DUCKDB_API static void SetToMember(Vector &vector, union_tag_t tag, Vector &member_vector, idx_t count,
4609
+ bool keep_tags_for_null);
4610
+ };
4611
+
4555
4612
  struct SequenceVector {
4556
4613
  static void GetSequence(const Vector &vector, int64_t &start, int64_t &increment, int64_t &sequence_count) {
4557
4614
  D_ASSERT(vector.GetVectorType() == VectorType::SEQUENCE_VECTOR);
@@ -15090,6 +15147,8 @@ typedef enum DUCKDB_TYPE {
15090
15147
  DUCKDB_TYPE_UUID,
15091
15148
  // const char*
15092
15149
  DUCKDB_TYPE_JSON,
15150
+ // union type, only useful as logical type
15151
+ DUCKDB_TYPE_UNION,
15093
15152
  } duckdb_type;
15094
15153
 
15095
15154
  //! Days are stored as days since 1970-01-01
@@ -18536,7 +18595,11 @@ private:
18536
18595
  const LogicalType &target);
18537
18596
  static BoundCastInfo TimestampSecCastSwitch(BindCastInput &input, const LogicalType &source,
18538
18597
  const LogicalType &target);
18598
+ static BoundCastInfo UnionCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
18539
18599
  static BoundCastInfo UUIDCastSwitch(BindCastInput &input, const LogicalType &source, const LogicalType &target);
18600
+
18601
+ static BoundCastInfo ImplicitToUnionCast(BindCastInput &input, const LogicalType &source,
18602
+ const LogicalType &target);
18540
18603
  };
18541
18604
 
18542
18605
  } // namespace duckdb