mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Allow insert select for files with formats without schema inference
This commit is contained in:
parent
6a165787a6
commit
ae88549c4f
@ -94,7 +94,7 @@ ColumnsDescription readSchemaFromFormat(
|
||||
}
|
||||
}
|
||||
else
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "{} file format doesn't support schema inference", format_name);
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "{} file format doesn't support schema inference. You must specify the structure manually", format_name);
|
||||
|
||||
return ColumnsDescription(names_and_types);
|
||||
}
|
||||
|
@ -25,24 +25,6 @@ namespace ErrorCodes
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void checkIfFormatSupportsAutoStructure(const String & name, const String & format)
|
||||
{
|
||||
if (name == "file" && format == "Distributed")
|
||||
return;
|
||||
|
||||
if (FormatFactory::instance().checkIfFormatHasAnySchemaReader(format))
|
||||
return;
|
||||
|
||||
throw Exception(
|
||||
"Table function '" + name
|
||||
+ "' allows automatic structure determination only for formats that support schema inference and for Distributed format in table function "
|
||||
"'file'",
|
||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||
}
|
||||
}
|
||||
|
||||
void ITableFunctionFileLike::parseArguments(const ASTPtr & ast_function, ContextPtr context)
|
||||
{
|
||||
/// Parse args
|
||||
@ -68,18 +50,13 @@ void ITableFunctionFileLike::parseArguments(const ASTPtr & ast_function, Context
|
||||
format = FormatFactory::instance().getFormatFromFileName(filename, true);
|
||||
|
||||
if (args.size() <= 2)
|
||||
{
|
||||
checkIfFormatSupportsAutoStructure(getName(), format);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.size() != 3 && args.size() != 4)
|
||||
throw Exception("Table function '" + getName() + "' requires 1, 2, 3 or 4 arguments: filename, format (default auto), structure (default auto) and compression method (default auto)",
|
||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||
|
||||
structure = args[2]->as<ASTLiteral &>().value.safeGet<String>();
|
||||
if (structure == "auto")
|
||||
checkIfFormatSupportsAutoStructure(getName(), format);
|
||||
|
||||
if (structure.empty())
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,2 @@
|
||||
insert into function file('02269_data', 'RowBinary') select 1;
|
||||
select * from file('02269_data', 'RowBinary', 'x UInt8');
|
Loading…
Reference in New Issue
Block a user