Better format detection for url table function/engine

This commit is contained in:
avogar 2022-08-25 18:31:06 +00:00
parent eae2667a1c
commit cef2972af4
5 changed files with 11 additions and 2 deletions

View File

@ -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;
}

View File

@ -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>();

View File

@ -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;

View File

@ -0,0 +1 @@
x UInt32

View File

@ -0,0 +1 @@
desc url('http://localhost:8888/test/data.tsv?get=parameterHere', auto, 'x UInt32');