duckdb 0.3.2-dev1031.0 → 0.3.2-dev1073.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/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 "1f299c4a4"
15
- #define DUCKDB_VERSION "0.3.2-dev1031"
14
+ #define DUCKDB_SOURCE_ID "66d0ef4de"
15
+ #define DUCKDB_VERSION "0.3.2-dev1073"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -1812,30 +1812,28 @@ enum class FileType {
1812
1812
 
1813
1813
  struct FileHandle {
1814
1814
  public:
1815
- FileHandle(FileSystem &file_system, string path) : file_system(file_system), path(path) {
1816
- }
1815
+ DUCKDB_API FileHandle(FileSystem &file_system, string path);
1817
1816
  FileHandle(const FileHandle &) = delete;
1818
- virtual ~FileHandle() {
1819
- }
1817
+ DUCKDB_API virtual ~FileHandle();
1820
1818
 
1821
- int64_t Read(void *buffer, idx_t nr_bytes);
1822
- int64_t Write(void *buffer, idx_t nr_bytes);
1823
- void Read(void *buffer, idx_t nr_bytes, idx_t location);
1824
- void Write(void *buffer, idx_t nr_bytes, idx_t location);
1825
- void Seek(idx_t location);
1826
- void Reset();
1827
- idx_t SeekPosition();
1828
- void Sync();
1829
- void Truncate(int64_t new_size);
1830
- string ReadLine();
1819
+ DUCKDB_API int64_t Read(void *buffer, idx_t nr_bytes);
1820
+ DUCKDB_API int64_t Write(void *buffer, idx_t nr_bytes);
1821
+ DUCKDB_API void Read(void *buffer, idx_t nr_bytes, idx_t location);
1822
+ DUCKDB_API void Write(void *buffer, idx_t nr_bytes, idx_t location);
1823
+ DUCKDB_API void Seek(idx_t location);
1824
+ DUCKDB_API void Reset();
1825
+ DUCKDB_API idx_t SeekPosition();
1826
+ DUCKDB_API void Sync();
1827
+ DUCKDB_API void Truncate(int64_t new_size);
1828
+ DUCKDB_API string ReadLine();
1831
1829
 
1832
- bool CanSeek();
1833
- bool OnDiskFile();
1834
- idx_t GetFileSize();
1835
- FileType GetType();
1830
+ DUCKDB_API bool CanSeek();
1831
+ DUCKDB_API bool OnDiskFile();
1832
+ DUCKDB_API idx_t GetFileSize();
1833
+ DUCKDB_API FileType GetType();
1836
1834
 
1837
1835
  //! Closes the file handle.
1838
- virtual void Close() = 0;
1836
+ DUCKDB_API virtual void Close() = 0;
1839
1837
 
1840
1838
  public:
1841
1839
  FileSystem &file_system;
@@ -1862,107 +1860,107 @@ public:
1862
1860
 
1863
1861
  class FileSystem {
1864
1862
  public:
1865
- virtual ~FileSystem() {
1866
- }
1863
+ DUCKDB_API virtual ~FileSystem();
1867
1864
 
1868
1865
  public:
1869
- static constexpr FileLockType DEFAULT_LOCK = FileLockType::NO_LOCK;
1870
- static constexpr FileCompressionType DEFAULT_COMPRESSION = FileCompressionType::UNCOMPRESSED;
1871
- static FileSystem &GetFileSystem(ClientContext &context);
1872
- static FileSystem &GetFileSystem(DatabaseInstance &db);
1873
- static FileOpener *GetFileOpener(ClientContext &context);
1866
+ DUCKDB_API static constexpr FileLockType DEFAULT_LOCK = FileLockType::NO_LOCK;
1867
+ DUCKDB_API static constexpr FileCompressionType DEFAULT_COMPRESSION = FileCompressionType::UNCOMPRESSED;
1868
+ DUCKDB_API static FileSystem &GetFileSystem(ClientContext &context);
1869
+ DUCKDB_API static FileSystem &GetFileSystem(DatabaseInstance &db);
1870
+ DUCKDB_API static FileOpener *GetFileOpener(ClientContext &context);
1874
1871
 
1875
- virtual unique_ptr<FileHandle> OpenFile(const string &path, uint8_t flags, FileLockType lock = DEFAULT_LOCK,
1876
- FileCompressionType compression = DEFAULT_COMPRESSION,
1877
- FileOpener *opener = nullptr);
1872
+ DUCKDB_API virtual unique_ptr<FileHandle> OpenFile(const string &path, uint8_t flags,
1873
+ FileLockType lock = DEFAULT_LOCK,
1874
+ FileCompressionType compression = DEFAULT_COMPRESSION,
1875
+ FileOpener *opener = nullptr);
1878
1876
 
1879
1877
  //! Read exactly nr_bytes from the specified location in the file. Fails if nr_bytes could not be read. This is
1880
1878
  //! equivalent to calling SetFilePointer(location) followed by calling Read().
1881
- virtual void Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1879
+ DUCKDB_API virtual void Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1882
1880
  //! Write exactly nr_bytes to the specified location in the file. Fails if nr_bytes could not be read. This is
1883
1881
  //! equivalent to calling SetFilePointer(location) followed by calling Write().
1884
- virtual void Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1882
+ DUCKDB_API virtual void Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location);
1885
1883
  //! Read nr_bytes from the specified file into the buffer, moving the file pointer forward by nr_bytes. Returns the
1886
1884
  //! amount of bytes read.
1887
- virtual int64_t Read(FileHandle &handle, void *buffer, int64_t nr_bytes);
1885
+ DUCKDB_API virtual int64_t Read(FileHandle &handle, void *buffer, int64_t nr_bytes);
1888
1886
  //! Write nr_bytes from the buffer into the file, moving the file pointer forward by nr_bytes.
1889
- virtual int64_t Write(FileHandle &handle, void *buffer, int64_t nr_bytes);
1887
+ DUCKDB_API virtual int64_t Write(FileHandle &handle, void *buffer, int64_t nr_bytes);
1890
1888
 
1891
1889
  //! Returns the file size of a file handle, returns -1 on error
1892
- virtual int64_t GetFileSize(FileHandle &handle);
1890
+ DUCKDB_API virtual int64_t GetFileSize(FileHandle &handle);
1893
1891
  //! Returns the file last modified time of a file handle, returns timespec with zero on all attributes on error
1894
- virtual time_t GetLastModifiedTime(FileHandle &handle);
1892
+ DUCKDB_API virtual time_t GetLastModifiedTime(FileHandle &handle);
1895
1893
  //! Returns the file last modified time of a file handle, returns timespec with zero on all attributes on error
1896
- virtual FileType GetFileType(FileHandle &handle);
1894
+ DUCKDB_API virtual FileType GetFileType(FileHandle &handle);
1897
1895
  //! Truncate a file to a maximum size of new_size, new_size should be smaller than or equal to the current size of
1898
1896
  //! the file
1899
- virtual void Truncate(FileHandle &handle, int64_t new_size);
1897
+ DUCKDB_API virtual void Truncate(FileHandle &handle, int64_t new_size);
1900
1898
 
1901
1899
  //! Check if a directory exists
1902
- virtual bool DirectoryExists(const string &directory);
1900
+ DUCKDB_API virtual bool DirectoryExists(const string &directory);
1903
1901
  //! Create a directory if it does not exist
1904
- virtual void CreateDirectory(const string &directory);
1902
+ DUCKDB_API virtual void CreateDirectory(const string &directory);
1905
1903
  //! Recursively remove a directory and all files in it
1906
- virtual void RemoveDirectory(const string &directory);
1904
+ DUCKDB_API virtual void RemoveDirectory(const string &directory);
1907
1905
  //! List files in a directory, invoking the callback method for each one with (filename, is_dir)
1908
- virtual bool ListFiles(const string &directory, const std::function<void(string, bool)> &callback);
1906
+ DUCKDB_API virtual bool ListFiles(const string &directory, const std::function<void(string, bool)> &callback);
1909
1907
  //! Move a file from source path to the target, StorageManager relies on this being an atomic action for ACID
1910
1908
  //! properties
1911
- virtual void MoveFile(const string &source, const string &target);
1909
+ DUCKDB_API virtual void MoveFile(const string &source, const string &target);
1912
1910
  //! Check if a file exists
1913
- virtual bool FileExists(const string &filename);
1911
+ DUCKDB_API virtual bool FileExists(const string &filename);
1914
1912
  //! Remove a file from disk
1915
- virtual void RemoveFile(const string &filename);
1913
+ DUCKDB_API virtual void RemoveFile(const string &filename);
1916
1914
  //! Sync a file handle to disk
1917
- virtual void FileSync(FileHandle &handle);
1915
+ DUCKDB_API virtual void FileSync(FileHandle &handle);
1918
1916
 
1919
1917
  //! Sets the working directory
1920
- static void SetWorkingDirectory(const string &path);
1918
+ DUCKDB_API static void SetWorkingDirectory(const string &path);
1921
1919
  //! Gets the working directory
1922
- static string GetWorkingDirectory();
1920
+ DUCKDB_API static string GetWorkingDirectory();
1923
1921
  //! Gets the users home directory
1924
- static string GetHomeDirectory();
1922
+ DUCKDB_API static string GetHomeDirectory();
1925
1923
  //! Returns the system-available memory in bytes
1926
- static idx_t GetAvailableMemory();
1924
+ DUCKDB_API static idx_t GetAvailableMemory();
1927
1925
  //! Path separator for the current file system
1928
- static string PathSeparator();
1926
+ DUCKDB_API static string PathSeparator();
1929
1927
  //! Join two paths together
1930
- static string JoinPath(const string &a, const string &path);
1928
+ DUCKDB_API static string JoinPath(const string &a, const string &path);
1931
1929
  //! Convert separators in a path to the local separators (e.g. convert "/" into \\ on windows)
1932
- static string ConvertSeparators(const string &path);
1930
+ DUCKDB_API static string ConvertSeparators(const string &path);
1933
1931
  //! Extract the base name of a file (e.g. if the input is lib/example.dll the base name is example)
1934
- static string ExtractBaseName(const string &path);
1932
+ DUCKDB_API static string ExtractBaseName(const string &path);
1935
1933
 
1936
1934
  //! Runs a glob on the file system, returning a list of matching files
1937
- virtual vector<string> Glob(const string &path);
1935
+ DUCKDB_API virtual vector<string> Glob(const string &path);
1938
1936
 
1939
1937
  //! registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.
1940
- virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
1941
- virtual void RegisterSubSystem(FileCompressionType compression_type, unique_ptr<FileSystem> fs);
1938
+ DUCKDB_API virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
1939
+ DUCKDB_API virtual void RegisterSubSystem(FileCompressionType compression_type, unique_ptr<FileSystem> fs);
1942
1940
 
1943
1941
  //! Whether or not a sub-system can handle a specific file path
1944
- virtual bool CanHandleFile(const string &fpath);
1942
+ DUCKDB_API virtual bool CanHandleFile(const string &fpath);
1945
1943
 
1946
1944
  //! Set the file pointer of a file handle to a specified location. Reads and writes will happen from this location
1947
- virtual void Seek(FileHandle &handle, idx_t location);
1945
+ DUCKDB_API virtual void Seek(FileHandle &handle, idx_t location);
1948
1946
  //! Reset a file to the beginning (equivalent to Seek(handle, 0) for simple files)
1949
- virtual void Reset(FileHandle &handle);
1950
- virtual idx_t SeekPosition(FileHandle &handle);
1947
+ DUCKDB_API virtual void Reset(FileHandle &handle);
1948
+ DUCKDB_API virtual idx_t SeekPosition(FileHandle &handle);
1951
1949
 
1952
1950
  //! Whether or not we can seek into the file
1953
- virtual bool CanSeek();
1951
+ DUCKDB_API virtual bool CanSeek();
1954
1952
  //! Whether or not the FS handles plain files on disk. This is relevant for certain optimizations, as random reads
1955
1953
  //! in a file on-disk are much cheaper than e.g. random reads in a file over the network
1956
- virtual bool OnDiskFile(FileHandle &handle);
1954
+ DUCKDB_API virtual bool OnDiskFile(FileHandle &handle);
1957
1955
 
1958
- virtual unique_ptr<FileHandle> OpenCompressedFile(unique_ptr<FileHandle> handle, bool write);
1956
+ DUCKDB_API virtual unique_ptr<FileHandle> OpenCompressedFile(unique_ptr<FileHandle> handle, bool write);
1959
1957
 
1960
1958
  //! Create a LocalFileSystem.
1961
- static unique_ptr<FileSystem> CreateLocal();
1959
+ DUCKDB_API static unique_ptr<FileSystem> CreateLocal();
1962
1960
 
1963
1961
  protected:
1964
1962
  //! Return the name of the filesytem. Used for forming diagnosis messages.
1965
- virtual std::string GetName() const = 0;
1963
+ DUCKDB_API virtual std::string GetName() const = 0;
1966
1964
  };
