Skip to content

Commit

Permalink
chore: Update vendored sources to duckdb/duckdb@b9ecd8d
Browse files Browse the repository at this point in the history
Merge pull request duckdb/duckdb#11831 from samansmink/hugging-face-fs
Merge pull request duckdb/duckdb#11981 from Tishj/python_optional_numpy
Merge pull request duckdb/duckdb#11980 from Tishj/pyfs_needs_gil
  • Loading branch information
krlmlr committed May 13, 2024
1 parent 3fadede commit 03f1ffd
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/duckdb/src/common/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ FileType FileHandle::GetType() {
}

bool FileSystem::IsRemoteFile(const string &path) {
const string prefixes[] = {"http://", "https://", "s3://", "s3a://", "s3n://", "gcs://", "gs://", "r2://"};
const string prefixes[] = {"http://", "https://", "s3://", "s3a://", "s3n://", "gcs://", "gs://", "r2://", "hf://"};
for (auto &prefix : prefixes) {
if (StringUtil::StartsWith(path, prefix)) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "3-dev876"
#define DUCKDB_PATCH_VERSION "3-dev897"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 10
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 0
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v0.10.3-dev876"
#define DUCKDB_VERSION "v0.10.3-dev897"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "ffb3f9789f"
#define DUCKDB_SOURCE_ID "b9ecd8da3a"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
4 changes: 4 additions & 0 deletions src/duckdb/src/include/duckdb/common/file_opener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace duckdb {

struct CatalogTransaction;
class SecretManager;
class ClientContext;
class Value;

Expand All @@ -33,8 +35,10 @@ class FileOpener {
virtual optional_ptr<ClientContext> TryGetClientContext() = 0;
virtual optional_ptr<DatabaseInstance> TryGetDatabase() = 0;

DUCKDB_API static unique_ptr<CatalogTransaction> TryGetCatalogTransaction(optional_ptr<FileOpener> opener);
DUCKDB_API static optional_ptr<ClientContext> TryGetClientContext(optional_ptr<FileOpener> opener);
DUCKDB_API static optional_ptr<DatabaseInstance> TryGetDatabase(optional_ptr<FileOpener> opener);
DUCKDB_API static optional_ptr<SecretManager> TryGetSecretManager(optional_ptr<FileOpener> opener);
DUCKDB_API static SettingLookupResult TryGetCurrentSetting(optional_ptr<FileOpener> opener, const string &key,
Value &result);
DUCKDB_API static SettingLookupResult TryGetCurrentSetting(optional_ptr<FileOpener> opener, const string &key,
Expand Down
19 changes: 12 additions & 7 deletions src/duckdb/src/include/duckdb/main/extension_entries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
{"calendar", "icu"},
{"enable_server_cert_verification", "httpfs"},
{"force_download", "httpfs"},
{"hf_max_per_page", "httpfs"},
{"http_keep_alive", "httpfs"},
{"http_retries", "httpfs"},
{"http_retry_backoff", "httpfs"},
Expand Down Expand Up @@ -326,9 +327,9 @@ static constexpr ExtensionEntry EXTENSION_COLLATIONS[] = {
// Note: these are currently hardcoded in scripts/generate_extensions_function.py
// TODO: automate by passing though to script via duckdb
static constexpr ExtensionEntry EXTENSION_FILE_PREFIXES[] = {
{"http://", "httpfs"}, {"https://", "httpfs"}, {"s3://", "httpfs"}, {"s3a://", "httpfs"},
{"s3n://", "httpfs"}, {"gcs://", "httpfs"}, {"gs://", "httpfs"}, {"r2://", "httpfs"},
{"azure://", "azure"}, {"az://", "azure"}, {"abfss://", "azure"}}; // END_OF_EXTENSION_FILE_PREFIXES
{"http://", "httpfs"}, {"https://", "httpfs"}, {"s3://", "httpfs"}, {"s3a://", "httpfs"}, {"s3n://", "httpfs"},
{"gcs://", "httpfs"}, {"gs://", "httpfs"}, {"r2://", "httpfs"}, {"azure://", "azure"}, {"az://", "azure"},
{"abfss://", "azure"}, {"hf://", "httpfs"}}; // END_OF_EXTENSION_FILE_PREFIXES

// Note: these are currently hardcoded in scripts/generate_extensions_function.py
// TODO: automate by passing though to script via duckdb
Expand All @@ -346,14 +347,18 @@ static constexpr ExtensionEntry EXTENSION_FILE_CONTAINS[] = {{".parquet?", "parq
// Note: these are currently hardcoded in scripts/generate_extensions_function.py
// TODO: automate by passing though to script via duckdb
static constexpr ExtensionEntry EXTENSION_SECRET_TYPES[] = {
{"s3", "httpfs"}, {"r2", "httpfs"}, {"gcs", "httpfs"}, {"azure", "azure"}}; // EXTENSION_SECRET_TYPES
{"s3", "httpfs"}, {"r2", "httpfs"}, {"gcs", "httpfs"},
{"azure", "azure"}, {"huggingface", "httpfs"}, {"bearer", "httpfs"}}; // EXTENSION_SECRET_TYPES

// Note: these are currently hardcoded in scripts/generate_extensions_function.py
// TODO: automate by passing though to script via duckdb
static constexpr ExtensionEntry EXTENSION_SECRET_PROVIDERS[] = {
{"s3/config", "httpfs"}, {"gcs/config", "httpfs"}, {"r2/config", "httpfs"},
{"s3/credential_chain", "aws"}, {"gcs/credential_chain", "aws"}, {"r2/credential_chain", "aws"},
{"azure/config", "azure"}, {"azure/credential_chain", "azure"}}; // EXTENSION_SECRET_PROVIDERS
{"s3/config", "httpfs"}, {"gcs/config", "httpfs"},
{"r2/config", "httpfs"}, {"s3/credential_chain", "aws"},
{"gcs/credential_chain", "aws"}, {"r2/credential_chain", "aws"},
{"azure/config", "azure"}, {"azure/credential_chain", "azure"},
{"huggingface/config", "httfps"}, {"huggingface/cache", "httpfs"},
{"bearer/config", "httpfs"}}; // EXTENSION_SECRET_PROVIDERS

static constexpr const char *AUTOLOADABLE_EXTENSIONS[] = {
"aws", "azure", "autocomplete", "excel", "fts", "httpfs", "inet",
Expand Down
31 changes: 31 additions & 0 deletions src/duckdb/src/main/client_context_file_opener.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "duckdb/main/client_context_file_opener.hpp"
#include "duckdb/catalog/catalog_transaction.hpp"

#include "duckdb/main/database.hpp"
#include "duckdb/common/file_opener.hpp"
#include "duckdb/main/client_context.hpp"

Expand All @@ -18,6 +20,22 @@ optional_ptr<DatabaseInstance> ClientContextFileOpener::TryGetDatabase() {
return context.db.get();
}

unique_ptr<CatalogTransaction> FileOpener::TryGetCatalogTransaction(optional_ptr<FileOpener> opener) {
if (!opener) {
return nullptr;
}
auto context = opener->TryGetClientContext();
if (context) {
return make_uniq<CatalogTransaction>(CatalogTransaction::GetSystemCatalogTransaction(*context));
}

auto db = opener->TryGetDatabase();
if (db) {
return make_uniq<CatalogTransaction>(CatalogTransaction::GetSystemTransaction(*db));
}
return nullptr;
}

optional_ptr<ClientContext> FileOpener::TryGetClientContext(optional_ptr<FileOpener> opener) {
if (!opener) {
return nullptr;
Expand All @@ -32,6 +50,19 @@ optional_ptr<DatabaseInstance> FileOpener::TryGetDatabase(optional_ptr<FileOpene
return opener->TryGetDatabase();
}

optional_ptr<SecretManager> FileOpener::TryGetSecretManager(optional_ptr<FileOpener> opener) {
if (!opener) {
return nullptr;
}

auto db = opener->TryGetDatabase();
if (!db) {
return nullptr;
}

return &db->GetSecretManager();
}

SettingLookupResult FileOpener::TryGetCurrentSetting(optional_ptr<FileOpener> opener, const string &key,
Value &result) {
if (!opener) {
Expand Down

0 comments on commit 03f1ffd

Please sign in to comment.