Skip to content

Commit 3a18f9a

Browse files
duckdblabs-botbrianwyka
authored andcommitted
Update vendored DuckDB sources to c2eee7c
1 parent 2b9d96e commit 3a18f9a

File tree

24 files changed

+340
-228
lines changed

24 files changed

+340
-228
lines changed

src/duckdb/src/common/extra_type_info.cpp

+56-13
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@
1010
namespace duckdb {
1111

1212
//===--------------------------------------------------------------------===//
13-
// Extra Type Info
13+
// Extension Type Info
1414
//===--------------------------------------------------------------------===//
15-
ExtraTypeInfo::ExtraTypeInfo(ExtraTypeInfoType type) : type(type) {
16-
}
17-
ExtraTypeInfo::ExtraTypeInfo(ExtraTypeInfoType type, string alias) : type(type), alias(std::move(alias)) {
18-
}
19-
ExtraTypeInfo::~ExtraTypeInfo() {
20-
}
21-
shared_ptr<ExtraTypeInfo> ExtraTypeInfo::Copy() const {
22-
return make_shared_ptr<ExtraTypeInfo>(*this);
23-
}
2415

2516
static bool CompareModifiers(const vector<Value> &left, const vector<Value> &right) {
2617
// Check if the common prefix of the properties is the same for both types
27-
auto common_props = MinValue(left.size(), right.size());
18+
const auto common_props = MinValue(left.size(), right.size());
2819
for (idx_t i = 0; i < common_props; i++) {
2920
if (left[i].type() != right[i].type()) {
3021
return false;
@@ -34,13 +25,65 @@ static bool CompareModifiers(const vector<Value> &left, const vector<Value> &rig
3425
if (left[i].IsNull() || right[i].IsNull()) {
3526
continue;
3627
}
28+
3729
if (left[i] != right[i]) {
3830
return false;
3931
}
4032
}
4133
return true;
4234
}
4335

36+
bool ExtensionTypeInfo::Equals(optional_ptr<ExtensionTypeInfo> other_p) const {
37+
if (other_p == nullptr) {
38+
return false;
39+
}
40+
if (!CompareModifiers(modifiers, other_p->modifiers)) {
41+
return false;
42+
}
43+
44+
// Properties are optional, so only compare those present in both
45+
for (auto &kv : properties) {
46+
auto it = other_p->properties.find(kv.first);
47+
if (it == other_p->properties.end()) {
48+
continue;
49+
}
50+
if (kv.second != it->second) {
51+
return false;
52+
}
53+
}
54+
55+
return true;
56+
}
57+
58+
//===--------------------------------------------------------------------===//
59+
// Extra Type Info
60+
//===--------------------------------------------------------------------===//
61+
ExtraTypeInfo::ExtraTypeInfo(ExtraTypeInfoType type) : type(type) {
62+
}
63+
ExtraTypeInfo::ExtraTypeInfo(ExtraTypeInfoType type, string alias) : type(type), alias(std::move(alias)) {
64+
}
65+
ExtraTypeInfo::~ExtraTypeInfo() {
66+
}
67+
68+
ExtraTypeInfo::ExtraTypeInfo(const ExtraTypeInfo &other) : type(other.type), alias(other.alias) {
69+
if (other.extension_info) {
70+
extension_info = make_uniq<ExtensionTypeInfo>(*other.extension_info);
71+
}
72+
}
73+
74+
ExtraTypeInfo &ExtraTypeInfo::operator=(const ExtraTypeInfo &other) {
75+
type = other.type;
76+
alias = other.alias;
77+
if (other.extension_info) {
78+
extension_info = make_uniq<ExtensionTypeInfo>(*other.extension_info);
79+
}
80+
return *this;
81+
}
82+
83+
shared_ptr<ExtraTypeInfo> ExtraTypeInfo::Copy() const {
84+
return shared_ptr<ExtraTypeInfo>(new ExtraTypeInfo(*this));
85+
}
86+
4487
bool ExtraTypeInfo::Equals(ExtraTypeInfo *other_p) const {
4588
if (type == ExtraTypeInfoType::INVALID_TYPE_INFO || type == ExtraTypeInfoType::STRING_TYPE_INFO ||
4689
type == ExtraTypeInfoType::GENERIC_TYPE_INFO) {
@@ -54,7 +97,7 @@ bool ExtraTypeInfo::Equals(ExtraTypeInfo *other_p) const {
5497
if (alias != other_p->alias) {
5598
return false;
5699
}
57-
if (!CompareModifiers(modifiers, other_p->modifiers)) {
100+
if (extension_info && !extension_info->Equals(other_p->extension_info.get())) {
58101
return false;
59102
}
60103
return true;
@@ -68,7 +111,7 @@ bool ExtraTypeInfo::Equals(ExtraTypeInfo *other_p) const {
68111
if (alias != other_p->alias) {
69112
return false;
70113
}
71-
if (!CompareModifiers(modifiers, other_p->modifiers)) {
114+
if (extension_info && !extension_info->Equals(other_p->extension_info.get())) {
72115
return false;
73116
}
74117
return EqualsInternal(other_p);

src/duckdb/src/common/progress_bar/progress_bar.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@ void ProgressBar::Update(bool final) {
130130
query_progress.percentage = new_percentage;
131131
}
132132
if (ShouldPrint(final)) {
133-
#ifndef DUCKDB_DISABLE_PRINT
134133
if (final) {
135134
FinishProgressBarPrint();
136135
} else {
137136
PrintProgress(LossyNumericCast<int>(query_progress.percentage.load()));
138137
}
139-
#endif
140138
}
141139
}
142140

src/duckdb/src/common/types.cpp

+34-52
Original file line numberDiff line numberDiff line change
@@ -365,21 +365,29 @@ bool TypeIsInteger(PhysicalType type) {
365365
type == PhysicalType::UINT128;
366366
}
367367

368+
static string TypeModifierListToString(const vector<Value> &mod_list) {
369+
string result;
370+
if (mod_list.empty()) {
371+
return result;
372+
}
373+
result = "(";
374+
for (idx_t i = 0; i < mod_list.size(); i++) {
375+
result += mod_list[i].ToString();
376+
if (i < mod_list.size() - 1) {
377+
result += ", ";
378+
}
379+
}
380+
result += ")";
381+
return result;
382+
}
383+
368384
string LogicalType::ToString() const {
369385
if (id_ != LogicalTypeId::USER) {
370386
auto alias = GetAlias();
371387
if (!alias.empty()) {
372-
auto mods_ptr = GetModifiers();
373-
if (mods_ptr && !mods_ptr->empty()) {
374-
auto &mods = *mods_ptr;
375-
alias += "(";
376-
for (idx_t i = 0; i < mods.size(); i++) {
377-
alias += mods[i].ToString();
378-
if (i < mods.size() - 1) {
379-
alias += ", ";
380-
}
381-
}
382-
alias += ")";
388+
if (HasExtensionInfo()) {
389+
auto &ext_info = *GetExtensionInfo();
390+
alias += TypeModifierListToString(ext_info.modifiers);
383391
}
384392
return alias;
385393
}
@@ -491,14 +499,7 @@ string LogicalType::ToString() const {
491499
result += KeywordHelper::WriteOptionallyQuoted(type);
492500

493501
if (!mods.empty()) {
494-
result += "(";
495-
for (idx_t i = 0; i < mods.size(); i++) {
496-
result += mods[i].ToString();
497-
if (i < mods.size() - 1) {
498-
result += ", ";
499-
}
500-
}
501-
result += ")";
502+
result += TypeModifierListToString(mods);
502503
}
503504

504505
return result;
@@ -1360,51 +1361,32 @@ bool LogicalType::HasAlias() const {
13601361
return false;
13611362
}
13621363

1363-
void LogicalType::SetModifiers(vector<Value> modifiers) {
1364-
if (!type_info_ && !modifiers.empty()) {
1365-
type_info_ = make_shared_ptr<ExtraTypeInfo>(ExtraTypeInfoType::GENERIC_TYPE_INFO);
1366-
}
1367-
type_info_->modifiers = std::move(modifiers);
1368-
}
1369-
1370-
bool LogicalType::HasModifiers() const {
1371-
if (id() == LogicalTypeId::USER) {
1372-
return !UserType::GetTypeModifiers(*this).empty();
1373-
}
1374-
if (type_info_) {
1375-
return !type_info_->modifiers.empty();
1364+
bool LogicalType::HasExtensionInfo() const {
1365+
if (type_info_ && type_info_->extension_info) {
1366+
return true;
13761367
}
13771368
return false;
13781369
}
13791370

1380-
vector<Value> LogicalType::GetModifiersCopy() const {
1381-
if (id() == LogicalTypeId::USER) {
1382-
return UserType::GetTypeModifiers(*this);
1383-
}
1384-
if (type_info_) {
1385-
return type_info_->modifiers;
1371+
optional_ptr<const ExtensionTypeInfo> LogicalType::GetExtensionInfo() const {
1372+
if (type_info_ && type_info_->extension_info) {
1373+
return type_info_->extension_info.get();
13861374
}
1387-
return {};
1375+
return nullptr;
13881376
}
13891377

1390-
optional_ptr<vector<Value>> LogicalType::GetModifiers() {
1391-
if (id() == LogicalTypeId::USER) {
1392-
return UserType::GetTypeModifiers(*this);
1393-
}
1394-
if (type_info_) {
1395-
return type_info_->modifiers;
1378+
optional_ptr<ExtensionTypeInfo> LogicalType::GetExtensionInfo() {
1379+
if (type_info_ && type_info_->extension_info) {
1380+
return type_info_->extension_info.get();
13961381
}
13971382
return nullptr;
13981383
}
13991384

1400-
optional_ptr<const vector<Value>> LogicalType::GetModifiers() const {
1401-
if (id() == LogicalTypeId::USER) {
1402-
return UserType::GetTypeModifiers(*this);
1403-
}
1404-
if (type_info_) {
1405-
return type_info_->modifiers;
1385+
void LogicalType::SetExtensionInfo(unique_ptr<ExtensionTypeInfo> info) {
1386+
if (!type_info_) {
1387+
type_info_ = make_shared_ptr<ExtraTypeInfo>(ExtraTypeInfoType::GENERIC_TYPE_INFO);
14061388
}
1407-
return nullptr;
1389+
type_info_->extension_info = std::move(info);
14081390
}
14091391

14101392
//===--------------------------------------------------------------------===//

src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ SourceResultType PhysicalCopyDatabase::GetData(ExecutionContext &context, DataCh
4242
catalog.CreateType(context.client, create_info->Cast<CreateTypeInfo>());
4343
break;
4444
case CatalogType::MACRO_ENTRY:
45+
case CatalogType::TABLE_MACRO_ENTRY:
4546
catalog.CreateFunction(context.client, create_info->Cast<CreateMacroInfo>());
4647
break;
4748
case CatalogType::TABLE_ENTRY: {

src/duckdb/src/execution/physical_plan/plan_get.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalGet &op) {
160160
vector<unique_ptr<Expression>> expressions;
161161
for (auto &column_id : column_ids) {
162162
if (column_id.IsRowIdColumn()) {
163-
types.emplace_back(LogicalType::ROW_TYPE);
164-
expressions.push_back(make_uniq<BoundConstantExpression>(Value::BIGINT(0)));
163+
types.emplace_back(op.GetRowIdType());
164+
// Now how to make that a constant expression.
165+
expressions.push_back(make_uniq<BoundConstantExpression>(Value(op.GetRowIdType())));
165166
} else {
166167
auto col_id = column_id.GetPrimaryIndex();
167168
auto type = op.returned_types[col_id];

src/duckdb/src/function/table/arrow_conversion.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -1340,17 +1340,31 @@ static void ColumnArrowToDuckDBDictionary(Vector &vector, ArrowArray &array, Arr
13401340
}
13411341

13421342
void ArrowTableFunction::ArrowToDuckDB(ArrowScanLocalState &scan_state, const arrow_column_map_t &arrow_convert_data,
1343-
DataChunk &output, idx_t start, bool arrow_scan_is_projected) {
1343+
DataChunk &output, idx_t start, bool arrow_scan_is_projected,
1344+
idx_t rowid_column_index) {
13441345
for (idx_t idx = 0; idx < output.ColumnCount(); idx++) {
13451346
auto col_idx = scan_state.column_ids.empty() ? idx : scan_state.column_ids[idx];
13461347

13471348
// If projection was not pushed down into the arrow scanner, but projection pushdown is enabled on the
13481349
// table function, we need to use original column ids here.
13491350
auto arrow_array_idx = arrow_scan_is_projected ? idx : col_idx;
13501351

1351-
if (col_idx == COLUMN_IDENTIFIER_ROW_ID) {
1352-
// This column is skipped by the projection pushdown
1353-
continue;
1352+
if (rowid_column_index != COLUMN_IDENTIFIER_ROW_ID) {
1353+
if (col_idx == COLUMN_IDENTIFIER_ROW_ID) {
1354+
arrow_array_idx = rowid_column_index;
1355+
} else if (col_idx >= rowid_column_index) {
1356+
// Since the rowid column is skipped when the table is bound (its not a named column),
1357+
// we need to shift references forward in the Arrow array by one to match the alignment
1358+
// that DuckDB believes the Arrow array is in.
1359+
col_idx += 1;
1360+
arrow_array_idx += 1;
1361+
}
1362+
} else {
1363+
// If there isn't any defined row_id_index, and we're asked for it, skip the column.
1364+
// This is the incumbent behavior.
1365+
if (col_idx == COLUMN_IDENTIFIER_ROW_ID) {
1366+
continue;
1367+
}
13541368
}
13551369

13561370
auto &parent_array = scan_state.chunk->arrow_array;

src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class TableCatalogEntry : public StandardEntry {
117117
//! Returns true, if the table has a primary key, else false.
118118
bool HasPrimaryKey() const;
119119

120+
//! Returns the rowid type of this table
121+
virtual LogicalType GetRowIdType() const {
122+
return LogicalType::ROW_TYPE;
123+
}
124+
120125
protected:
121126
//! A list of columns that are part of this table
122127
ColumnList columns;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include "duckdb/common/string.hpp"
4+
#include "duckdb/common/types/value.hpp"
5+
#include "duckdb/common/serializer/serializer.hpp"
6+
7+
namespace duckdb {
8+
9+
struct ExtensionTypeInfo {
10+
vector<Value> modifiers;
11+
unordered_map<string, Value> properties;
12+
13+
public:
14+
void Serialize(Serializer &serializer) const;
15+
static unique_ptr<ExtensionTypeInfo> Deserialize(Deserializer &source);
16+
bool Equals(optional_ptr<ExtensionTypeInfo> other_p) const;
17+
};
18+
19+
} // namespace duckdb

src/duckdb/src/include/duckdb/common/extra_type_info.hpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "duckdb/common/common.hpp"
1212
#include "duckdb/common/types/vector.hpp"
13+
#include "duckdb/common/extension_type_info.hpp"
1314

1415
namespace duckdb {
1516

@@ -30,13 +31,18 @@ enum class ExtraTypeInfoType : uint8_t {
3031
};
3132

3233
struct ExtraTypeInfo {
34+
ExtraTypeInfoType type;
35+
string alias;
36+
unique_ptr<ExtensionTypeInfo> extension_info;
37+
3338
explicit ExtraTypeInfo(ExtraTypeInfoType type);
3439
explicit ExtraTypeInfo(ExtraTypeInfoType type, string alias);
3540
virtual ~ExtraTypeInfo();
3641

37-
ExtraTypeInfoType type;
38-
string alias;
39-
vector<Value> modifiers;
42+
protected:
43+
// copy constructor (protected)
44+
ExtraTypeInfo(const ExtraTypeInfo &other);
45+
ExtraTypeInfo &operator=(const ExtraTypeInfo &other);
4046

4147
public:
4248
bool Equals(ExtraTypeInfo *other_p) const;

src/duckdb/src/include/duckdb/common/types.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ enum class LogicalTypeId : uint8_t {
234234
};
235235

236236
struct ExtraTypeInfo;
237+
struct ExtensionTypeInfo;
237238

238239
struct aggregate_state_t; // NOLINT: mimic std casing
239240

@@ -323,11 +324,11 @@ struct LogicalType {
323324
DUCKDB_API void SetAlias(string alias);
324325
DUCKDB_API bool HasAlias() const;
325326
DUCKDB_API string GetAlias() const;
326-
DUCKDB_API void SetModifiers(vector<Value> modifiers);
327-
DUCKDB_API bool HasModifiers() const;
328-
DUCKDB_API vector<Value> GetModifiersCopy() const;
329-
DUCKDB_API optional_ptr<vector<Value>> GetModifiers();
330-
DUCKDB_API optional_ptr<const vector<Value>> GetModifiers() const;
327+
328+
DUCKDB_API bool HasExtensionInfo() const;
329+
DUCKDB_API optional_ptr<const ExtensionTypeInfo> GetExtensionInfo() const;
330+
DUCKDB_API optional_ptr<ExtensionTypeInfo> GetExtensionInfo();
331+
DUCKDB_API void SetExtensionInfo(unique_ptr<ExtensionTypeInfo> info);
331332

332333
//! Returns the maximum logical type when combining the two types - or throws an exception if combining is not possible
333334
DUCKDB_API static LogicalType MaxLogicalType(ClientContext &context, const LogicalType &left, const LogicalType &right);

src/duckdb/src/include/duckdb/function/table/arrow.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ struct ArrowTableFunction {
190190
vector<LogicalType> &return_types, vector<string> &names);
191191
//! Actual conversion from Arrow to DuckDB
192192
static void ArrowToDuckDB(ArrowScanLocalState &scan_state, const arrow_column_map_t &arrow_convert_data,
193-
DataChunk &output, idx_t start, bool arrow_scan_is_projected = true);
193+
DataChunk &output, idx_t start, bool arrow_scan_is_projected = true,
194+
idx_t rowid_column_index = COLUMN_IDENTIFIER_ROW_ID);
194195

195196
//! Get next scan state
196197
static bool ArrowScanParallelStateNext(ClientContext &context, const FunctionData *bind_data_p,

0 commit comments

Comments
 (0)