1967
1965
 
1968
1966
  } // namespace duckdb
@@ -5293,6 +5291,26 @@ private:
5293
5291
 
5294
5292
 
5295
5293
 
5294
+ //===----------------------------------------------------------------------===//
5295
+ // DuckDB
5296
+ //
5297
+ // duckdb/common/named_parameter_map.hpp
5298
+ //
5299
+ //
5300
+ //===----------------------------------------------------------------------===//
5301
+
5302
+
5303
+
5304
+ //===----------------------------------------------------------------------===//
5305
+ // DuckDB
5306
+ //
5307
+ // duckdb/common/case_insensitive_map.hpp
5308
+ //
5309
+ //
5310
+ //===----------------------------------------------------------------------===//
5311
+
5312
+
5313
+
5296
5314
 
5297
5315
  //===----------------------------------------------------------------------===//
5298
5316
  // DuckDB
@@ -5310,6 +5328,171 @@ namespace duckdb {
5310
5328
  using std::unordered_set;
5311
5329
  }
5312
5330
 
5331
+
5332
+ //===----------------------------------------------------------------------===//
5333
+ // DuckDB
5334
+ //
5335
+ // duckdb/common/string_util.hpp
5336
+ //
5337
+ //
5338
+ //===----------------------------------------------------------------------===//
5339
+
5340
+
5341
+
5342
+
5343
+
5344
+
5345
+
5346
+ namespace duckdb {
5347
+ /**
5348
+ * String Utility Functions
5349
+ * Note that these are not the most efficient implementations (i.e., they copy
5350
+ * memory) and therefore they should only be used for debug messages and other
5351
+ * such things.
5352
+ */
5353
+ class StringUtil {
5354
+ public:
5355
+ DUCKDB_API static bool CharacterIsSpace(char c) {
5356
+ return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
5357
+ }
5358
+ DUCKDB_API static bool CharacterIsNewline(char c) {
5359
+ return c == '\n' || c == '\r';
5360
+ }
5361
+ DUCKDB_API static bool CharacterIsDigit(char c) {
5362
+ return c >= '0' && c <= '9';
5363
+ }
5364
+ DUCKDB_API static char CharacterToLower(char c) {
5365
+ if (c >= 'A' && c <= 'Z') {
5366
+ return c - ('A' - 'a');
5367
+ }
5368
+ return c;
5369
+ }
5370
+
5371
+ //! Returns true if the needle string exists in the haystack
5372
+ DUCKDB_API static bool Contains(const string &haystack, const string &needle);
5373
+
5374
+ //! Returns true if the target string starts with the given prefix
5375
+ DUCKDB_API static bool StartsWith(string str, string prefix);
5376
+
5377
+ //! Returns true if the target string <b>ends</b> with the given suffix.
5378
+ DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
5379
+
5380
+ //! Repeat a string multiple times
5381
+ DUCKDB_API static string Repeat(const string &str, const idx_t n);
5382
+
5383
+ //! Split the input string based on newline char
5384
+ DUCKDB_API static vector<string> Split(const string &str, char delimiter);
5385
+
5386
+ //! Split the input string allong a quote. Note that any escaping is NOT supported.
5387
+ DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
5388
+
5389
+ //! Join multiple strings into one string. Components are concatenated by the given separator
5390
+ DUCKDB_API static string Join(const vector<string> &input, const string &separator);
5391
+
5392
+ //! Join multiple items of container with given size, transformed to string
5393
+ //! using function, into one string using the given separator
5394
+ template <typename C, typename S, typename Func>
5395
+ static string Join(const C &input, S count, const string &separator, Func f) {
5396
+ // The result
5397
+ std::string result;
5398
+
5399
+ // If the input isn't empty, append the first element. We do this so we
5400
+ // don't need to introduce an if into the loop.
5401
+ if (count > 0) {
5402
+ result += f(input[0]);
5403
+ }
5404
+
5405
+ // Append the remaining input components, after the first
5406
+ for (size_t i = 1; i < count; i++) {
5407
+ result += separator + f(input[i]);
5408
+ }
5409
+
5410
+ return result;
5411
+ }
5412
+
5413
+ //! Return a string that formats the give number of bytes
5414
+ DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
5415
+
5416
+ //! Convert a string to uppercase
5417
+ DUCKDB_API static string Upper(const string &str);
5418
+
5419
+ //! Convert a string to lowercase
5420
+ DUCKDB_API static string Lower(const string &str);
5421
+
5422
+ //! Format a string using printf semantics
5423
+ template <typename... Args>
5424
+ static string Format(const string fmt_str, Args... params) {
5425
+ return Exception::ConstructMessage(fmt_str, params...);
5426
+ }
5427
+
5428
+ //! Split the input string into a vector of strings based on the split string
5429
+ DUCKDB_API static vector<string> Split(const string &input, const string &split);
5430
+
5431
+ //! Remove the whitespace char in the left end of the string
5432
+ DUCKDB_API static void LTrim(string &str);
5433
+ //! Remove the whitespace char in the right end of the string
5434
+ DUCKDB_API static void RTrim(string &str);
5435
+ //! Remove the whitespace char in the left and right end of the string
5436
+ DUCKDB_API static void Trim(string &str);
5437
+
5438
+ DUCKDB_API static string Replace(string source, const string &from, const string &to);
5439
+
5440
+ //! Get the levenshtein distance from two strings
5441
+ DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
5442
+
5443
+ //! Get the top-n strings (sorted by the given score distance) from a set of scores.
5444
+ //! At least one entry is returned (if there is one).
5445
+ //! Strings are only returned if they have a score less than the threshold.
5446
+ DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
5447
+ idx_t threshold = 5);
5448
+ //! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
5449
+ //! with the given params.
5450
+ DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
5451
+ idx_t threshold = 5);
5452
+ DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
5453
+ const string &candidate = "Candidate bindings");
5454
+
5455
+ //! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
5456
+ //! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
5457
+ DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
5458
+ const string &message_prefix, idx_t n = 5);
5459
+ };
5460
+
5461
+ } // namespace duckdb
5462
+
5463
+
5464
+ namespace duckdb {
5465
+
5466
+ struct CaseInsensitiveStringHashFunction {
5467
+ uint64_t operator()(const string &str) const {
5468
+ std::hash<string> hasher;
5469
+ return hasher(StringUtil::Lower(str));
5470
+ }
5471
+ };
5472
+
5473
+ struct CaseInsensitiveStringEquality {
5474
+ bool operator()(const string &a, const string &b) const {
5475
+ return StringUtil::Lower(a) == StringUtil::Lower(b);
5476
+ }
5477
+ };
5478
+
5479
+ template <typename T>
5480
+ using case_insensitive_map_t =
5481
+ unordered_map<string, T, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
5482
+
5483
+ using case_insensitive_set_t = unordered_set<string, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
5484
+
5485
+ } // namespace duckdb
5486
+
5487
+
5488
+ namespace duckdb {
5489
+
5490
+ using named_parameter_type_map_t = case_insensitive_map_t<LogicalType>;
5491
+ using named_parameter_map_t = case_insensitive_map_t<Value>;
5492
+
5493
+ } // namespace duckdb
5494
+
5495
+
5313
5496
  //===----------------------------------------------------------------------===//
