diff --git a/src/Formats/ReadSchemaUtils.cpp b/src/Formats/ReadSchemaUtils.cpp index 3e88b51152d..ccb017a60ac 100644 --- a/src/Formats/ReadSchemaUtils.cpp +++ b/src/Formats/ReadSchemaUtils.cpp @@ -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); } diff --git a/src/TableFunctions/ITableFunctionFileLike.cpp b/src/TableFunctions/ITableFunctionFileLike.cpp index 3388a7ec9f6..cf4a62a30f4 100644 --- a/src/TableFunctions/ITableFunctionFileLike.cpp +++ b/src/TableFunctions/ITableFunctionFileLike.cpp @@ -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().value.safeGet(); - if (structure == "auto") - checkIfFormatSupportsAutoStructure(getName(), format); if (structure.empty()) throw Exception(ErrorCodes::BAD_ARGUMENTS, diff --git a/tests/queries/0_stateless/02269_insert_select_with_format_without_schema_inference.reference b/tests/queries/0_stateless/02269_insert_select_with_format_without_schema_inference.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/tests/queries/0_stateless/02269_insert_select_with_format_without_schema_inference.reference @@ -0,0 +1 @@ +1 diff --git a/tests/queries/0_stateless/02269_insert_select_with_format_without_schema_inference.sql b/tests/queries/0_stateless/02269_insert_select_with_format_without_schema_inference.sql new file mode 100644 index 00000000000..8ea9dba2696 --- /dev/null +++ b/tests/queries/0_stateless/02269_insert_select_with_format_without_schema_inference.sql @@ -0,0 +1,2 @@ +insert into function file('02269_data', 'RowBinary') select 1; +select * from file('02269_data', 'RowBinary', 'x UInt8');