Skip to content

Add httpfs_client_implementation option, currently only default and httplib are valid #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions extension/httpfs/httpfs_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@

namespace duckdb {

static void SetHttpfsClientImplementation(DBConfig &config, const string &value) {
if (config.http_util && config.http_util->GetName() == "WasmHTTPUtils") {
if (value == "wasm" || value == "default") {
// Already handled, do not override
return;
}
throw InvalidInputException("Unsupported option for httpfs_client_implementation, only `wasm` and "
"`default` are currently supported for duckdb-wasm");
}
if (value == "httplib" || value == "default") {
if (!config.http_util || config.http_util->GetName() != "HTTPFSUtil") {
config.http_util = make_shared_ptr<HTTPFSUtil>();
}
return;
}
throw InvalidInputException("Unsupported option for httpfs_client_implementation, only `curl`, `httplib` and "
"`default` are currently supported");
}

static void LoadInternal(DatabaseInstance &instance) {
auto &fs = instance.GetFileSystem();

Expand Down Expand Up @@ -64,11 +83,16 @@ static void LoadInternal(DatabaseInstance &instance) {
config.AddExtensionOption("hf_max_per_page", "Debug option to limit number of items returned in list requests",
LogicalType::UBIGINT, Value::UBIGINT(0));

if (config.http_util && config.http_util->GetName() == "WasmHTTPUtils") {
// Already handled, do not override
} else {
config.http_util = make_shared_ptr<HTTPFSUtil>();
}
auto callback_httpfs_client_implementation = [](ClientContext &context, SetScope scope, Value &parameter) {
auto &config = DBConfig::GetConfig(context);
string value = StringValue::Get(parameter);
SetHttpfsClientImplementation(config, value);
};

config.AddExtensionOption("httpfs_client_implementation", "Select which is the HTTPUtil implementation to be used",
LogicalType::VARCHAR, "default", callback_httpfs_client_implementation);

SetHttpfsClientImplementation(config, "default");

auto provider = make_uniq<AWSEnvironmentCredentialsProvider>(config);
provider->SetAll();
Expand Down
16 changes: 16 additions & 0 deletions test/sql/httpfs_client/httpfs_client_implementation.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# name: test/sql/htpfs_client/httpfs_client_implementation.test
# description: Tests basic valus for httpfs_client_implementation
# group: [httpfs_client]

require httpfs

statement ok
set httpfs_client_implementation = 'default';

statement ok
set httpfs_client_implementation = 'httplib';

statement error
set httpfs_client_implementation = 'something else';
----
Unsupported option for httpfs_client_implementation
Loading