duckdb 0.6.2-dev1162.0 → 0.6.2-dev1170.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/extension/parquet/parquet_reader.cpp +4 -4
- package/src/duckdb/src/common/sort/merge_sorter.cpp +2 -2
- package/src/duckdb/src/execution/index/art/node.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +53 -17
- package/src/duckdb/src/function/table/read_csv.cpp +43 -13
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/union_by_name.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +5 -2
- package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +1 -1
- package/src/duckdb/src/parser/expression/between_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/case_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/cast_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/collate_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/comparison_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/constant_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/function_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/lambda_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/operator_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/parameter_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +2 -2
- package/src/duckdb/src/parser/expression/star_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/subquery_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/window_expression.cpp +2 -2
- package/src/duckdb/src/parser/parsed_expression.cpp +17 -17
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +1 -1
- package/src/duckdb/third_party/fmt/include/fmt/core.h +2 -4
- package/src/duckdb/third_party/fmt/include/fmt/format.h +10 -10
- package/src/duckdb/third_party/thrift/thrift/TApplicationException.h +0 -3
package/package.json
CHANGED
|
@@ -712,9 +712,9 @@ void ParquetReader::RearrangeChildReaders(unique_ptr<duckdb::ColumnReader> &root
|
|
|
712
712
|
unordered_map<idx_t, idx_t> reverse_union_idx;
|
|
713
713
|
|
|
714
714
|
for (idx_t col = 0; col < union_idx_map.size(); ++col) {
|
|
715
|
-
auto child_reader = move(root_struct_reader.child_readers[col]);
|
|
716
|
-
auto cast_reader = make_unique<CastColumnReader>(move(child_reader), union_col_types[union_idx_map[col]]);
|
|
717
|
-
root_struct_reader.child_readers[col] = move(cast_reader);
|
|
715
|
+
auto child_reader = std::move(root_struct_reader.child_readers[col]);
|
|
716
|
+
auto cast_reader = make_unique<CastColumnReader>(std::move(child_reader), union_col_types[union_idx_map[col]]);
|
|
717
|
+
root_struct_reader.child_readers[col] = std::move(cast_reader);
|
|
718
718
|
reverse_union_idx[union_idx_map[col]] = col;
|
|
719
719
|
}
|
|
720
720
|
|
|
@@ -726,7 +726,7 @@ void ParquetReader::RearrangeChildReaders(unique_ptr<duckdb::ColumnReader> &root
|
|
|
726
726
|
column_id_nulls[col] = false;
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
-
union_null_cols = move(column_id_nulls);
|
|
729
|
+
union_null_cols = std::move(column_id_nulls);
|
|
730
730
|
}
|
|
731
731
|
void FilterIsNull(Vector &v, parquet_filter_t &filter_mask, idx_t count) {
|
|
732
732
|
if (v.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
@@ -334,8 +334,8 @@ void MergeSorter::MergeRadix(const idx_t &count, const bool left_smaller[]) {
|
|
|
334
334
|
|
|
335
335
|
auto &l_blocks = l.sb->radix_sorting_data;
|
|
336
336
|
auto &r_blocks = r.sb->radix_sorting_data;
|
|
337
|
-
RowDataBlock *l_block;
|
|
338
|
-
RowDataBlock *r_block;
|
|
337
|
+
RowDataBlock *l_block = nullptr;
|
|
338
|
+
RowDataBlock *r_block = nullptr;
|
|
339
339
|
|
|
340
340
|
data_ptr_t l_ptr;
|
|
341
341
|
data_ptr_t r_ptr;
|
|
@@ -278,7 +278,7 @@ Node *Node::Deserialize(ART &art, idx_t block_id, idx_t offset) {
|
|
|
278
278
|
reader.offset = offset;
|
|
279
279
|
auto n = reader.Read<uint8_t>();
|
|
280
280
|
NodeType node_type(static_cast<NodeType>(n));
|
|
281
|
-
Node *deserialized_node;
|
|
281
|
+
Node *deserialized_node = nullptr;
|
|
282
282
|
switch (node_type) {
|
|
283
283
|
case NodeType::NLeaf:
|
|
284
284
|
return Leaf::Deserialize(reader);
|
|
@@ -40,9 +40,9 @@ BufferedCSVReader::BufferedCSVReader(ClientContext &context, BufferedCSVReaderOp
|
|
|
40
40
|
BufferedCSVReader::BufferedCSVReader(ClientContext &context, string filename, BufferedCSVReaderOptions options_p,
|
|
41
41
|
const vector<LogicalType> &requested_types)
|
|
42
42
|
: BaseCSVReader(FileSystem::GetFileSystem(context), Allocator::Get(context), FileSystem::GetFileOpener(context),
|
|
43
|
-
move(options_p), requested_types),
|
|
43
|
+
std::move(options_p), requested_types),
|
|
44
44
|
buffer_size(0), position(0), start(0) {
|
|
45
|
-
options.file_path = move(filename);
|
|
45
|
+
options.file_path = std::move(filename);
|
|
46
46
|
file_handle = OpenCSV(options);
|
|
47
47
|
Initialize(requested_types);
|
|
48
48
|
}
|
|
@@ -832,6 +832,27 @@ vector<LogicalType> BufferedCSVReader::RefineTypeDetection(const vector<LogicalT
|
|
|
832
832
|
return detected_types;
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
+
string BufferedCSVReader::ColumnTypesError(case_insensitive_map_t<idx_t> sql_types_per_column,
|
|
836
|
+
const vector<string> &names) {
|
|
837
|
+
for (idx_t i = 0; i < names.size(); i++) {
|
|
838
|
+
auto it = sql_types_per_column.find(names[i]);
|
|
839
|
+
if (it != sql_types_per_column.end()) {
|
|
840
|
+
sql_types_per_column.erase(names[i]);
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (sql_types_per_column.empty()) {
|
|
845
|
+
return string();
|
|
846
|
+
}
|
|
847
|
+
string exception = "COLUMN_TYPES error: Columns with names: ";
|
|
848
|
+
for (auto &col : sql_types_per_column) {
|
|
849
|
+
exception += "\"" + col.first + "\",";
|
|
850
|
+
}
|
|
851
|
+
exception.pop_back();
|
|
852
|
+
exception += " do not exist in the CSV File";
|
|
853
|
+
return exception;
|
|
854
|
+
}
|
|
855
|
+
|
|
835
856
|
vector<LogicalType> BufferedCSVReader::SniffCSV(const vector<LogicalType> &requested_types) {
|
|
836
857
|
for (auto &type : requested_types) {
|
|
837
858
|
// auto detect for blobs not supported: there may be invalid UTF-8 in the file
|
|
@@ -887,23 +908,38 @@ vector<LogicalType> BufferedCSVReader::SniffCSV(const vector<LogicalType> &reque
|
|
|
887
908
|
// #######
|
|
888
909
|
options.num_cols = best_num_cols;
|
|
889
910
|
DetectHeader(best_sql_types_candidates, best_header_row);
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
if (
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
911
|
+
if (!options.sql_type_list.empty()) {
|
|
912
|
+
// user-defined types were supplied for certain columns
|
|
913
|
+
// override the types
|
|
914
|
+
if (!options.sql_types_per_column.empty()) {
|
|
915
|
+
// types supplied as name -> value map
|
|
916
|
+
idx_t found = 0;
|
|
917
|
+
for (idx_t i = 0; i < names.size(); i++) {
|
|
918
|
+
auto it = options.sql_types_per_column.find(names[i]);
|
|
919
|
+
if (it != options.sql_types_per_column.end()) {
|
|
920
|
+
best_sql_types_candidates[i] = {options.sql_type_list[it->second]};
|
|
921
|
+
found++;
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
if (!options.union_by_name && found < options.sql_types_per_column.size()) {
|
|
926
|
+
string exception = ColumnTypesError(options.sql_types_per_column, names);
|
|
927
|
+
if (!exception.empty()) {
|
|
928
|
+
throw BinderException(exception);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
} else {
|
|
932
|
+
// types supplied as list
|
|
933
|
+
if (names.size() < options.sql_type_list.size()) {
|
|
934
|
+
throw BinderException("read_csv: %d types were provided, but CSV file only has %d columns",
|
|
935
|
+
options.sql_type_list.size(), names.size());
|
|
936
|
+
}
|
|
937
|
+
for (idx_t i = 0; i < options.sql_type_list.size(); i++) {
|
|
938
|
+
best_sql_types_candidates[i] = {options.sql_type_list[i]};
|
|
939
|
+
}
|
|
902
940
|
}
|
|
903
|
-
exception.pop_back();
|
|
904
|
-
exception += " do not exist in the CSV File";
|
|
905
|
-
throw BinderException(exception);
|
|
906
941
|
}
|
|
942
|
+
|
|
907
943
|
// #######
|
|
908
944
|
// ### type detection (refining)
|
|
909
945
|
// #######
|
|
@@ -89,24 +89,45 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, TableFunctio
|
|
|
89
89
|
if (names.empty()) {
|
|
90
90
|
throw BinderException("read_csv requires at least a single column as input!");
|
|
91
91
|
}
|
|
92
|
-
} else if (loption == "column_types") {
|
|
92
|
+
} else if (loption == "column_types" || loption == "types" || loption == "dtypes") {
|
|
93
93
|
auto &child_type = kv.second.type();
|
|
94
|
-
if (child_type.id() != LogicalTypeId::STRUCT) {
|
|
95
|
-
throw BinderException("read_csv_auto
|
|
94
|
+
if (child_type.id() != LogicalTypeId::STRUCT && child_type.id() != LogicalTypeId::LIST) {
|
|
95
|
+
throw BinderException("read_csv_auto %s requires a struct or list as input", kv.first);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
if (!options.sql_type_list.empty()) {
|
|
98
|
+
throw BinderException("read_csv_auto column_types/types/dtypes can only be supplied once");
|
|
99
|
+
}
|
|
100
|
+
vector<string> sql_type_names;
|
|
101
|
+
if (child_type.id() == LogicalTypeId::STRUCT) {
|
|
102
|
+
auto &struct_children = StructValue::GetChildren(kv.second);
|
|
103
|
+
D_ASSERT(StructType::GetChildCount(child_type) == struct_children.size());
|
|
104
|
+
for (idx_t i = 0; i < struct_children.size(); i++) {
|
|
105
|
+
auto &name = StructType::GetChildName(child_type, i);
|
|
106
|
+
auto &val = struct_children[i];
|
|
107
|
+
if (val.type().id() != LogicalTypeId::VARCHAR) {
|
|
108
|
+
throw BinderException("read_csv_auto %s requires a type specification as string", kv.first);
|
|
109
|
+
}
|
|
110
|
+
sql_type_names.push_back(StringValue::Get(val));
|
|
111
|
+
options.sql_types_per_column[name] = i;
|
|
104
112
|
}
|
|
105
|
-
|
|
113
|
+
} else {
|
|
114
|
+
auto &list_child = ListType::GetChildType(child_type);
|
|
115
|
+
if (list_child.id() != LogicalTypeId::VARCHAR) {
|
|
116
|
+
throw BinderException("read_csv_auto %s requires a list of types (varchar) as input", kv.first);
|
|
117
|
+
}
|
|
118
|
+
auto &children = ListValue::GetChildren(kv.second);
|
|
119
|
+
for (auto &child : children) {
|
|
120
|
+
sql_type_names.push_back(StringValue::Get(child));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
options.sql_type_list.reserve(sql_type_names.size());
|
|
124
|
+
for (auto &sql_type : sql_type_names) {
|
|
125
|
+
auto def_type = TransformStringToLogicalType(sql_type);
|
|
106
126
|
if (def_type.id() == LogicalTypeId::USER) {
|
|
107
|
-
throw BinderException("Unrecognized type for read_csv_auto
|
|
127
|
+
throw BinderException("Unrecognized type \"%s\" for read_csv_auto %s definition", sql_type,
|
|
128
|
+
kv.first);
|
|
108
129
|
}
|
|
109
|
-
options.
|
|
130
|
+
options.sql_type_list.push_back(move(def_type));
|
|
110
131
|
}
|
|
111
132
|
} else if (loption == "all_varchar") {
|
|
112
133
|
options.all_varchar = BooleanValue::Get(kv.second);
|
|
@@ -173,6 +194,13 @@ static unique_ptr<FunctionData> ReadCSVBind(ClientContext &context, TableFunctio
|
|
|
173
194
|
const idx_t first_file_index = 0;
|
|
174
195
|
result->initial_reader = std::move(result->union_readers[first_file_index]);
|
|
175
196
|
D_ASSERT(names.size() == return_types.size());
|
|
197
|
+
|
|
198
|
+
if (!options.sql_types_per_column.empty()) {
|
|
199
|
+
auto exception = BufferedCSVReader::ColumnTypesError(options.sql_types_per_column, names);
|
|
200
|
+
if (!exception.empty()) {
|
|
201
|
+
throw BinderException(exception);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
176
204
|
}
|
|
177
205
|
|
|
178
206
|
if (result->options.include_file_name) {
|
|
@@ -830,6 +858,8 @@ TableFunction ReadCSVTableFunction::GetAutoFunction(bool list_parameter) {
|
|
|
830
858
|
read_csv_auto.cardinality = CSVReaderCardinality;
|
|
831
859
|
ReadCSVAddNamedParameters(read_csv_auto);
|
|
832
860
|
read_csv_auto.named_parameters["column_types"] = LogicalType::ANY;
|
|
861
|
+
read_csv_auto.named_parameters["dtypes"] = LogicalType::ANY;
|
|
862
|
+
read_csv_auto.named_parameters["types"] = LogicalType::ANY;
|
|
833
863
|
return read_csv_auto;
|
|
834
864
|
}
|
|
835
865
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev1170"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "72d187c5ff"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -51,7 +51,7 @@ public:
|
|
|
51
51
|
union_col_types.emplace_back(sql_types[col]);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
union_readers.push_back(move(reader));
|
|
54
|
+
union_readers.push_back(std::move(reader));
|
|
55
55
|
}
|
|
56
56
|
return union_readers;
|
|
57
57
|
}
|
|
@@ -73,8 +73,8 @@ public:
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
reader->union_col_types = union_col_types;
|
|
76
|
-
reader->union_idx_map = move(union_idx_map);
|
|
77
|
-
reader->union_null_cols = move(union_null_cols);
|
|
76
|
+
reader->union_idx_map = std::move(union_idx_map);
|
|
77
|
+
reader->union_null_cols = std::move(union_null_cols);
|
|
78
78
|
}
|
|
79
79
|
return union_readers;
|
|
80
80
|
}
|
|
@@ -76,6 +76,8 @@ public:
|
|
|
76
76
|
//! Extract a single DataChunk from the CSV file and stores it in insert_chunk
|
|
77
77
|
void ParseCSV(DataChunk &insert_chunk);
|
|
78
78
|
|
|
79
|
+
static string ColumnTypesError(case_insensitive_map_t<idx_t> sql_types_per_column, const vector<string> &names);
|
|
80
|
+
|
|
79
81
|
private:
|
|
80
82
|
//! Initialize Parser
|
|
81
83
|
void Initialize(const vector<LogicalType> &requested_types);
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#include "duckdb/function/scalar/strftime.hpp"
|
|
14
14
|
#include "duckdb/common/types/value.hpp"
|
|
15
15
|
#include "duckdb/common/field_writer.hpp"
|
|
16
|
+
#include "duckdb/common/case_insensitive_map.hpp"
|
|
16
17
|
|
|
17
18
|
namespace duckdb {
|
|
18
19
|
|
|
@@ -54,8 +55,10 @@ struct BufferedCSVReaderOptions {
|
|
|
54
55
|
//===--------------------------------------------------------------------===//
|
|
55
56
|
// CSVAutoOptions
|
|
56
57
|
//===--------------------------------------------------------------------===//
|
|
57
|
-
//! SQL
|
|
58
|
-
|
|
58
|
+
//! SQL Type list mapping of name to SQL type index in sql_type_list
|
|
59
|
+
case_insensitive_map_t<idx_t> sql_types_per_column;
|
|
60
|
+
//! User-defined SQL type list
|
|
61
|
+
vector<LogicalType> sql_type_list;
|
|
59
62
|
//===--------------------------------------------------------------------===//
|
|
60
63
|
// ReadCSVOptions
|
|
61
64
|
//===--------------------------------------------------------------------===//
|
|
@@ -24,7 +24,7 @@ public:
|
|
|
24
24
|
public:
|
|
25
25
|
string ToString() const override;
|
|
26
26
|
|
|
27
|
-
static bool
|
|
27
|
+
static bool Equal(const BetweenExpression *a, const BetweenExpression *b);
|
|
28
28
|
|
|
29
29
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
30
30
|
|
|
@@ -29,7 +29,7 @@ public:
|
|
|
29
29
|
public:
|
|
30
30
|
string ToString() const override;
|
|
31
31
|
|
|
32
|
-
static bool
|
|
32
|
+
static bool Equal(const CaseExpression *a, const CaseExpression *b);
|
|
33
33
|
|
|
34
34
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
35
35
|
|
|
@@ -28,7 +28,7 @@ public:
|
|
|
28
28
|
public:
|
|
29
29
|
string ToString() const override;
|
|
30
30
|
|
|
31
|
-
static bool
|
|
31
|
+
static bool Equal(const CastExpression *a, const CastExpression *b);
|
|
32
32
|
|
|
33
33
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
34
34
|
|
|
@@ -25,7 +25,7 @@ public:
|
|
|
25
25
|
public:
|
|
26
26
|
string ToString() const override;
|
|
27
27
|
|
|
28
|
-
static bool
|
|
28
|
+
static bool Equal(const CollateExpression *a, const CollateExpression *b);
|
|
29
29
|
|
|
30
30
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
31
31
|
|
|
@@ -38,7 +38,7 @@ public:
|
|
|
38
38
|
string GetName() const override;
|
|
39
39
|
string ToString() const override;
|
|
40
40
|
|
|
41
|
-
static bool
|
|
41
|
+
static bool Equal(const ColumnRefExpression *a, const ColumnRefExpression *b);
|
|
42
42
|
hash_t Hash() const override;
|
|
43
43
|
|
|
44
44
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
@@ -24,7 +24,7 @@ public:
|
|
|
24
24
|
public:
|
|
25
25
|
string ToString() const override;
|
|
26
26
|
|
|
27
|
-
static bool
|
|
27
|
+
static bool Equal(const ComparisonExpression *a, const ComparisonExpression *b);
|
|
28
28
|
|
|
29
29
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
30
30
|
|
|
@@ -28,7 +28,7 @@ public:
|
|
|
28
28
|
|
|
29
29
|
string ToString() const override;
|
|
30
30
|
|
|
31
|
-
static bool
|
|
31
|
+
static bool Equal(const ConjunctionExpression *a, const ConjunctionExpression *b);
|
|
32
32
|
|
|
33
33
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
34
34
|
|
|
@@ -24,7 +24,7 @@ public:
|
|
|
24
24
|
public:
|
|
25
25
|
string ToString() const override;
|
|
26
26
|
|
|
27
|
-
static bool
|
|
27
|
+
static bool Equal(const ConstantExpression *a, const ConstantExpression *b);
|
|
28
28
|
hash_t Hash() const override;
|
|
29
29
|
|
|
30
30
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
@@ -50,7 +50,7 @@ public:
|
|
|
50
50
|
|
|
51
51
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
52
52
|
|
|
53
|
-
static bool
|
|
53
|
+
static bool Equal(const FunctionExpression *a, const FunctionExpression *b);
|
|
54
54
|
hash_t Hash() const override;
|
|
55
55
|
|
|
56
56
|
void Serialize(FieldWriter &writer) const override;
|
|
@@ -30,7 +30,7 @@ public:
|
|
|
30
30
|
public:
|
|
31
31
|
string ToString() const override;
|
|
32
32
|
|
|
33
|
-
static bool
|
|
33
|
+
static bool Equal(const LambdaExpression *a, const LambdaExpression *b);
|
|
34
34
|
hash_t Hash() const override;
|
|
35
35
|
|
|
36
36
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
@@ -26,7 +26,7 @@ public:
|
|
|
26
26
|
public:
|
|
27
27
|
string ToString() const override;
|
|
28
28
|
|
|
29
|
-
static bool
|
|
29
|
+
static bool Equal(const OperatorExpression *a, const OperatorExpression *b);
|
|
30
30
|
|
|
31
31
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
32
32
|
|
|
@@ -27,7 +27,7 @@ public:
|
|
|
27
27
|
|
|
28
28
|
string ToString() const override;
|
|
29
29
|
|
|
30
|
-
static bool
|
|
30
|
+
static bool Equal(const ParameterExpression *a, const ParameterExpression *b);
|
|
31
31
|
|
|
32
32
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
33
33
|
hash_t Hash() const override;
|
|
@@ -24,7 +24,7 @@ public:
|
|
|
24
24
|
|
|
25
25
|
string ToString() const override;
|
|
26
26
|
|
|
27
|
-
static bool
|
|
27
|
+
static bool Equal(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
|
|
28
28
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
29
29
|
hash_t Hash() const override;
|
|
30
30
|
|
|
@@ -32,7 +32,7 @@ public:
|
|
|
32
32
|
public:
|
|
33
33
|
string ToString() const override;
|
|
34
34
|
|
|
35
|
-
static bool
|
|
35
|
+
static bool Equal(const StarExpression *a, const StarExpression *b);
|
|
36
36
|
|
|
37
37
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
38
38
|
|
|
@@ -39,7 +39,7 @@ public:
|
|
|
39
39
|
|
|
40
40
|
string ToString() const override;
|
|
41
41
|
|
|
42
|
-
static bool
|
|
42
|
+
static bool Equal(const SubqueryExpression *a, const SubqueryExpression *b);
|
|
43
43
|
|
|
44
44
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
45
45
|
|
|
@@ -65,7 +65,7 @@ public:
|
|
|
65
65
|
//! Convert the Expression to a String
|
|
66
66
|
string ToString() const override;
|
|
67
67
|
|
|
68
|
-
static bool
|
|
68
|
+
static bool Equal(const WindowExpression *a, const WindowExpression *b);
|
|
69
69
|
|
|
70
70
|
unique_ptr<ParsedExpression> Copy() const override;
|
|
71
71
|
|
|
@@ -13,7 +13,7 @@ string BetweenExpression::ToString() const {
|
|
|
13
13
|
return ToString<BetweenExpression, ParsedExpression>(*this);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
bool BetweenExpression::
|
|
16
|
+
bool BetweenExpression::Equal(const BetweenExpression *a, const BetweenExpression *b) {
|
|
17
17
|
if (!a->input->Equals(b->input.get())) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
@@ -12,7 +12,7 @@ string CaseExpression::ToString() const {
|
|
|
12
12
|
return ToString<CaseExpression, ParsedExpression>(*this);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
bool CaseExpression::
|
|
15
|
+
bool CaseExpression::Equal(const CaseExpression *a, const CaseExpression *b) {
|
|
16
16
|
if (a->case_checks.size() != b->case_checks.size()) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
@@ -16,7 +16,7 @@ string CastExpression::ToString() const {
|
|
|
16
16
|
return ToString<CastExpression, ParsedExpression>(*this);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
bool CastExpression::
|
|
19
|
+
bool CastExpression::Equal(const CastExpression *a, const CastExpression *b) {
|
|
20
20
|
if (!a->child->Equals(b->child.get())) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
@@ -15,7 +15,7 @@ string CollateExpression::ToString() const {
|
|
|
15
15
|
return child->ToString() + " COLLATE " + KeywordHelper::WriteOptionallyQuoted(collation);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
bool CollateExpression::
|
|
18
|
+
bool CollateExpression::Equal(const CollateExpression *a, const CollateExpression *b) {
|
|
19
19
|
if (!a->child->Equals(b->child.get())) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
@@ -61,7 +61,7 @@ string ColumnRefExpression::ToString() const {
|
|
|
61
61
|
return result;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
bool ColumnRefExpression::
|
|
64
|
+
bool ColumnRefExpression::Equal(const ColumnRefExpression *a, const ColumnRefExpression *b) {
|
|
65
65
|
if (a->column_names.size() != b->column_names.size()) {
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
@@ -15,7 +15,7 @@ string ComparisonExpression::ToString() const {
|
|
|
15
15
|
return ToString<ComparisonExpression, ParsedExpression>(*this);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
bool ComparisonExpression::
|
|
18
|
+
bool ComparisonExpression::Equal(const ComparisonExpression *a, const ComparisonExpression *b) {
|
|
19
19
|
if (!a->left->Equals(b->left.get())) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
@@ -39,7 +39,7 @@ string ConjunctionExpression::ToString() const {
|
|
|
39
39
|
return ToString<ConjunctionExpression, ParsedExpression>(*this);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
bool ConjunctionExpression::
|
|
42
|
+
bool ConjunctionExpression::Equal(const ConjunctionExpression *a, const ConjunctionExpression *b) {
|
|
43
43
|
return ExpressionUtil::SetEquals(a->children, b->children);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -15,7 +15,7 @@ string ConstantExpression::ToString() const {
|
|
|
15
15
|
return value.ToSQLString();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
bool ConstantExpression::
|
|
18
|
+
bool ConstantExpression::Equal(const ConstantExpression *a, const ConstantExpression *b) {
|
|
19
19
|
return a->value.type() == b->value.type() && !ValueOperations::DistinctFrom(a->value, b->value);
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -34,7 +34,7 @@ string FunctionExpression::ToString() const {
|
|
|
34
34
|
filter.get(), order_bys.get(), export_state, true);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
bool FunctionExpression::
|
|
37
|
+
bool FunctionExpression::Equal(const FunctionExpression *a, const FunctionExpression *b) {
|
|
38
38
|
if (a->catalog != b->catalog || a->schema != b->schema || a->function_name != b->function_name ||
|
|
39
39
|
b->distinct != a->distinct) {
|
|
40
40
|
return false;
|
|
@@ -13,7 +13,7 @@ string LambdaExpression::ToString() const {
|
|
|
13
13
|
return lhs->ToString() + " -> " + expr->ToString();
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
bool LambdaExpression::
|
|
16
|
+
bool LambdaExpression::Equal(const LambdaExpression *a, const LambdaExpression *b) {
|
|
17
17
|
return a->lhs->Equals(b->lhs.get()) && a->expr->Equals(b->expr.get());
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -24,7 +24,7 @@ string OperatorExpression::ToString() const {
|
|
|
24
24
|
return ToString<OperatorExpression, ParsedExpression>(*this);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
bool OperatorExpression::
|
|
27
|
+
bool OperatorExpression::Equal(const OperatorExpression *a, const OperatorExpression *b) {
|
|
28
28
|
if (a->children.size() != b->children.size()) {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
@@ -22,7 +22,7 @@ unique_ptr<ParsedExpression> ParameterExpression::Copy() const {
|
|
|
22
22
|
return std::move(copy);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
bool ParameterExpression::
|
|
25
|
+
bool ParameterExpression::Equal(const ParameterExpression *a, const ParameterExpression *b) {
|
|
26
26
|
return a->parameter_nr == b->parameter_nr;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -15,8 +15,8 @@ string PositionalReferenceExpression::ToString() const {
|
|
|
15
15
|
return "#" + to_string(index);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
bool PositionalReferenceExpression::
|
|
19
|
-
|
|
18
|
+
bool PositionalReferenceExpression::Equal(const PositionalReferenceExpression *a,
|
|
19
|
+
const PositionalReferenceExpression *b) {
|
|
20
20
|
return a->index == b->index;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -51,7 +51,7 @@ string StarExpression::ToString() const {
|
|
|
51
51
|
return result;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
bool StarExpression::
|
|
54
|
+
bool StarExpression::Equal(const StarExpression *a, const StarExpression *b) {
|
|
55
55
|
if (a->relation_name != b->relation_name || a->exclude_list != b->exclude_list) {
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
@@ -26,7 +26,7 @@ string SubqueryExpression::ToString() const {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
bool SubqueryExpression::
|
|
29
|
+
bool SubqueryExpression::Equal(const SubqueryExpression *a, const SubqueryExpression *b) {
|
|
30
30
|
if (!a->subquery || !b->subquery) {
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
@@ -32,7 +32,7 @@ string WindowExpression::ToString() const {
|
|
|
32
32
|
return ToString<WindowExpression, ParsedExpression, OrderByNode>(*this, schema, function_name);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
bool WindowExpression::
|
|
35
|
+
bool WindowExpression::Equal(const WindowExpression *a, const WindowExpression *b) {
|
|
36
36
|
// check if the child expressions are equivalent
|
|
37
37
|
if (b->children.size() != a->children.size()) {
|
|
38
38
|
return false;
|
|
@@ -48,7 +48,7 @@ bool WindowExpression::Equals(const WindowExpression *a, const WindowExpression
|
|
|
48
48
|
if (a->start != b->start || a->end != b->end) {
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
|
-
// check if the framing expressions are
|
|
51
|
+
// check if the framing expressions are equivalentbind_
|
|
52
52
|
if (!BaseExpression::Equals(a->start_expr.get(), b->start_expr.get()) ||
|
|
53
53
|
!BaseExpression::Equals(a->end_expr.get(), b->end_expr.get()) ||
|
|
54
54
|
!BaseExpression::Equals(a->offset_expr.get(), b->offset_expr.get()) ||
|
|
@@ -52,40 +52,40 @@ bool ParsedExpression::Equals(const BaseExpression *other) const {
|
|
|
52
52
|
}
|
|
53
53
|
switch (expression_class) {
|
|
54
54
|
case ExpressionClass::BETWEEN:
|
|
55
|
-
return BetweenExpression::
|
|
55
|
+
return BetweenExpression::Equal((BetweenExpression *)this, (BetweenExpression *)other);
|
|
56
56
|
case ExpressionClass::CASE:
|
|
57
|
-
return CaseExpression::
|
|
57
|
+
return CaseExpression::Equal((CaseExpression *)this, (CaseExpression *)other);
|
|
58
58
|
case ExpressionClass::CAST:
|
|
59
|
-
return CastExpression::
|
|
59
|
+
return CastExpression::Equal((CastExpression *)this, (CastExpression *)other);
|
|
60
60
|
case ExpressionClass::COLLATE:
|
|
61
|
-
return CollateExpression::
|
|
61
|
+
return CollateExpression::Equal((CollateExpression *)this, (CollateExpression *)other);
|
|
62
62
|
case ExpressionClass::COLUMN_REF:
|
|
63
|
-
return ColumnRefExpression::
|
|
63
|
+
return ColumnRefExpression::Equal((ColumnRefExpression *)this, (ColumnRefExpression *)other);
|
|
64
64
|
case ExpressionClass::COMPARISON:
|
|
65
|
-
return ComparisonExpression::
|
|
65
|
+
return ComparisonExpression::Equal((ComparisonExpression *)this, (ComparisonExpression *)other);
|
|
66
66
|
case ExpressionClass::CONJUNCTION:
|
|
67
|
-
return ConjunctionExpression::
|
|
67
|
+
return ConjunctionExpression::Equal((ConjunctionExpression *)this, (ConjunctionExpression *)other);
|
|
68
68
|
case ExpressionClass::CONSTANT:
|
|
69
|
-
return ConstantExpression::
|
|
69
|
+
return ConstantExpression::Equal((ConstantExpression *)this, (ConstantExpression *)other);
|
|
70
70
|
case ExpressionClass::DEFAULT:
|
|
71
71
|
return true;
|
|
72
72
|
case ExpressionClass::FUNCTION:
|
|
73
|
-
return FunctionExpression::
|
|
73
|
+
return FunctionExpression::Equal((FunctionExpression *)this, (FunctionExpression *)other);
|
|
74
74
|
case ExpressionClass::LAMBDA:
|
|
75
|
-
return LambdaExpression::
|
|
75
|
+
return LambdaExpression::Equal((LambdaExpression *)this, (LambdaExpression *)other);
|
|
76
76
|
case ExpressionClass::OPERATOR:
|
|
77
|
-
return OperatorExpression::
|
|
77
|
+
return OperatorExpression::Equal((OperatorExpression *)this, (OperatorExpression *)other);
|
|
78
78
|
case ExpressionClass::PARAMETER:
|
|
79
|
-
return ParameterExpression::
|
|
79
|
+
return ParameterExpression::Equal((ParameterExpression *)this, (ParameterExpression *)other);
|
|
80
80
|
case ExpressionClass::POSITIONAL_REFERENCE:
|
|
81
|
-
return PositionalReferenceExpression::
|
|
82
|
-
|
|
81
|
+
return PositionalReferenceExpression::Equal((PositionalReferenceExpression *)this,
|
|
82
|
+
(PositionalReferenceExpression *)other);
|
|
83
83
|
case ExpressionClass::STAR:
|
|
84
|
-
return StarExpression::
|
|
84
|
+
return StarExpression::Equal((StarExpression *)this, (StarExpression *)other);
|
|
85
85
|
case ExpressionClass::SUBQUERY:
|
|
86
|
-
return SubqueryExpression::
|
|
86
|
+
return SubqueryExpression::Equal((SubqueryExpression *)this, (SubqueryExpression *)other);
|
|
87
87
|
case ExpressionClass::WINDOW:
|
|
88
|
-
return WindowExpression::
|
|
88
|
+
return WindowExpression::Equal((WindowExpression *)this, (WindowExpression *)other);
|
|
89
89
|
default:
|
|
90
90
|
throw SerializationException("Unsupported type for expression comparison!");
|
|
91
91
|
}
|
|
@@ -269,7 +269,7 @@ bool Binder::FindStarExpression(ParsedExpression &expr, StarExpression **star) {
|
|
|
269
269
|
auto current_star = (StarExpression *)&expr;
|
|
270
270
|
if (*star) {
|
|
271
271
|
// we can have multiple
|
|
272
|
-
if (!StarExpression::
|
|
272
|
+
if (!StarExpression::Equal(*star, current_star)) {
|
|
273
273
|
throw BinderException(
|
|
274
274
|
FormatError(expr, "Multiple different STAR/COLUMNS in the same expression are not supported"));
|
|
275
275
|
}
|
|
@@ -355,16 +355,14 @@ template <typename Char> class basic_string_view {
|
|
|
355
355
|
using string_view = basic_string_view<char>;
|
|
356
356
|
using wstring_view = basic_string_view<wchar_t>;
|
|
357
357
|
|
|
358
|
-
#ifndef __cpp_char8_t
|
|
359
358
|
// A UTF-8 code unit type.
|
|
360
|
-
|
|
361
|
-
#endif
|
|
359
|
+
typedef unsigned char fmt_char8_t;
|
|
362
360
|
|
|
363
361
|
/** Specifies if ``T`` is a character type. Can be specialized by users. */
|
|
364
362
|
template <typename T> struct is_char : std::false_type {};
|
|
365
363
|
template <> struct is_char<char> : std::true_type {};
|
|
366
364
|
template <> struct is_char<wchar_t> : std::true_type {};
|
|
367
|
-
template <> struct is_char<
|
|
365
|
+
template <> struct is_char<fmt_char8_t> : std::true_type {};
|
|
368
366
|
template <> struct is_char<char16_t> : std::true_type {};
|
|
369
367
|
template <> struct is_char<char32_t> : std::true_type {};
|
|
370
368
|
|
|
@@ -457,8 +457,8 @@ inline size_t count_code_points(basic_string_view<Char> s) {
|
|
|
457
457
|
}
|
|
458
458
|
|
|
459
459
|
// Counts the number of code points in a UTF-8 string.
|
|
460
|
-
inline size_t count_code_points(basic_string_view<
|
|
461
|
-
const
|
|
460
|
+
inline size_t count_code_points(basic_string_view<fmt_char8_t> s) {
|
|
461
|
+
const fmt_char8_t* data = s.data();
|
|
462
462
|
size_t num_code_points = 0;
|
|
463
463
|
for (size_t i = 0, size = s.size(); i != size; ++i) {
|
|
464
464
|
if ((data[i] & 0xc0) != 0x80) ++num_code_points;
|
|
@@ -473,8 +473,8 @@ inline size_t code_point_index(basic_string_view<Char> s, size_t n) {
|
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
// Calculates the index of the nth code point in a UTF-8 string.
|
|
476
|
-
inline size_t code_point_index(basic_string_view<
|
|
477
|
-
const
|
|
476
|
+
inline size_t code_point_index(basic_string_view<fmt_char8_t> s, size_t n) {
|
|
477
|
+
const fmt_char8_t* data = s.data();
|
|
478
478
|
size_t num_code_points = 0;
|
|
479
479
|
for (size_t i = 0, size = s.size(); i != size; ++i) {
|
|
480
480
|
if ((data[i] & 0xc0) != 0x80 && ++num_code_points > n) {
|
|
@@ -484,13 +484,13 @@ inline size_t code_point_index(basic_string_view<char8_t> s, size_t n) {
|
|
|
484
484
|
return s.size();
|
|
485
485
|
}
|
|
486
486
|
|
|
487
|
-
inline
|
|
487
|
+
inline fmt_char8_t to_fmt_char8_t(char c) { return static_cast<fmt_char8_t>(c); }
|
|
488
488
|
|
|
489
489
|
template <typename InputIt, typename OutChar>
|
|
490
490
|
using needs_conversion = bool_constant<
|
|
491
491
|
std::is_same<typename std::iterator_traits<InputIt>::value_type,
|
|
492
492
|
char>::value &&
|
|
493
|
-
std::is_same<OutChar,
|
|
493
|
+
std::is_same<OutChar, fmt_char8_t>::value>;
|
|
494
494
|
|
|
495
495
|
template <typename OutChar, typename InputIt, typename OutputIt,
|
|
496
496
|
FMT_ENABLE_IF(!needs_conversion<InputIt, OutChar>::value)>
|
|
@@ -501,7 +501,7 @@ OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) {
|
|
|
501
501
|
template <typename OutChar, typename InputIt, typename OutputIt,
|
|
502
502
|
FMT_ENABLE_IF(needs_conversion<InputIt, OutChar>::value)>
|
|
503
503
|
OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) {
|
|
504
|
-
return std::transform(begin, end, it,
|
|
504
|
+
return std::transform(begin, end, it, to_fmt_char8_t);
|
|
505
505
|
}
|
|
506
506
|
|
|
507
507
|
#ifndef FMT_USE_GRISU
|
|
@@ -535,12 +535,12 @@ class buffer_range : public internal::output_range<
|
|
|
535
535
|
};
|
|
536
536
|
|
|
537
537
|
// A UTF-8 string view.
|
|
538
|
-
class u8string_view : public basic_string_view<
|
|
538
|
+
class u8string_view : public basic_string_view<fmt_char8_t> {
|
|
539
539
|
public:
|
|
540
540
|
u8string_view(const char* s)
|
|
541
|
-
: basic_string_view<
|
|
541
|
+
: basic_string_view<fmt_char8_t>(reinterpret_cast<const fmt_char8_t*>(s)) {}
|
|
542
542
|
u8string_view(const char* s, size_t count) FMT_NOEXCEPT
|
|
543
|
-
: basic_string_view<
|
|
543
|
+
: basic_string_view<fmt_char8_t>(reinterpret_cast<const fmt_char8_t*>(s), count) {
|
|
544
544
|
}
|
|
545
545
|
};
|
|
546
546
|
|