5314
5497
  // DuckDB
5315
5498
  //
@@ -5777,7 +5960,7 @@ struct TableFunctionData : public FunctionData {
5777
5960
 
5778
5961
  struct FunctionParameters {
5779
5962
  vector<Value> values;
5780
- unordered_map<string, Value> named_parameters;
5963
+ named_parameter_map_t named_parameters;
5781
5964
  };
5782
5965
 
5783
5966
  //! Function is the base class used for any type of function (scalar, aggregate or simple function)
@@ -5797,7 +5980,7 @@ public:
5797
5980
  const LogicalType &return_type);
5798
5981
  //! Returns the formatted string name(arg1, arg2.., np1=a, np2=b, ...)
5799
5982
  DUCKDB_API static string CallToString(const string &name, const vector<LogicalType> &arguments,
5800
- const unordered_map<string, LogicalType> &named_parameters);
5983
+ const named_parameter_type_map_t &named_parameters);
5801
5984
 
5802
5985
  //! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
5803
5986
  //! returns DConstants::INVALID_INDEX and sets error if none could be found
@@ -5847,14 +6030,14 @@ public:
5847
6030
  DUCKDB_API ~SimpleNamedParameterFunction() override;
5848
6031
 
5849
6032
  //! The named parameters of the function
5850
- unordered_map<string, LogicalType> named_parameters;
6033
+ named_parameter_type_map_t named_parameters;
5851
6034
 
5852
6035
  public:
5853
6036
  DUCKDB_API string ToString() override;
5854
6037
  DUCKDB_API bool HasNamedParameters();
5855
6038
 
5856
6039
  DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5857
- unordered_map<string, Value> &named_parameters,
6040
+ named_parameter_map_t &named_parameters,
5858
6041
  vector<unique_ptr<ParsedExpression>> &children);
5859
6042
  };
5860
6043
 
@@ -9673,8 +9856,6 @@ public:
9673
9856
 
9674
9857
 
9675
9858
 
9676
-
9677
-
9678
9859
  #include <functional>
9679
9860
 
9680
9861
  namespace duckdb {
@@ -9694,7 +9875,7 @@ struct TableFilterCollection {
9694
9875
  };
9695
9876
 
9696
9877
  typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, vector<Value> &inputs,
9697
- unordered_map<string, Value> &named_parameters,
9878
+ named_parameter_map_t &named_parameters,
9698
9879
  vector<LogicalType> &input_table_types,
9699
9880
  vector<string> &input_table_names,
9700
9881
  vector<LogicalType> &return_types, vector<string> &names);
@@ -10534,7 +10715,7 @@ public:
10534
10715
  //! Create a relation from calling a table in/out function on the input relation
10535
10716
  DUCKDB_API shared_ptr<Relation> TableFunction(const std::string &fname, const vector<Value> &values);
10536
10717
  DUCKDB_API shared_ptr<Relation> TableFunction(const std::string &fname, const vector<Value> &values,
10537
- const unordered_map<string, Value> &named_parameters);
10718
+ const named_parameter_map_t &named_parameters);
10538
10719
 
10539
10720
  public:
10540
10721
  //! Whether or not the relation inherits column bindings from its child or not, only relevant for binding
@@ -10791,7 +10972,7 @@ public:
10791
10972
  //! Returns a relation that calls a specified table function
10792
10973
  DUCKDB_API shared_ptr<Relation> TableFunction(const string &tname);
10793
10974
  DUCKDB_API shared_ptr<Relation> TableFunction(const string &tname, const vector<Value> &values,
10794
- const unordered_map<string, Value> &named_parameters);
10975
+ const named_parameter_map_t &named_parameters);
10795
10976
  DUCKDB_API shared_ptr<Relation> TableFunction(const string &tname, const vector<Value> &values);
10796
10977
  //! Returns a relation that produces values
10797
10978
  DUCKDB_API shared_ptr<Relation> Values(const vector<vector<Value>> &values);
@@ -11002,173 +11183,6 @@ private:
11002
11183
 
11003
11184
  } // namespace duckdb
11004
11185
 
11005
- //===----------------------------------------------------------------------===//
11006
- // DuckDB
11007
- //
11008
- // duckdb/common/case_insensitive_map.hpp
11009
- //
11010
- //
11011
- //===----------------------------------------------------------------------===//
11012
-
11013
-
11014
-
11015
-
11016
-
11017
-
11018
- //===----------------------------------------------------------------------===//
11019
- // DuckDB
11020
- //
11021
- // duckdb/common/string_util.hpp
11022
- //
11023
- //
11024
- //===----------------------------------------------------------------------===//
11025
-
11026
-
11027
-
11028
-
11029
-
11030
-
11031
-
11032
- namespace duckdb {
11033
- /**
11034
- * String Utility Functions
11035
- * Note that these are not the most efficient implementations (i.e., they copy
11036
- * memory) and therefore they should only be used for debug messages and other
11037
- * such things.
11038
- */
11039
- class StringUtil {
11040
- public:
11041
- DUCKDB_API static bool CharacterIsSpace(char c) {
11042
- return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
11043
- }
11044
- DUCKDB_API static bool CharacterIsNewline(char c) {
11045
- return c == '\n' || c == '\r';
11046
- }
11047
- DUCKDB_API static bool CharacterIsDigit(char c) {
11048
- return c >= '0' && c <= '9';
11049
- }
11050
- DUCKDB_API static char CharacterToLower(char c) {
11051
- if (c >= 'A' && c <= 'Z') {
11052
- return c - ('A' - 'a');
11053
- }
11054
- return c;
11055
- }
11056
-
11057
- //! Returns true if the needle string exists in the haystack
11058
- DUCKDB_API static bool Contains(const string &haystack, const string &needle);
11059
-
11060
- //! Returns true if the target string starts with the given prefix
11061
- DUCKDB_API static bool StartsWith(string str, string prefix);
11062
-
11063
- //! Returns true if the target string <b>ends</b> with the given suffix.
11064
- DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
11065
-
11066
- //! Repeat a string multiple times
11067
- DUCKDB_API static string Repeat(const string &str, const idx_t n);
11068
-
11069
- //! Split the input string based on newline char
11070
- DUCKDB_API static vector<string> Split(const string &str, char delimiter);
11071
-
11072
- //! Split the input string allong a quote. Note that any escaping is NOT supported.
11073
- DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
11074
-
11075
- //! Join multiple strings into one string. Components are concatenated by the given separator
11076
- DUCKDB_API static string Join(const vector<string> &input, const string &separator);
11077
-
11078
- //! Join multiple items of container with given size, transformed to string
11079
- //! using function, into one string using the given separator
11080
- template <typename C, typename S, typename Func>
11081
- static string Join(const C &input, S count, const string &separator, Func f) {
11082
- // The result
11083
- std::string result;
11084
-
11085
- // If the input isn't empty, append the first element. We do this so we
11086
- // don't need to introduce an if into the loop.
11087
- if (count > 0) {
11088
- result += f(input[0]);
11089
- }
11090
-
11091
- // Append the remaining input components, after the first
11092
- for (size_t i = 1; i < count; i++) {
11093
- result += separator + f(input[i]);
11094
- }
11095
-
11096
- return result;
11097
- }
11098
-
11099
- //! Return a string that formats the give number of bytes
11100
- DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
11101
-
11102
- //! Convert a string to uppercase
11103
- DUCKDB_API static string Upper(const string &str);
11104
-
11105
- //! Convert a string to lowercase
11106
- DUCKDB_API static string Lower(const string &str);
11107
-
11108
- //! Format a string using printf semantics
11109
- template <typename... Args>
11110
- static string Format(const string fmt_str, Args... params) {
11111
- return Exception::ConstructMessage(fmt_str, params...);
11112
- }
11113
-
11114
- //! Split the input string into a vector of strings based on the split string
11115
- DUCKDB_API static vector<string> Split(const string &input, const string &split);
11116
-
11117
- //! Remove the whitespace char in the left end of the string
11118
- DUCKDB_API static void LTrim(string &str);
11119
- //! Remove the whitespace char in the right end of the string
11120
- DUCKDB_API static void RTrim(string &str);
11121
- //! Remove the whitespace char in the left and right end of the string
11122
- DUCKDB_API static void Trim(string &str);
11123
-
11124
- DUCKDB_API static string Replace(string source, const string &from, const string &to);
11125
-
11126
- //! Get the levenshtein distance from two strings
11127
- DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
11128
-
11129
- //! Get the top-n strings (sorted by the given score distance) from a set of scores.
11130
- //! At least one entry is returned (if there is one).
11131
- //! Strings are only returned if they have a score less than the threshold.
11132
- DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
11133
- idx_t threshold = 5);
11134
- //! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
11135
- //! with the given params.
11136
- DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
11137
- idx_t threshold = 5);
11138
- DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
11139
- const string &candidate = "Candidate bindings");
11140
-
11141
- //! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
11142
- //! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
11143
- DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
11144
- const string &message_prefix, idx_t n = 5);
11145
- };
11146
-
11147
- } // namespace duckdb
11148
-
11149
-
11150
- namespace duckdb {
11151
-
11152
- struct CaseInsensitiveStringHashFunction {
11153
- uint64_t operator()(const string &str) const {
11154
- std::hash<string> hasher;
11155
- return hasher(StringUtil::Lower(str));
11156
- }
11157
- };
11158
-
11159
- struct CaseInsensitiveStringEquality {
11160
- bool operator()(const string &a, const string &b) const {
11161
- return StringUtil::Lower(a) == StringUtil::Lower(b);
11162
- }
11163
- };
11164
-
11165
- template <typename T>
11166
- using case_insensitive_map_t =
11167
- unordered_map<string, T, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
11168
-
11169
- using case_insensitive_set_t = unordered_set<string, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality>;
11170
-
11171
- } // namespace duckdb
11172
11186
 
