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.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/extension/parquet/parquet_reader.cpp +4 -4
  3. package/src/duckdb/src/common/sort/merge_sorter.cpp +2 -2
  4. package/src/duckdb/src/execution/index/art/node.cpp +1 -1
  5. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +53 -17
  6. package/src/duckdb/src/function/table/read_csv.cpp +43 -13
  7. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  8. package/src/duckdb/src/include/duckdb/common/union_by_name.hpp +3 -3
  9. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -0
  10. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +5 -2
  11. package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +1 -1
  12. package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +1 -1
  13. package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +1 -1
  14. package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +1 -1
  15. package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +1 -1
  16. package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +1 -1
  17. package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
  18. package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +1 -1
  19. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
  20. package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +1 -1
  21. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +1 -1
  22. package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +1 -1
  23. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
  24. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
  25. package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +1 -1
  26. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +1 -1
  27. package/src/duckdb/src/parser/expression/between_expression.cpp +1 -1
  28. package/src/duckdb/src/parser/expression/case_expression.cpp +1 -1
  29. package/src/duckdb/src/parser/expression/cast_expression.cpp +1 -1
  30. package/src/duckdb/src/parser/expression/collate_expression.cpp +1 -1
  31. package/src/duckdb/src/parser/expression/columnref_expression.cpp +1 -1
  32. package/src/duckdb/src/parser/expression/comparison_expression.cpp +1 -1
  33. package/src/duckdb/src/parser/expression/conjunction_expression.cpp +1 -1
  34. package/src/duckdb/src/parser/expression/constant_expression.cpp +1 -1
  35. package/src/duckdb/src/parser/expression/function_expression.cpp +1 -1
  36. package/src/duckdb/src/parser/expression/lambda_expression.cpp +1 -1
  37. package/src/duckdb/src/parser/expression/operator_expression.cpp +1 -1
  38. package/src/duckdb/src/parser/expression/parameter_expression.cpp +1 -1
  39. package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +2 -2
  40. package/src/duckdb/src/parser/expression/star_expression.cpp +1 -1
  41. package/src/duckdb/src/parser/expression/subquery_expression.cpp +1 -1
  42. package/src/duckdb/src/parser/expression/window_expression.cpp +2 -2
  43. package/src/duckdb/src/parser/parsed_expression.cpp +17 -17
  44. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +1 -1
  45. package/src/duckdb/third_party/fmt/include/fmt/core.h +2 -4
  46. package/src/duckdb/third_party/fmt/include/fmt/format.h +10 -10
  47. package/src/duckdb/third_party/thrift/thrift/TApplicationException.h +0 -3
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.6.2-dev1162.0",
5
+ "version": "0.6.2-dev1170.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -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
- auto sql_types_per_column = options.sql_types_per_column;
891
- for (idx_t i = 0; i < names.size(); i++) {
892
- auto it = sql_types_per_column.find(names[i]);
893
- if (it != sql_types_per_column.end()) {
894
- best_sql_types_candidates[i] = {it->second};
895
- sql_types_per_column.erase(names[i]);
896
- }
897
- }
898
- if (!sql_types_per_column.empty()) {
899
- string exception = "COLUMN_TYPES error: Columns with names: ";
900
- for (auto &col : sql_types_per_column) {
901
- exception += "\"" + col.first + "\",";
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 column_types requires a struct as input");
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
- auto &struct_children = StructValue::GetChildren(kv.second);
98
- D_ASSERT(StructType::GetChildCount(child_type) == struct_children.size());
99
- for (idx_t i = 0; i < struct_children.size(); i++) {
100
- auto &name = StructType::GetChildName(child_type, i);
101
- auto &val = struct_children[i];
102
- if (val.type().id() != LogicalTypeId::VARCHAR) {
103
- throw BinderException("read_csv_auto requires a type specification as string");
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
- auto def_type = TransformStringToLogicalType(StringValue::Get(val));
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 column_types definition");
127
+ throw BinderException("Unrecognized type \"%s\" for read_csv_auto %s definition", sql_type,
128
+ kv.first);
108
129
  }
109
- options.sql_types_per_column[name] = def_type;
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-dev1162"
2
+ #define DUCKDB_VERSION "0.6.2-dev1170"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "fc2ef0355a"
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 Types defined per specific column
58
- unordered_map<string, LogicalType> sql_types_per_column;
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 Equals(const BetweenExpression *a, const BetweenExpression *b);
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 Equals(const CaseExpression *a, const CaseExpression *b);
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 Equals(const CastExpression *a, const CastExpression *b);
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 Equals(const CollateExpression *a, const CollateExpression *b);
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 Equals(const ColumnRefExpression *a, const ColumnRefExpression *b);
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 Equals(const ComparisonExpression *a, const ComparisonExpression *b);
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 Equals(const ConjunctionExpression *a, const ConjunctionExpression *b);
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 Equals(const ConstantExpression *a, const ConstantExpression *b);
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 Equals(const FunctionExpression *a, const FunctionExpression *b);
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 Equals(const LambdaExpression *a, const LambdaExpression *b);
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 Equals(const OperatorExpression *a, const OperatorExpression *b);
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 Equals(const ParameterExpression *a, const ParameterExpression *b);
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 Equals(const PositionalReferenceExpression *a, const PositionalReferenceExpression *b);
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 Equals(const StarExpression *a, const StarExpression *b);
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 Equals(const SubqueryExpression *a, const SubqueryExpression *b);
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 Equals(const WindowExpression *a, const WindowExpression *b);
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::Equals(const BetweenExpression *a, const BetweenExpression *b) {
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::Equals(const CaseExpression *a, const CaseExpression *b) {
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::Equals(const CastExpression *a, const CastExpression *b) {
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::Equals(const CollateExpression *a, const CollateExpression *b) {
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::Equals(const ColumnRefExpression *a, const ColumnRefExpression *b) {
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::Equals(const ComparisonExpression *a, const ComparisonExpression *b) {
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::Equals(const ConjunctionExpression *a, const ConjunctionExpression *b) {
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::Equals(const ConstantExpression *a, const ConstantExpression *b) {
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::Equals(const FunctionExpression *a, const FunctionExpression *b) {
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::Equals(const LambdaExpression *a, const LambdaExpression *b) {
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::Equals(const OperatorExpression *a, const OperatorExpression *b) {
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::Equals(const ParameterExpression *a, const ParameterExpression *b) {
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::Equals(const PositionalReferenceExpression *a,
19
- const PositionalReferenceExpression *b) {
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::Equals(const StarExpression *a, const StarExpression *b) {
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::Equals(const SubqueryExpression *a, const SubqueryExpression *b) {
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::Equals(const WindowExpression *a, const WindowExpression *b) {
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 equivalent
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::Equals((BetweenExpression *)this, (BetweenExpression *)other);
55
+ return BetweenExpression::Equal((BetweenExpression *)this, (BetweenExpression *)other);
56
56
  case ExpressionClass::CASE:
57
- return CaseExpression::Equals((CaseExpression *)this, (CaseExpression *)other);
57
+ return CaseExpression::Equal((CaseExpression *)this, (CaseExpression *)other);
58
58
  case ExpressionClass::CAST:
59
- return CastExpression::Equals((CastExpression *)this, (CastExpression *)other);
59
+ return CastExpression::Equal((CastExpression *)this, (CastExpression *)other);
60
60
  case ExpressionClass::COLLATE:
61
- return CollateExpression::Equals((CollateExpression *)this, (CollateExpression *)other);
61
+ return CollateExpression::Equal((CollateExpression *)this, (CollateExpression *)other);
62
62
  case ExpressionClass::COLUMN_REF:
63
- return ColumnRefExpression::Equals((ColumnRefExpression *)this, (ColumnRefExpression *)other);
63
+ return ColumnRefExpression::Equal((ColumnRefExpression *)this, (ColumnRefExpression *)other);
64
64
  case ExpressionClass::COMPARISON:
65
- return ComparisonExpression::Equals((ComparisonExpression *)this, (ComparisonExpression *)other);
65
+ return ComparisonExpression::Equal((ComparisonExpression *)this, (ComparisonExpression *)other);
66
66
  case ExpressionClass::CONJUNCTION:
67
- return ConjunctionExpression::Equals((ConjunctionExpression *)this, (ConjunctionExpression *)other);
67
+ return ConjunctionExpression::Equal((ConjunctionExpression *)this, (ConjunctionExpression *)other);
68
68
  case ExpressionClass::CONSTANT:
69
- return ConstantExpression::Equals((ConstantExpression *)this, (ConstantExpression *)other);
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::Equals((FunctionExpression *)this, (FunctionExpression *)other);
73
+ return FunctionExpression::Equal((FunctionExpression *)this, (FunctionExpression *)other);
74
74
  case ExpressionClass::LAMBDA:
75
- return LambdaExpression::Equals((LambdaExpression *)this, (LambdaExpression *)other);
75
+ return LambdaExpression::Equal((LambdaExpression *)this, (LambdaExpression *)other);
76
76
  case ExpressionClass::OPERATOR:
77
- return OperatorExpression::Equals((OperatorExpression *)this, (OperatorExpression *)other);
77
+ return OperatorExpression::Equal((OperatorExpression *)this, (OperatorExpression *)other);
78
78
  case ExpressionClass::PARAMETER:
79
- return ParameterExpression::Equals((ParameterExpression *)this, (ParameterExpression *)other);
79
+ return ParameterExpression::Equal((ParameterExpression *)this, (ParameterExpression *)other);
80
80
  case ExpressionClass::POSITIONAL_REFERENCE:
81
- return PositionalReferenceExpression::Equals((PositionalReferenceExpression *)this,
82
- (PositionalReferenceExpression *)other);
81
+ return PositionalReferenceExpression::Equal((PositionalReferenceExpression *)this,
82
+ (PositionalReferenceExpression *)other);
83
83
  case ExpressionClass::STAR:
84
- return StarExpression::Equals((StarExpression *)this, (StarExpression *)other);
84
+ return StarExpression::Equal((StarExpression *)this, (StarExpression *)other);
85
85
  case ExpressionClass::SUBQUERY:
86
- return SubqueryExpression::Equals((SubqueryExpression *)this, (SubqueryExpression *)other);
86
+ return SubqueryExpression::Equal((SubqueryExpression *)this, (SubqueryExpression *)other);
87
87
  case ExpressionClass::WINDOW:
88
- return WindowExpression::Equals((WindowExpression *)this, (WindowExpression *)other);
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::Equals(*star, current_star)) {
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
- enum char8_t : unsigned char {};
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<char8_t> : std::true_type {};
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<char8_t> s) {
461
- const char8_t* data = s.data();
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<char8_t> s, size_t n) {
477
- const char8_t* data = s.data();
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 char8_t to_char8_t(char c) { return static_cast<char8_t>(c); }
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, char8_t>::value>;
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, to_char8_t);
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<char8_t> {
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<char8_t>(reinterpret_cast<const char8_t*>(s)) {}
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<char8_t>(reinterpret_cast<const char8_t*>(s), count) {
543
+ : basic_string_view<fmt_char8_t>(reinterpret_cast<const fmt_char8_t*>(s), count) {
544
544
  }
545
545
  };
546
546
 
@@ -100,9 +100,6 @@ public:
100
100
  }
101
101
  }
102
102
 
103
- uint32_t read(protocol::TProtocol* iprot);
104
- uint32_t write(protocol::TProtocol* oprot) const;
105
-
106
103
  protected:
107
104
  /**
108
105
  * Error code