-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update vendored DuckDB sources to 39f8f72
- Loading branch information
1 parent
39f8f72
commit 8765850
Showing
12 changed files
with
71 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/duckdb/src/include/duckdb/common/extra_type_info/enum_type_info.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include "duckdb/common/extra_type_info.hpp" | ||
#include "duckdb/common/serializer/deserializer.hpp" | ||
#include "duckdb/common/string_map_set.hpp" | ||
|
||
namespace duckdb { | ||
|
||
template <class T> | ||
struct EnumTypeInfoTemplated : public EnumTypeInfo { | ||
explicit EnumTypeInfoTemplated(Vector &values_insert_order_p, idx_t size_p) | ||
: EnumTypeInfo(values_insert_order_p, size_p) { | ||
D_ASSERT(values_insert_order_p.GetType().InternalType() == PhysicalType::VARCHAR); | ||
|
||
UnifiedVectorFormat vdata; | ||
values_insert_order.ToUnifiedFormat(size_p, vdata); | ||
|
||
auto data = UnifiedVectorFormat::GetData<string_t>(vdata); | ||
for (idx_t i = 0; i < size_p; i++) { | ||
auto idx = vdata.sel->get_index(i); | ||
if (!vdata.validity.RowIsValid(idx)) { | ||
throw InternalException("Attempted to create ENUM type with NULL value"); | ||
} | ||
if (values.count(data[idx]) > 0) { | ||
throw InvalidInputException("Attempted to create ENUM type with duplicate value %s", | ||
data[idx].GetString()); | ||
} | ||
values[data[idx]] = UnsafeNumericCast<T>(i); | ||
} | ||
} | ||
|
||
static shared_ptr<EnumTypeInfoTemplated> Deserialize(Deserializer &deserializer, uint32_t size) { | ||
Vector values_insert_order(LogicalType::VARCHAR, size); | ||
auto strings = FlatVector::GetData<string_t>(values_insert_order); | ||
|
||
deserializer.ReadList(201, "values", [&](Deserializer::List &list, idx_t i) { | ||
strings[i] = StringVector::AddStringOrBlob(values_insert_order, list.ReadElement<string>()); | ||
}); | ||
return make_shared_ptr<EnumTypeInfoTemplated>(values_insert_order, size); | ||
} | ||
|
||
const string_map_t<T> &GetValues() const { | ||
return values; | ||
} | ||
|
||
EnumTypeInfoTemplated(const EnumTypeInfoTemplated &) = delete; | ||
EnumTypeInfoTemplated &operator=(const EnumTypeInfoTemplated &) = delete; | ||
|
||
private: | ||
string_map_t<T> values; | ||
}; | ||
|
||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters