mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Better format detection for url table function/engine
This commit is contained in:
parent
eae2667a1c
commit
cef2972af4
@ -1078,7 +1078,7 @@ URLBasedDataSourceConfiguration StorageURL::getConfiguration(ASTs & args, Contex
|
||||
}
|
||||
|
||||
if (configuration.format == "auto")
|
||||
configuration.format = FormatFactory::instance().getFormatFromFileName(configuration.url, true);
|
||||
configuration.format = FormatFactory::instance().getFormatFromFileName(Poco::URI(configuration.url).getPath(), true);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void TableFunctionURL::parseArguments(const ASTPtr & ast_function, ContextPtr co
|
||||
filename = configuration.url;
|
||||
format = configuration.format;
|
||||
if (format == "auto")
|
||||
format = FormatFactory::instance().getFormatFromFileName(filename, true);
|
||||
format = FormatFactory::instance().getFormatFromFileName(Poco::URI(filename).getPath(), true);
|
||||
structure = configuration.structure;
|
||||
compression_method = configuration.compression_method;
|
||||
}
|
||||
@ -118,6 +118,11 @@ ColumnsDescription TableFunctionURL::getActualTableStructure(ContextPtr context)
|
||||
return parseColumnsListFromString(structure, context);
|
||||
}
|
||||
|
||||
String TableFunctionURL::getFormatFromFirstArgument()
|
||||
{
|
||||
return FormatFactory::instance().getFormatFromFileName(Poco::URI(filename).getPath(), true);
|
||||
}
|
||||
|
||||
void registerTableFunctionURL(TableFunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<TableFunctionURL>();
|
||||
|
@ -32,6 +32,8 @@ private:
|
||||
const std::string & table_name, const String & compression_method_) const override;
|
||||
const char * getStorageTypeName() const override { return "URL"; }
|
||||
|
||||
String getFormatFromFirstArgument() override;
|
||||
|
||||
ReadWriteBufferFromHTTP::HTTPHeaderEntries getHeaders() const;
|
||||
|
||||
URLBasedDataSourceConfiguration configuration;
|
||||
|
@ -0,0 +1 @@
|
||||
x UInt32
|
1
tests/queries/0_stateless/02409_url_format_detection.sql
Normal file
1
tests/queries/0_stateless/02409_url_format_detection.sql
Normal file
@ -0,0 +1 @@
|
||||
desc url('http://localhost:8888/test/data.tsv?get=parameterHere', auto, 'x UInt32');
|
Loading…
Reference in New Issue
Block a user