duckdb 0.3.5-dev164.0 → 0.3.5-dev175.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 +1 -1
- package/src/duckdb.cpp +88 -18
- package/src/duckdb.hpp +498 -499
- package/src/parquet-amalgamation.cpp +22928 -22928
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -1237,8 +1237,8 @@ namespace duckdb {
|
|
|
1237
1237
|
class TableMacroFunction : public MacroFunction {
|
|
1238
1238
|
public:
|
|
1239
1239
|
TableMacroFunction(unique_ptr<QueryNode> query_node);
|
|
1240
|
-
|
|
1241
1240
|
TableMacroFunction(void);
|
|
1241
|
+
|
|
1242
1242
|
//! The main query node
|
|
1243
1243
|
unique_ptr<QueryNode> query_node;
|
|
1244
1244
|
|
|
@@ -1427,10 +1427,15 @@ public:
|
|
|
1427
1427
|
SchemaCatalogEntry *schema;
|
|
1428
1428
|
|
|
1429
1429
|
DUCKDB_API static unique_ptr<CreateMacroInfo> CreateInternalMacroInfo(DefaultMacro &default_macro);
|
|
1430
|
+
DUCKDB_API static unique_ptr<CreateMacroInfo> CreateInternalTableMacroInfo(DefaultMacro &default_macro);
|
|
1430
1431
|
|
|
1431
1432
|
public:
|
|
1432
1433
|
unique_ptr<CatalogEntry> CreateDefaultEntry(ClientContext &context, const string &entry_name) override;
|
|
1433
1434
|
vector<string> GetDefaultEntries() override;
|
|
1435
|
+
|
|
1436
|
+
private:
|
|
1437
|
+
static unique_ptr<CreateMacroInfo> CreateInternalTableMacroInfo(DefaultMacro &default_macro,
|
|
1438
|
+
unique_ptr<MacroFunction> function);
|
|
1434
1439
|
};
|
|
1435
1440
|
|
|
1436
1441
|
} // namespace duckdb
|
|
@@ -4610,6 +4615,7 @@ void CatalogSet::Scan(const std::function<void(CatalogEntry *)> &callback) {
|
|
|
4610
4615
|
|
|
4611
4616
|
|
|
4612
4617
|
|
|
4618
|
+
|
|
4613
4619
|
namespace duckdb {
|
|
4614
4620
|
|
|
4615
4621
|
static DefaultMacro internal_macros[] = {
|
|
@@ -4735,14 +4741,9 @@ static DefaultMacro internal_macros[] = {
|
|
|
4735
4741
|
{nullptr, nullptr, {nullptr}, nullptr}
|
|
4736
4742
|
};
|
|
4737
4743
|
|
|
4738
|
-
unique_ptr<CreateMacroInfo> DefaultFunctionGenerator::
|
|
4739
|
-
// parse the expression
|
|
4740
|
-
auto expressions = Parser::ParseExpressionList(default_macro.macro);
|
|
4741
|
-
D_ASSERT(expressions.size() == 1);
|
|
4742
|
-
|
|
4743
|
-
auto result = make_unique<ScalarMacroFunction>(move(expressions[0]));
|
|
4744
|
+
unique_ptr<CreateMacroInfo> DefaultFunctionGenerator::CreateInternalTableMacroInfo(DefaultMacro &default_macro, unique_ptr<MacroFunction> function) {
|
|
4744
4745
|
for (idx_t param_idx = 0; default_macro.parameters[param_idx] != nullptr; param_idx++) {
|
|
4745
|
-
|
|
4746
|
+
function->parameters.push_back(
|
|
4746
4747
|
make_unique<ColumnRefExpression>(default_macro.parameters[param_idx]));
|
|
4747
4748
|
}
|
|
4748
4749
|
|
|
@@ -4751,8 +4752,30 @@ unique_ptr<CreateMacroInfo> DefaultFunctionGenerator::CreateInternalMacroInfo(De
|
|
|
4751
4752
|
bind_info->name = default_macro.name;
|
|
4752
4753
|
bind_info->temporary = true;
|
|
4753
4754
|
bind_info->internal = true;
|
|
4754
|
-
bind_info->
|
|
4755
|
+
bind_info->type = function->type == MacroType::TABLE_MACRO ? CatalogType::TABLE_MACRO_ENTRY : CatalogType::MACRO_ENTRY;
|
|
4756
|
+
bind_info->function = move(function);
|
|
4755
4757
|
return bind_info;
|
|
4758
|
+
|
|
4759
|
+
}
|
|
4760
|
+
|
|
4761
|
+
unique_ptr<CreateMacroInfo> DefaultFunctionGenerator::CreateInternalMacroInfo(DefaultMacro &default_macro) {
|
|
4762
|
+
// parse the expression
|
|
4763
|
+
auto expressions = Parser::ParseExpressionList(default_macro.macro);
|
|
4764
|
+
D_ASSERT(expressions.size() == 1);
|
|
4765
|
+
|
|
4766
|
+
auto result = make_unique<ScalarMacroFunction>(move(expressions[0]));
|
|
4767
|
+
return CreateInternalTableMacroInfo(default_macro, move(result));
|
|
4768
|
+
}
|
|
4769
|
+
|
|
4770
|
+
unique_ptr<CreateMacroInfo> DefaultFunctionGenerator::CreateInternalTableMacroInfo(DefaultMacro &default_macro) {
|
|
4771
|
+
Parser parser;
|
|
4772
|
+
parser.ParseQuery(default_macro.macro);
|
|
4773
|
+
D_ASSERT(parser.statements.size() == 1);
|
|
4774
|
+
D_ASSERT(parser.statements[0]->type == StatementType::SELECT_STATEMENT);
|
|
4775
|
+
|
|
4776
|
+
auto &select = (SelectStatement &) *parser.statements[0];
|
|
4777
|
+
auto result = make_unique<TableMacroFunction>(move(select.node));
|
|
4778
|
+
return CreateInternalTableMacroInfo(default_macro, move(result));
|
|
4756
4779
|
}
|
|
4757
4780
|
|
|
4758
4781
|
static unique_ptr<CreateFunctionInfo> GetDefaultFunction(const string &input_schema, const string &input_name) {
|
|
@@ -51502,7 +51525,7 @@ void ART::VerifyExistence(DataChunk &chunk, VerifyExistenceType verify_type, str
|
|
|
51502
51525
|
case VerifyExistenceType::APPEND_FK: {
|
|
51503
51526
|
// found node no exists in tree
|
|
51504
51527
|
exception_msg =
|
|
51505
|
-
"violates foreign key constraint because key \"" + key_name + "\"
|
|
51528
|
+
"violates foreign key constraint because key \"" + key_name + "\" does not exist in referenced table";
|
|
51506
51529
|
break;
|
|
51507
51530
|
}
|
|
51508
51531
|
case VerifyExistenceType::DELETE_FK: {
|
|
@@ -63569,7 +63592,7 @@ void BufferedCSVReaderOptions::SetDelimiter(const string &input) {
|
|
|
63569
63592
|
this->delimiter = StringUtil::Replace(input, "\\t", "\t");
|
|
63570
63593
|
this->has_delimiter = true;
|
|
63571
63594
|
if (input.empty()) {
|
|
63572
|
-
|
|
63595
|
+
this->delimiter = string("\0", 1);
|
|
63573
63596
|
}
|
|
63574
63597
|
}
|
|
63575
63598
|
|
|
@@ -147892,6 +147915,9 @@ unique_ptr<TableRef> SubqueryRef::Deserialize(FieldReader &reader) {
|
|
|
147892
147915
|
|
|
147893
147916
|
namespace duckdb {
|
|
147894
147917
|
|
|
147918
|
+
TableFunctionRef::TableFunctionRef() : TableRef(TableReferenceType::TABLE_FUNCTION) {
|
|
147919
|
+
}
|
|
147920
|
+
|
|
147895
147921
|
string TableFunctionRef::ToString() const {
|
|
147896
147922
|
return BaseToString(function->ToString(), column_name_alias);
|
|
147897
147923
|
}
|
|
@@ -148074,10 +148100,12 @@ unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGLis
|
|
|
148074
148100
|
for (auto kc = constraint->fk_attrs->head; kc; kc = kc->next) {
|
|
148075
148101
|
fk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
|
148076
148102
|
}
|
|
148077
|
-
|
|
148078
|
-
|
|
148103
|
+
if (constraint->pk_attrs) {
|
|
148104
|
+
for (auto kc = constraint->pk_attrs->head; kc; kc = kc->next) {
|
|
148105
|
+
pk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
|
148106
|
+
}
|
|
148079
148107
|
}
|
|
148080
|
-
if (pk_columns.size() != fk_columns.size()) {
|
|
148108
|
+
if (!pk_columns.empty() && pk_columns.size() != fk_columns.size()) {
|
|
148081
148109
|
throw ParserException("The number of referencing and referenced columns for foreign keys must be the same");
|
|
148082
148110
|
}
|
|
148083
148111
|
if (fk_columns.empty()) {
|
|
@@ -157087,6 +157115,7 @@ public:
|
|
|
157087
157115
|
|
|
157088
157116
|
|
|
157089
157117
|
|
|
157118
|
+
|
|
157090
157119
|
namespace duckdb {
|
|
157091
157120
|
|
|
157092
157121
|
SchemaCatalogEntry *Binder::BindSchema(CreateInfo &info) {
|
|
@@ -157211,6 +157240,35 @@ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, const st
|
|
|
157211
157240
|
}
|
|
157212
157241
|
}
|
|
157213
157242
|
|
|
157243
|
+
static void FindMatchingPrimaryKeyColumns(vector<unique_ptr<Constraint>> &constraints, ForeignKeyConstraint &fk) {
|
|
157244
|
+
if (!fk.pk_columns.empty()) {
|
|
157245
|
+
return;
|
|
157246
|
+
}
|
|
157247
|
+
// find the matching primary key constraint
|
|
157248
|
+
for (auto &constr : constraints) {
|
|
157249
|
+
if (constr->type != ConstraintType::UNIQUE) {
|
|
157250
|
+
continue;
|
|
157251
|
+
}
|
|
157252
|
+
auto &unique = (UniqueConstraint &)*constr;
|
|
157253
|
+
if (!unique.is_primary_key) {
|
|
157254
|
+
continue;
|
|
157255
|
+
}
|
|
157256
|
+
idx_t column_count;
|
|
157257
|
+
if (unique.index != DConstants::INVALID_INDEX) {
|
|
157258
|
+
fk.info.pk_keys.push_back(unique.index);
|
|
157259
|
+
column_count = 1;
|
|
157260
|
+
} else {
|
|
157261
|
+
fk.pk_columns = unique.columns;
|
|
157262
|
+
column_count = unique.columns.size();
|
|
157263
|
+
}
|
|
157264
|
+
if (column_count != fk.fk_columns.size()) {
|
|
157265
|
+
throw BinderException("The number of referencing and referenced columns for foreign keys must be the same");
|
|
157266
|
+
}
|
|
157267
|
+
return;
|
|
157268
|
+
}
|
|
157269
|
+
throw BinderException("there is no primary key for referenced table \"%s\"", fk.info.table);
|
|
157270
|
+
}
|
|
157271
|
+
|
|
157214
157272
|
BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
157215
157273
|
BoundStatement result;
|
|
157216
157274
|
result.names = {"Count"};
|
|
@@ -157291,13 +157349,15 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
157291
157349
|
if (fk.info.type != ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE) {
|
|
157292
157350
|
continue;
|
|
157293
157351
|
}
|
|
157294
|
-
D_ASSERT(fk.info.pk_keys.empty()
|
|
157352
|
+
D_ASSERT(fk.info.pk_keys.empty());
|
|
157295
157353
|
if (create_info.table == fk.info.table) {
|
|
157296
157354
|
fk.info.type = ForeignKeyType::FK_TYPE_SELF_REFERENCE_TABLE;
|
|
157355
|
+
FindMatchingPrimaryKeyColumns(create_info.constraints, fk);
|
|
157297
157356
|
} else {
|
|
157298
157357
|
// have to resolve referenced table
|
|
157299
157358
|
auto pk_table_entry_ptr = catalog.GetEntry<TableCatalogEntry>(context, fk.info.schema, fk.info.table);
|
|
157300
|
-
D_ASSERT(
|
|
157359
|
+
D_ASSERT(fk.info.pk_keys.empty());
|
|
157360
|
+
FindMatchingPrimaryKeyColumns(pk_table_entry_ptr->constraints, fk);
|
|
157301
157361
|
for (auto &keyname : fk.pk_columns) {
|
|
157302
157362
|
auto entry = pk_table_entry_ptr->name_map.find(keyname);
|
|
157303
157363
|
if (entry == pk_table_entry_ptr->name_map.end()) {
|
|
@@ -159565,9 +159625,7 @@ unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
|
159565
159625
|
|
|
159566
159626
|
if (func_catalog->type == CatalogType::TABLE_FUNCTION_ENTRY) {
|
|
159567
159627
|
function = (TableFunctionCatalogEntry *)func_catalog;
|
|
159568
|
-
|
|
159569
159628
|
} else if (func_catalog->type == CatalogType::TABLE_MACRO_ENTRY) {
|
|
159570
|
-
|
|
159571
159629
|
auto macro_func = (TableMacroCatalogEntry *)func_catalog;
|
|
159572
159630
|
auto query_node = BindTableMacro(*fexpr, macro_func, 0);
|
|
159573
159631
|
D_ASSERT(query_node);
|
|
@@ -172956,15 +173014,27 @@ static void UpdateChunk(Vector &data, Vector &updates, Vector &row_ids, idx_t co
|
|
|
172956
173014
|
case PhysicalType::INT8:
|
|
172957
173015
|
TemplatedUpdateLoop<int8_t>(data, updates, row_ids, count, base_index);
|
|
172958
173016
|
break;
|
|
173017
|
+
case PhysicalType::UINT8:
|
|
173018
|
+
TemplatedUpdateLoop<uint8_t>(data, updates, row_ids, count, base_index);
|
|
173019
|
+
break;
|
|
172959
173020
|
case PhysicalType::INT16:
|
|
172960
173021
|
TemplatedUpdateLoop<int16_t>(data, updates, row_ids, count, base_index);
|
|
172961
173022
|
break;
|
|
173023
|
+
case PhysicalType::UINT16:
|
|
173024
|
+
TemplatedUpdateLoop<uint16_t>(data, updates, row_ids, count, base_index);
|
|
173025
|
+
break;
|
|
172962
173026
|
case PhysicalType::INT32:
|
|
172963
173027
|
TemplatedUpdateLoop<int32_t>(data, updates, row_ids, count, base_index);
|
|
172964
173028
|
break;
|
|
173029
|
+
case PhysicalType::UINT32:
|
|
173030
|
+
TemplatedUpdateLoop<uint32_t>(data, updates, row_ids, count, base_index);
|
|
173031
|
+
break;
|
|
172965
173032
|
case PhysicalType::INT64:
|
|
172966
173033
|
TemplatedUpdateLoop<int64_t>(data, updates, row_ids, count, base_index);
|
|
172967
173034
|
break;
|
|
173035
|
+
case PhysicalType::UINT64:
|
|
173036
|
+
TemplatedUpdateLoop<uint64_t>(data, updates, row_ids, count, base_index);
|
|
173037
|
+
break;
|
|
172968
173038
|
case PhysicalType::FLOAT:
|
|
172969
173039
|
TemplatedUpdateLoop<float>(data, updates, row_ids, count, base_index);
|
|
172970
173040
|
break;
|