11173
11187
 
11174
11188
 
@@ -11490,17 +11504,17 @@ public:
11490
11504
  DBConfig config;
11491
11505
 
11492
11506
  public:
11493
- StorageManager &GetStorageManager();
11494
- Catalog &GetCatalog();
11495
- FileSystem &GetFileSystem();
11496
- TransactionManager &GetTransactionManager();
11497
- TaskScheduler &GetScheduler();
11498
- ObjectCache &GetObjectCache();
11499
- ConnectionManager &GetConnectionManager();
11507
+ DUCKDB_API StorageManager &GetStorageManager();
11508
+ DUCKDB_API Catalog &GetCatalog();
11509
+ DUCKDB_API FileSystem &GetFileSystem();
11510
+ DUCKDB_API TransactionManager &GetTransactionManager();
11511
+ DUCKDB_API TaskScheduler &GetScheduler();
11512
+ DUCKDB_API ObjectCache &GetObjectCache();
11513
+ DUCKDB_API ConnectionManager &GetConnectionManager();
11500
11514
 
11501
11515
  idx_t NumberOfThreads();
11502
11516
 
11503
- static DatabaseInstance &GetDatabase(ClientContext &context);
11517
+ DUCKDB_API static DatabaseInstance &GetDatabase(ClientContext &context);
11504
11518
 
