mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #54373 from Avogar/fix-s3-url-invalid-characters-error
Fix possible error 'URI contains invalid characters' in s3 table function
This commit is contained in:
commit
00fcb8aceb
@ -58,6 +58,11 @@ void TableFunctionS3::parseArgumentsImpl(ASTs & args, const ContextPtr & context
|
||||
if (auto named_collection = tryGetNamedCollectionWithOverrides(args, context))
|
||||
{
|
||||
StorageS3::processNamedCollectionResult(configuration, *named_collection);
|
||||
if (configuration.format == "auto")
|
||||
{
|
||||
String file_path = named_collection->getOrDefault<String>("filename", Poco::URI(named_collection->get<String>("url")).getPath());
|
||||
configuration.format = FormatFactory::instance().getFormatFromFileName(file_path, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -152,7 +157,8 @@ void TableFunctionS3::parseArgumentsImpl(ASTs & args, const ContextPtr & context
|
||||
}
|
||||
|
||||
/// This argument is always the first
|
||||
configuration.url = S3::URI(checkAndGetLiteralArgument<String>(args[0], "url"));
|
||||
String url = checkAndGetLiteralArgument<String>(args[0], "url");
|
||||
configuration.url = S3::URI(url);
|
||||
|
||||
if (args_to_idx.contains("format"))
|
||||
{
|
||||
@ -176,12 +182,12 @@ void TableFunctionS3::parseArgumentsImpl(ASTs & args, const ContextPtr & context
|
||||
configuration.auth_settings.secret_access_key = checkAndGetLiteralArgument<String>(args[args_to_idx["secret_access_key"]], "secret_access_key");
|
||||
|
||||
configuration.auth_settings.no_sign_request = no_sign_request;
|
||||
|
||||
if (configuration.format == "auto")
|
||||
configuration.format = FormatFactory::instance().getFormatFromFileName(Poco::URI(url).getPath(), true);
|
||||
}
|
||||
|
||||
configuration.keys = {configuration.url.key};
|
||||
|
||||
if (configuration.format == "auto")
|
||||
configuration.format = FormatFactory::instance().getFormatFromFileName(Poco::URI(configuration.url.uri.getPath()).getPath(), true);
|
||||
}
|
||||
|
||||
void TableFunctionS3::parseArguments(const ASTPtr & ast_function, ContextPtr context)
|
||||
|
@ -0,0 +1,6 @@
|
||||
-- Tags: no-fasttest
|
||||
|
||||
select * from s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/MyPrefix/BU%20-%20UNIT%20-%201/*.parquet'); -- { serverError CANNOT_EXTRACT_TABLE_STRUCTURE }
|
||||
|
||||
select * from s3('https://datasets-documentation.s3.eu-west-3.amazonaws.com/MyPrefix/*.parquet?some_tocken=ABCD'); -- { serverError CANNOT_EXTRACT_TABLE_STRUCTURE }
|
||||
|
Loading…
Reference in New Issue
Block a user