duckdb 0.3.2-dev1000.0 → 0.3.2-dev1051.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 +878 -819
- package/src/duckdb.hpp +257 -188
- package/src/parquet-amalgamation.cpp +21049 -21049
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "0.3.2-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "e4aebbd9b"
|
|
15
|
+
#define DUCKDB_VERSION "0.3.2-dev1051"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -2368,6 +2368,41 @@ public:
|
|
|
2368
2368
|
return true;
|
|
2369
2369
|
}
|
|
2370
2370
|
|
|
2371
|
+
idx_t CountValid(const idx_t count) const {
|
|
2372
|
+
if (AllValid() || count == 0) {
|
|
2373
|
+
return count;
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
idx_t valid = 0;
|
|
2377
|
+
const auto entry_count = EntryCount(count);
|
|
2378
|
+
for (idx_t entry_idx = 0; entry_idx < entry_count;) {
|
|
2379
|
+
auto entry = GetValidityEntry(entry_idx++);
|
|
2380
|
+
// Handle ragged end
|
|
2381
|
+
if (entry_idx == entry_count) {
|
|
2382
|
+
idx_t idx_in_entry;
|
|
2383
|
+
GetEntryIndex(count, entry_idx, idx_in_entry);
|
|
2384
|
+
for (idx_t i = 0; i < idx_in_entry; ++i) {
|
|
2385
|
+
valid += idx_t(RowIsValid(entry, i));
|
|
2386
|
+
}
|
|
2387
|
+
break;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// Handle all set
|
|
2391
|
+
if (AllValid(entry)) {
|
|
2392
|
+
valid += BITS_PER_VALUE;
|
|
2393
|
+
continue;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
// Count partial entry (Kernighan's algorithm)
|
|
2397
|
+
while (entry) {
|
|
2398
|
+
entry &= (entry - 1);
|
|
2399
|
+
++valid;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
return valid;
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2371
2406
|
inline V *GetData() const {
|
|
2372
2407
|
return validity_mask;
|
|
2373
2408
|
}
|
|
@@ -5258,6 +5293,26 @@ private:
|
|
|
5258
5293
|
|
|
5259
5294
|
|
|
5260
5295
|
|
|
5296
|
+
//===----------------------------------------------------------------------===//
|
|
5297
|
+
// DuckDB
|
|
5298
|
+
//
|
|
5299
|
+
// duckdb/common/named_parameter_map.hpp
|
|
5300
|
+
//
|
|
5301
|
+
//
|
|
5302
|
+
//===----------------------------------------------------------------------===//
|
|
5303
|
+
|
|
5304
|
+
|
|
5305
|
+
|
|
5306
|
+
//===----------------------------------------------------------------------===//
|
|
5307
|
+
// DuckDB
|
|
5308
|
+
//
|
|
5309
|
+
// duckdb/common/case_insensitive_map.hpp
|
|
5310
|
+
//
|
|
5311
|
+
//
|
|
5312
|
+
//===----------------------------------------------------------------------===//
|
|
5313
|
+
|
|
5314
|
+
|
|
5315
|
+
|
|
5261
5316
|
|
|
5262
5317
|
//===----------------------------------------------------------------------===//
|
|
5263
5318
|
// DuckDB
|
|
@@ -5275,6 +5330,171 @@ namespace duckdb {
|
|
|
5275
5330
|
using std::unordered_set;
|
|
5276
5331
|
}
|
|
5277
5332
|
|
|
5333
|
+
|
|
5334
|
+
//===----------------------------------------------------------------------===//
|
|
5335
|
+
// DuckDB
|
|
5336
|
+
//
|
|
5337
|
+
// duckdb/common/string_util.hpp
|
|
5338
|
+
//
|
|
5339
|
+
//
|
|
5340
|
+
//===----------------------------------------------------------------------===//
|
|
5341
|
+
|
|
5342
|
+
|
|
5343
|
+
|
|
5344
|
+
|
|
5345
|
+
|
|
5346
|
+
|
|
5347
|
+
|
|
5348
|
+
namespace duckdb {
|
|
5349
|
+
/**
|
|
5350
|
+
* String Utility Functions
|
|
5351
|
+
* Note that these are not the most efficient implementations (i.e., they copy
|
|
5352
|
+
* memory) and therefore they should only be used for debug messages and other
|
|
5353
|
+
* such things.
|
|
5354
|
+
*/
|
|
5355
|
+
class StringUtil {
|
|
5356
|
+
public:
|
|
5357
|
+
DUCKDB_API static bool CharacterIsSpace(char c) {
|
|
5358
|
+
return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
|
|
5359
|
+
}
|
|
5360
|
+
DUCKDB_API static bool CharacterIsNewline(char c) {
|
|
5361
|
+
return c == '\n' || c == '\r';
|
|
5362
|
+
}
|
|
5363
|
+
DUCKDB_API static bool CharacterIsDigit(char c) {
|
|
5364
|
+
return c >= '0' && c <= '9';
|
|
5365
|
+
}
|
|
5366
|
+
DUCKDB_API static char CharacterToLower(char c) {
|
|
5367
|
+
if (c >= 'A' && c <= 'Z') {
|
|
5368
|
+
return c - ('A' - 'a');
|
|
5369
|
+
}
|
|
5370
|
+
return c;
|
|
5371
|
+
}
|
|
5372
|
+
|
|
5373
|
+
//! Returns true if the needle string exists in the haystack
|
|
5374
|
+
DUCKDB_API static bool Contains(const string &haystack, const string &needle);
|
|
5375
|
+
|
|
5376
|
+
//! Returns true if the target string starts with the given prefix
|
|
5377
|
+
DUCKDB_API static bool StartsWith(string str, string prefix);
|
|
5378
|
+
|
|
5379
|
+
//! Returns true if the target string <b>ends</b> with the given suffix.
|
|
5380
|
+
DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
|
|
5381
|
+
|
|
5382
|
+
//! Repeat a string multiple times
|
|
5383
|
+
DUCKDB_API static string Repeat(const string &str, const idx_t n);
|
|
5384
|
+
|
|
5385
|
+
//! Split the input string based on newline char
|
|
5386
|
+
DUCKDB_API static vector<string> Split(const string &str, char delimiter);
|
|
5387
|
+
|
|
5388
|
+
//! Split the input string allong a quote. Note that any escaping is NOT supported.
|
|
5389
|
+
DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
|
|
5390
|
+
|
|
5391
|
+
//! Join multiple strings into one string. Components are concatenated by the given separator
|
|
5392
|
+
DUCKDB_API static string Join(const vector<string> &input, const string &separator);
|
|
5393
|
+
|
|
5394
|
+
//! Join multiple items of container with given size, transformed to string
|
|
5395
|
+
//! using function, into one string using the given separator
|
|
5396
|
+
template <typename C, typename S, typename Func>
|
|
5397
|
+
static string Join(const C &input, S count, const string &separator, Func f) {
|
|
5398
|
+
// The result
|
|
5399
|
+
std::string result;
|
|
5400
|
+
|
|
5401
|
+
// If the input isn't empty, append the first element. We do this so we
|
|
5402
|
+
// don't need to introduce an if into the loop.
|
|
5403
|
+
if (count > 0) {
|
|
5404
|
+
result += f(input[0]);
|
|
5405
|
+
}
|
|
5406
|
+
|
|
5407
|
+
// Append the remaining input components, after the first
|
|
5408
|
+
for (size_t i = 1; i < count; i++) {
|
|
5409
|
+
result += separator + f(input[i]);
|
|
5410
|
+
}
|
|
5411
|
+
|
|
5412
|
+
return result;
|
|
5413
|
+
}
|
|
5414
|
+
|
|
5415
|
+
//! Return a string that formats the give number of bytes
|
|
5416
|
+
DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
|
|
5417
|
+
|
|
5418
|
+
//! Convert a string to uppercase
|
|
5419
|
+
DUCKDB_API static string Upper(const string &str);
|
|
5420
|
+
|
|
5421
|
+
//! Convert a string to lowercase
|
|
5422
|
+
DUCKDB_API static string Lower(const string &str);
|
|
5423
|
+
|
|
5424
|
+
//! Format a string using printf semantics
|
|
5425
|
+
template <typename... Args>
|
|
5426
|
+
static string Format(const string fmt_str, Args... params) {
|
|
5427
|
+
return Exception::ConstructMessage(fmt_str, params...);
|
|
5428
|
+
}
|
|
5429
|
+
|
|
5430
|
+
//! Split the input string into a vector of strings based on the split string
|
|
5431
|
+
DUCKDB_API static vector<string> Split(const string &input, const string &split);
|
|
5432
|
+
|
|
5433
|
+
//! Remove the whitespace char in the left end of the string
|
|
5434
|
+
DUCKDB_API static void LTrim(string &str);
|
|
5435
|
+
//! Remove the whitespace char in the right end of the string
|
|
5436
|
+
DUCKDB_API static void RTrim(string &str);
|
|
5437
|
+
//! Remove the whitespace char in the left and right end of the string
|
|
5438
|
+
DUCKDB_API static void Trim(string &str);
|
|
5439
|
+
|
|
5440
|
+
DUCKDB_API static string Replace(string source, const string &from, const string &to);
|
|
5441
|
+
|
|
5442
|
+
//! Get the levenshtein distance from two strings
|
|
5443
|
+
DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
|
|
5444
|
+
|
|
5445
|
+
//! Get the top-n strings (sorted by the given score distance) from a set of scores.
|
|
5446
|
+
//! At least one entry is returned (if there is one).
|
|
5447
|
+
//! Strings are only returned if they have a score less than the threshold.
|
|
5448
|
+
DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
|
|
5449
|
+
idx_t threshold = 5);
|
|
5450
|
+
//! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
|
|
5451
|
+
//! with the given params.
|
|
5452
|
+
DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
|
|
5453
|
+
idx_t threshold = 5);
|
|
5454
|
+
DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
|
|
5455
|
+
const string &candidate = "Candidate bindings");
|
|
5456
|
+
|
|
5457
|
+
//! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
|
|
5458
|
+
//! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
|
|
5459
|
+
DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
|
|
5460
|
+
const string &message_prefix, idx_t n = 5);
|
|
5461
|
+
};
|
|
5462
|
+
|
|
5463
|
+
} // namespace duckdb
|
|
5464
|
+
|
|
5465
|
+
|
|
5466
|
+
namespace duckdb {
|
|
5467
|
+
|
|
5468
|
+
struct CaseInsensitiveStringHashFunction {
|
|
5469
|
+
uint64_t operator()(const string &str) const {
|
|
5470
|
+
std::hash<string> hasher;
|
|
5471
|
+
return hasher(StringUtil::Lower(str));
|
|
5472
|
+
}
|
|
5473
|
+
};
|
|
5474
|
+
|
|
5475
|
+
struct CaseInsensitiveStringEquality {
|
|
5476
|
+
bool operator()(const string &a, const string &b) const {
|
|
5477
|
+
return StringUtil::Lower(a) == StringUtil::Lower(b);
|
|
5478
|
+
}
|
|
5479
|
+
};
|
|
5480
|
+
|
|
5481
|
+
template <typename T>
|
|
5482
|
+
using case_insensitive_map_t =
|
|
5483
|
+
unordered_map<string, T, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
|
|
5484
|
+
|
|
5485
|
+
using case_insensitive_set_t = unordered_set<string, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
|
|
5486
|
+
|
|
5487
|
+
} // namespace duckdb
|
|
5488
|
+
|
|
5489
|
+
|
|
5490
|
+
namespace duckdb {
|
|
5491
|
+
|
|
5492
|
+
using named_parameter_type_map_t = case_insensitive_map_t<LogicalType>;
|
|
5493
|
+
using named_parameter_map_t = case_insensitive_map_t<Value>;
|
|
5494
|
+
|
|
5495
|
+
} // namespace duckdb
|
|
5496
|
+
|
|
5497
|
+
|
|
5278
5498
|
//===----------------------------------------------------------------------===//
|
|
5279
5499
|
// DuckDB
|
|
5280
5500
|
//
|
|
@@ -5742,7 +5962,7 @@ struct TableFunctionData : public FunctionData {
|
|
|
5742
5962
|
|
|
5743
5963
|
struct FunctionParameters {
|
|
5744
5964
|
vector<Value> values;
|
|
5745
|
-
|
|
5965
|
+
named_parameter_map_t named_parameters;
|
|
5746
5966
|
};
|
|
5747
5967
|
|
|
5748
5968
|
//! Function is the base class used for any type of function (scalar, aggregate or simple function)
|
|
@@ -5762,7 +5982,7 @@ public:
|
|
|
5762
5982
|
const LogicalType &return_type);
|
|
5763
5983
|
//! Returns the formatted string name(arg1, arg2.., np1=a, np2=b, ...)
|
|
5764
5984
|
DUCKDB_API static string CallToString(const string &name, const vector<LogicalType> &arguments,
|
|
5765
|
-
const
|
|
5985
|
+
const named_parameter_type_map_t &named_parameters);
|
|
5766
5986
|
|
|
5767
5987
|
//! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
|
|
5768
5988
|
//! returns DConstants::INVALID_INDEX and sets error if none could be found
|
|
@@ -5812,14 +6032,14 @@ public:
|
|
|
5812
6032
|
DUCKDB_API ~SimpleNamedParameterFunction() override;
|
|
5813
6033
|
|
|
5814
6034
|
//! The named parameters of the function
|
|
5815
|
-
|
|
6035
|
+
named_parameter_type_map_t named_parameters;
|
|
5816
6036
|
|
|
5817
6037
|
public:
|
|
5818
6038
|
DUCKDB_API string ToString() override;
|
|
5819
6039
|
DUCKDB_API bool HasNamedParameters();
|
|
5820
6040
|
|
|
5821
6041
|
DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> ¶meters,
|
|
5822
|
-
|
|
6042
|
+
named_parameter_map_t &named_parameters,
|
|
5823
6043
|
vector<unique_ptr<ParsedExpression>> &children);
|
|
5824
6044
|
};
|
|
5825
6045
|
|
|
@@ -9638,8 +9858,6 @@ public:
|
|
|
9638
9858
|
|
|
9639
9859
|
|
|
9640
9860
|
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
9861
|
#include <functional>
|
|
9644
9862
|
|
|
9645
9863
|
namespace duckdb {
|
|
@@ -9659,7 +9877,7 @@ struct TableFilterCollection {
|
|
|
9659
9877
|
};
|
|
9660
9878
|
|
|
9661
9879
|
typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, vector<Value> &inputs,
|
|
9662
|
-
|
|
9880
|
+
named_parameter_map_t &named_parameters,
|
|
9663
9881
|
vector<LogicalType> &input_table_types,
|
|
9664
9882
|
vector<string> &input_table_names,
|
|
9665
9883
|
vector<LogicalType> &return_types, vector<string> &names);
|
|
@@ -10499,7 +10717,7 @@ public:
|
|
|
10499
10717
|
//! Create a relation from calling a table in/out function on the input relation
|
|
10500
10718
|
DUCKDB_API shared_ptr<Relation> TableFunction(const std::string &fname, const vector<Value> &values);
|
|
10501
10719
|
DUCKDB_API shared_ptr<Relation> TableFunction(const std::string &fname, const vector<Value> &values,
|
|
10502
|
-
const
|
|
10720
|
+
const named_parameter_map_t &named_parameters);
|
|
10503
10721
|
|
|
10504
10722
|
public:
|
|
10505
10723
|
//! Whether or not the relation inherits column bindings from its child or not, only relevant for binding
|
|
@@ -10756,7 +10974,7 @@ public:
|
|
|
10756
10974
|
//! Returns a relation that calls a specified table function
|
|
10757
10975
|
DUCKDB_API shared_ptr<Relation> TableFunction(const string &tname);
|
|
10758
10976
|
DUCKDB_API shared_ptr<Relation> TableFunction(const string &tname, const vector<Value> &values,
|
|
10759
|
-
const
|
|
10977
|
+
const named_parameter_map_t &named_parameters);
|
|
10760
10978
|
DUCKDB_API shared_ptr<Relation> TableFunction(const string &tname, const vector<Value> &values);
|
|
10761
10979
|
//! Returns a relation that produces values
|
|
10762
10980
|
DUCKDB_API shared_ptr<Relation> Values(const vector<vector<Value>> &values);
|
|
@@ -10967,173 +11185,6 @@ private:
|
|
|
10967
11185
|
|
|
10968
11186
|
} // namespace duckdb
|
|
10969
11187
|
|
|
10970
|
-
//===----------------------------------------------------------------------===//
|
|
10971
|
-
// DuckDB
|
|
10972
|
-
//
|
|
10973
|
-
// duckdb/common/case_insensitive_map.hpp
|
|
10974
|
-
//
|
|
10975
|
-
//
|
|
10976
|
-
//===----------------------------------------------------------------------===//
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
//===----------------------------------------------------------------------===//
|
|
10984
|
-
// DuckDB
|
|
10985
|
-
//
|
|
10986
|
-
// duckdb/common/string_util.hpp
|
|
10987
|
-
//
|
|
10988
|
-
//
|
|
10989
|
-
//===----------------------------------------------------------------------===//
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
namespace duckdb {
|
|
10998
|
-
/**
|
|
10999
|
-
* String Utility Functions
|
|
11000
|
-
* Note that these are not the most efficient implementations (i.e., they copy
|
|
11001
|
-
* memory) and therefore they should only be used for debug messages and other
|
|
11002
|
-
* such things.
|
|
11003
|
-
*/
|
|
11004
|
-
class StringUtil {
|
|
11005
|
-
public:
|
|
11006
|
-
DUCKDB_API static bool CharacterIsSpace(char c) {
|
|
11007
|
-
return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
|
|
11008
|
-
}
|
|
11009
|
-
DUCKDB_API static bool CharacterIsNewline(char c) {
|
|
11010
|
-
return c == '\n' || c == '\r';
|
|
11011
|
-
}
|
|
11012
|
-
DUCKDB_API static bool CharacterIsDigit(char c) {
|
|
11013
|
-
return c >= '0' && c <= '9';
|
|
11014
|
-
}
|
|
11015
|
-
DUCKDB_API static char CharacterToLower(char c) {
|
|
11016
|
-
if (c >= 'A' && c <= 'Z') {
|
|
11017
|
-
return c - ('A' - 'a');
|
|
11018
|
-
}
|
|
11019
|
-
return c;
|
|
11020
|
-
}
|
|
11021
|
-
|
|
11022
|
-
//! Returns true if the needle string exists in the haystack
|
|
11023
|
-
DUCKDB_API static bool Contains(const string &haystack, const string &needle);
|
|
11024
|
-
|
|
11025
|
-
//! Returns true if the target string starts with the given prefix
|
|
11026
|
-
DUCKDB_API static bool StartsWith(string str, string prefix);
|
|
11027
|
-
|
|
11028
|
-
//! Returns true if the target string <b>ends</b> with the given suffix.
|
|
11029
|
-
DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
|
|
11030
|
-
|
|
11031
|
-
//! Repeat a string multiple times
|
|
11032
|
-
DUCKDB_API static string Repeat(const string &str, const idx_t n);
|
|
11033
|
-
|
|
11034
|
-
//! Split the input string based on newline char
|
|
11035
|
-
DUCKDB_API static vector<string> Split(const string &str, char delimiter);
|
|
11036
|
-
|
|
11037
|
-
//! Split the input string allong a quote. Note that any escaping is NOT supported.
|
|
11038
|
-
DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
|
|
11039
|
-
|
|
11040
|
-
//! Join multiple strings into one string. Components are concatenated by the given separator
|
|
11041
|
-
DUCKDB_API static string Join(const vector<string> &input, const string &separator);
|
|
11042
|
-
|
|
11043
|
-
//! Join multiple items of container with given size, transformed to string
|
|
11044
|
-
//! using function, into one string using the given separator
|
|
11045
|
-
template <typename C, typename S, typename Func>
|
|
11046
|
-
static string Join(const C &input, S count, const string &separator, Func f) {
|
|
11047
|
-
// The result
|
|
11048
|
-
std::string result;
|
|
11049
|
-
|
|
11050
|
-
// If the input isn't empty, append the first element. We do this so we
|
|
11051
|
-
// don't need to introduce an if into the loop.
|
|
11052
|
-
if (count > 0) {
|
|
11053
|
-
result += f(input[0]);
|
|
11054
|
-
}
|
|
11055
|
-
|
|
11056
|
-
// Append the remaining input components, after the first
|
|
11057
|
-
for (size_t i = 1; i < count; i++) {
|
|
11058
|
-
result += separator + f(input[i]);
|
|
11059
|
-
}
|
|
11060
|
-
|
|
11061
|
-
return result;
|
|
11062
|
-
}
|
|
11063
|
-
|
|
11064
|
-
//! Return a string that formats the give number of bytes
|
|
11065
|
-
DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
|
|
11066
|
-
|
|
11067
|
-
//! Convert a string to uppercase
|
|
11068
|
-
DUCKDB_API static string Upper(const string &str);
|
|
11069
|
-
|
|
11070
|
-
//! Convert a string to lowercase
|
|
11071
|
-
DUCKDB_API static string Lower(const string &str);
|
|
11072
|
-
|
|
11073
|
-
//! Format a string using printf semantics
|
|
11074
|
-
template <typename... Args>
|
|
11075
|
-
static string Format(const string fmt_str, Args... params) {
|
|
11076
|
-
return Exception::ConstructMessage(fmt_str, params...);
|
|
11077
|
-
}
|
|
11078
|
-
|
|
11079
|
-
//! Split the input string into a vector of strings based on the split string
|
|
11080
|
-
DUCKDB_API static vector<string> Split(const string &input, const string &split);
|
|
11081
|
-
|
|
11082
|
-
//! Remove the whitespace char in the left end of the string
|
|
11083
|
-
DUCKDB_API static void LTrim(string &str);
|
|
11084
|
-
//! Remove the whitespace char in the right end of the string
|
|
11085
|
-
DUCKDB_API static void RTrim(string &str);
|
|
11086
|
-
//! Remove the whitespace char in the left and right end of the string
|
|
11087
|
-
DUCKDB_API static void Trim(string &str);
|
|
11088
|
-
|
|
11089
|
-
DUCKDB_API static string Replace(string source, const string &from, const string &to);
|
|
11090
|
-
|
|
11091
|
-
//! Get the levenshtein distance from two strings
|
|
11092
|
-
DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
|
|
11093
|
-
|
|
11094
|
-
//! Get the top-n strings (sorted by the given score distance) from a set of scores.
|
|
11095
|
-
//! At least one entry is returned (if there is one).
|
|
11096
|
-
//! Strings are only returned if they have a score less than the threshold.
|
|
11097
|
-
DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
|
|
11098
|
-
idx_t threshold = 5);
|
|
11099
|
-
//! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
|
|
11100
|
-
//! with the given params.
|
|
11101
|
-
DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
|
|
11102
|
-
idx_t threshold = 5);
|
|
11103
|
-
DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
|
|
11104
|
-
const string &candidate = "Candidate bindings");
|
|
11105
|
-
|
|
11106
|
-
//! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
|
|
11107
|
-
//! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
|
|
11108
|
-
DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
|
|
11109
|
-
const string &message_prefix, idx_t n = 5);
|
|
11110
|
-
};
|
|
11111
|
-
|
|
11112
|
-
} // namespace duckdb
|
|
11113
|
-
|
|
11114
|
-
|
|
11115
|
-
namespace duckdb {
|
|
11116
|
-
|
|
11117
|
-
struct CaseInsensitiveStringHashFunction {
|
|
11118
|
-
uint64_t operator()(const string &str) const {
|
|
11119
|
-
std::hash<string> hasher;
|
|
11120
|
-
return hasher(StringUtil::Lower(str));
|
|
11121
|
-
}
|
|
11122
|
-
};
|
|
11123
|
-
|
|
11124
|
-
struct CaseInsensitiveStringEquality {
|
|
11125
|
-
bool operator()(const string &a, const string &b) const {
|
|
11126
|
-
return StringUtil::Lower(a) == StringUtil::Lower(b);
|
|
11127
|
-
}
|
|
11128
|
-
};
|
|
11129
|
-
|
|
11130
|
-
template <typename T>
|
|
11131
|
-
using case_insensitive_map_t =
|
|
11132
|
-
unordered_map<string, T, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
|
|
11133
|
-
|
|
11134
|
-
using case_insensitive_set_t = unordered_set<string, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
|
|
11135
|
-
|
|
11136
|
-
} // namespace duckdb
|
|
11137
11188
|
|
|
11138
11189
|
|
|
11139
11190
|
|
|
@@ -15782,7 +15833,7 @@ public:
|
|
|
15782
15833
|
SchemaCatalogEntry *BindCreateFunctionInfo(CreateInfo &info);
|
|
15783
15834
|
|
|
15784
15835
|
//! Check usage, and cast named parameters to their types
|
|
15785
|
-
static void BindNamedParameters(
|
|
15836
|
+
static void BindNamedParameters(named_parameter_type_map_t &types, named_parameter_map_t &values,
|
|
15786
15837
|
QueryErrorContext &error_context, string &func_name);
|
|
15787
15838
|
|
|
15788
15839
|
unique_ptr<BoundTableRef> Bind(TableRef &ref);
|
|
@@ -15909,7 +15960,7 @@ private:
|
|
|
15909
15960
|
unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
|
|
15910
15961
|
|
|
15911
15962
|
bool BindFunctionParameters(vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
|
|
15912
|
-
vector<Value> ¶meters,
|
|
15963
|
+
vector<Value> ¶meters, named_parameter_map_t &named_parameters,
|
|
15913
15964
|
unique_ptr<BoundSubqueryRef> &subquery, string &error);
|
|
15914
15965
|
|
|
15915
15966
|
unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
|
|
@@ -17250,6 +17301,10 @@ struct ClientConfig {
|
|
|
17250
17301
|
//! The wait time before showing the progress bar
|
|
17251
17302
|
int wait_time = 2000;
|
|
17252
17303
|
|
|
17304
|
+
//! Preserve identifier case while parsing.
|
|
17305
|
+
//! If false, all unquoted identifiers are lower-cased (e.g. "MyTable" -> "mytable").
|
|
17306
|
+
bool preserve_identifier_case = true;
|
|
17307
|
+
|
|
17253
17308
|
// Whether or not aggressive query verification is enabled
|
|
17254
17309
|
bool query_verification_enabled = false;
|
|
17255
17310
|
//! Enable the running of optimizers
|
|
@@ -17294,6 +17349,7 @@ class ClientContextLock;
|
|
|
17294
17349
|
struct CreateScalarFunctionInfo;
|
|
17295
17350
|
class ScalarFunctionCatalogEntry;
|
|
17296
17351
|
struct ActiveQueryContext;
|
|
17352
|
+
struct ParserOptions;
|
|
17297
17353
|
|
|
17298
17354
|
//! The ClientContext holds information relevant to the current client session
|
|
17299
17355
|
//! during execution
|
|
@@ -17411,6 +17467,9 @@ public:
|
|
|
17411
17467
|
//! Equivalent to CURRENT_SETTING(key) SQL function.
|
|
17412
17468
|
DUCKDB_API bool TryGetCurrentSetting(const std::string &key, Value &result);
|
|
17413
17469
|
|
|
17470
|
+
//! Returns the parser options for this client context
|
|
17471
|
+
DUCKDB_API ParserOptions GetParserOptions();
|
|
17472
|
+
|
|
17414
17473
|
DUCKDB_API unique_ptr<DataChunk> Fetch(ClientContextLock &lock, StreamQueryResult &result);
|
|
17415
17474
|
|
|
17416
17475
|
//! Whether or not the given result object (streaming query result or pending query result) is active
|
|
@@ -19728,7 +19787,7 @@ struct PragmaInfo : public ParseInfo {
|
|
|
19728
19787
|
//! Parameter list (if any)
|
|
19729
19788
|
vector<Value> parameters;
|
|
19730
19789
|
//! Named parameter list (if any)
|
|
19731
|
-
|
|
19790
|
+
named_parameter_map_t named_parameters;
|
|
19732
19791
|
|
|
19733
19792
|
public:
|
|
19734
19793
|
unique_ptr<PragmaInfo> Copy() const {
|
|
@@ -19779,7 +19838,7 @@ public:
|
|
|
19779
19838
|
|
|
19780
19839
|
pragma_query_t query;
|
|
19781
19840
|
pragma_function_t function;
|
|
19782
|
-
|
|
19841
|
+
named_parameter_type_map_t named_parameters;
|
|
19783
19842
|
|
|
19784
19843
|
private:
|
|
19785
19844
|
PragmaFunction(string name, PragmaType pragma_type, pragma_query_t query, pragma_function_t function,
|
|
@@ -19848,12 +19907,16 @@ struct PGList;
|
|
|
19848
19907
|
|
|
19849
19908
|
namespace duckdb {
|
|
19850
19909
|
|
|
19910
|
+
struct ParserOptions {
|
|
19911
|
+
bool preserve_identifier_case = true;
|
|
19912
|
+
};
|
|
19913
|
+
|
|
19851
19914
|
//! The parser is responsible for parsing the query and converting it into a set
|
|
19852
19915
|
//! of parsed statements. The parsed statements can then be converted into a
|
|
19853
19916
|
//! plan and executed.
|
|
19854
19917
|
class Parser {
|
|
19855
19918
|
public:
|
|
19856
|
-
Parser();
|
|
19919
|
+
Parser(ParserOptions options = ParserOptions());
|
|
19857
19920
|
|
|
19858
19921
|
//! The parsed SQL statements from an invocation to ParseQuery.
|
|
19859
19922
|
vector<unique_ptr<SQLStatement>> statements;
|
|
@@ -19874,16 +19937,22 @@ public:
|
|
|
19874
19937
|
static vector<ParserKeyword> KeywordList();
|
|
19875
19938
|
|
|
19876
19939
|
//! Parses a list of expressions (i.e. the list found in a SELECT clause)
|
|
19877
|
-
static vector<unique_ptr<ParsedExpression>> ParseExpressionList(const string &select_list
|
|
19940
|
+
static vector<unique_ptr<ParsedExpression>> ParseExpressionList(const string &select_list,
|
|
19941
|
+
ParserOptions options = ParserOptions());
|
|
19878
19942
|
//! Parses a list as found in an ORDER BY expression (i.e. including optional ASCENDING/DESCENDING modifiers)
|
|
19879
|
-
static vector<OrderByNode> ParseOrderList(const string &select_list);
|
|
19943
|
+
static vector<OrderByNode> ParseOrderList(const string &select_list, ParserOptions options = ParserOptions());
|
|
19880
19944
|
//! Parses an update list (i.e. the list found in the SET clause of an UPDATE statement)
|
|
19881
19945
|
static void ParseUpdateList(const string &update_list, vector<string> &update_columns,
|
|
19882
|
-
vector<unique_ptr<ParsedExpression>> &expressions
|
|
19946
|
+
vector<unique_ptr<ParsedExpression>> &expressions,
|
|
19947
|
+
ParserOptions options = ParserOptions());
|
|
19883
19948
|
//! Parses a VALUES list (i.e. the list of expressions after a VALUES clause)
|
|
19884
|
-
static vector<vector<unique_ptr<ParsedExpression>>> ParseValuesList(const string &value_list
|
|
19949
|
+
static vector<vector<unique_ptr<ParsedExpression>>> ParseValuesList(const string &value_list,
|
|
19950
|
+
ParserOptions options = ParserOptions());
|
|
19885
19951
|
//! Parses a column list (i.e. as found in a CREATE TABLE statement)
|
|
19886
|
-
static vector<ColumnDefinition> ParseColumnList(const string &column_list);
|
|
19952
|
+
static vector<ColumnDefinition> ParseColumnList(const string &column_list, ParserOptions options = ParserOptions());
|
|
19953
|
+
|
|
19954
|
+
private:
|
|
19955
|
+
ParserOptions options;
|
|
19887
19956
|
};
|
|
19888
19957
|
} // namespace duckdb
|
|
19889
19958
|
//===----------------------------------------------------------------------===//
|