11505
11519
  private:
11506
11520
  void Initialize(const char *path, DBConfig *config);
@@ -15817,7 +15831,7 @@ public:
15817
15831
  SchemaCatalogEntry *BindCreateFunctionInfo(CreateInfo &info);
15818
15832
 
15819
15833
  //! Check usage, and cast named parameters to their types
15820
- static void BindNamedParameters(unordered_map<string, LogicalType> &types, unordered_map<string, Value> &values,
15834
+ static void BindNamedParameters(named_parameter_type_map_t &types, named_parameter_map_t &values,
15821
15835
  QueryErrorContext &error_context, string &func_name);
15822
15836
 
15823
15837
  unique_ptr<BoundTableRef> Bind(TableRef &ref);
@@ -15944,7 +15958,7 @@ private:
15944
15958
  unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
15945
15959
 
15946
15960
  bool BindFunctionParameters(vector<unique_ptr<ParsedExpression>> &expressions, vector<LogicalType> &arguments,
15947
- vector<Value> &parameters, unordered_map<string, Value> &named_parameters,
15961
+ vector<Value> &parameters, named_parameter_map_t &named_parameters,
15948
15962
  unique_ptr<BoundSubqueryRef> &subquery, string &error);
15949
15963
 
15950
15964
  unique_ptr<LogicalOperator> CreatePlan(BoundBaseTableRef &ref);
@@ -17285,6 +17299,10 @@ struct ClientConfig {
17285
17299
  //! The wait time before showing the progress bar
17286
17300
  int wait_time = 2000;
17287
17301
 
17302
+ //! Preserve identifier case while parsing.
17303
+ //! If false, all unquoted identifiers are lower-cased (e.g. "MyTable" -> "mytable").
17304
+ bool preserve_identifier_case = true;
17305
+
17288
17306
  // Whether or not aggressive query verification is enabled
17289
17307
  bool query_verification_enabled = false;
17290
17308
  //! Enable the running of optimizers
@@ -17329,6 +17347,7 @@ class ClientContextLock;
17329
17347
  struct CreateScalarFunctionInfo;
17330
17348
  class ScalarFunctionCatalogEntry;
17331
17349
  struct ActiveQueryContext;
17350
+ struct ParserOptions;
17332
17351
 
17333
17352
  //! The ClientContext holds information relevant to the current client session
17334
17353
  //! during execution
@@ -17446,6 +17465,9 @@ public:
17446
17465
  //! Equivalent to CURRENT_SETTING(key) SQL function.
17447
17466
  DUCKDB_API bool TryGetCurrentSetting(const std::string &key, Value &result);
17448
17467
 
17468
+ //! Returns the parser options for this client context
17469
+ DUCKDB_API ParserOptions GetParserOptions();
17470
+
17449
17471
  DUCKDB_API unique_ptr<DataChunk> Fetch(ClientContextLock &lock, StreamQueryResult &result);
17450
17472
 
17451
17473
  //! Whether or not the given result object (streaming query result or pending query result) is active
@@ -19763,7 +19785,7 @@ struct PragmaInfo : public ParseInfo {
19763
19785
  //! Parameter list (if any)
19764
19786
  vector<Value> parameters;
19765
19787
  //! Named parameter list (if any)
19766
- unordered_map<string, Value> named_parameters;
19788
+ named_parameter_map_t named_parameters;
19767
19789
 
19768
19790
  public:
19769
19791
  unique_ptr<PragmaInfo> Copy() const {
@@ -19814,7 +19836,7 @@ public:
19814
19836
 
19815
19837
  pragma_query_t query;
19816
19838
  pragma_function_t function;
19817
- unordered_map<string, LogicalType> named_parameters;
19839
+ named_parameter_type_map_t named_parameters;
19818
19840
 
19819
19841
  private:
19820
19842
  PragmaFunction(string name, PragmaType pragma_type, pragma_query_t query, pragma_function_t function,
@@ -19883,12 +19905,16 @@ struct PGList;
19883
19905
 
19884
19906
  namespace duckdb {
19885
19907
 
19908
+ struct ParserOptions {
19909
+ bool preserve_identifier_case = true;
19910
+ };
19911
+
19886
19912
  //! The parser is responsible for parsing the query and converting it into a set
19887
19913
  //! of parsed statements. The parsed statements can then be converted into a
19888
19914
  //! plan and executed.
19889
19915
  class Parser {
19890
19916
  public:
19891
- Parser();
19917
+ Parser(ParserOptions options = ParserOptions());
19892
19918
 
19893
19919
  //! The parsed SQL statements from an invocation to ParseQuery.
19894
19920
  vector<unique_ptr<SQLStatement>> statements;
@@ -19909,16 +19935,22 @@ public:
19909
19935
  static vector<ParserKeyword> KeywordList();
19910
19936
 
19911
19937
  //! Parses a list of expressions (i.e. the list found in a SELECT clause)
19912
- static vector<unique_ptr<ParsedExpression>> ParseExpressionList(const string &select_list);
19938
+ static vector<unique_ptr<ParsedExpression>> ParseExpressionList(const string &select_list,
19939
+ ParserOptions options = ParserOptions());
19913
19940
  //! Parses a list as found in an ORDER BY expression (i.e. including optional ASCENDING/DESCENDING modifiers)
19914
- static vector<OrderByNode> ParseOrderList(const string &select_list);
19941
+ static vector<OrderByNode> ParseOrderList(const string &select_list, ParserOptions options = ParserOptions());
19915
19942
  //! Parses an update list (i.e. the list found in the SET clause of an UPDATE statement)
19916
19943
  static void ParseUpdateList(const string &update_list, vector<string> &update_columns,
19917
- vector<unique_ptr<ParsedExpression>> &expressions);
19944
+ vector<unique_ptr<ParsedExpression>> &expressions,
19945
+ ParserOptions options = ParserOptions());
19918
19946
  //! Parses a VALUES list (i.e. the list of expressions after a VALUES clause)
19919
- static vector<vector<unique_ptr<ParsedExpression>>> ParseValuesList(const string &value_list);
19947
+ static vector<vector<unique_ptr<ParsedExpression>>> ParseValuesList(const string &value_list,
19948
+ ParserOptions options = ParserOptions());
19920
19949
  //! Parses a column list (i.e. as found in a CREATE TABLE statement)
19921
- static vector<ColumnDefinition> ParseColumnList(const string &column_list);
19950
+ static vector<ColumnDefinition> ParseColumnList(const string &column_list, ParserOptions options = ParserOptions());
19951
+
19952
+ private:
19953
+ ParserOptions options;
19922
19954
  };
19923
19955
  } // namespace duckdb
19924
19956
  //===----------------------------------------------------------------------===//
@@ -20479,7 +20511,7 @@ struct StrfTimeFormat : public StrTimeFormat {
20479
20511
  void FormatString(date_t date, int32_t data[7], char *target);
20480
20512
  void FormatString(date_t date, dtime_t time, char *target);
20481
20513
 
20482
- static string Format(timestamp_t timestamp, const string &format);
20514
+ DUCKDB_API static string Format(timestamp_t timestamp, const string &format);
20483
20515
 
20484
20516
  protected:
20485
20517
  //! The variable-length specifiers. To determine total string size, these need to be checked.
@@ -20513,9 +20545,14 @@ public:
20513
20545
  timestamp_t ToTimestamp();
20514
20546
  string FormatError(string_t input, const string &format_specifier);
20515
20547
  };
20548
+
20549
+ public:
20516
20550
  //! The full format specifier, for error messages
20517
20551
  string format_specifier;
20518
20552
 
20553
+ public:
20554
+ DUCKDB_API static ParseResult Parse(const string &format, const string &text);
20555
+
20519
20556
  bool Parse(string_t str, ParseResult &result);
20520
20557
 
20521
20558
  bool TryParseDate(string_t str, date_t &result, string &error_message);