fix assertion in table function file()

This commit is contained in:
Alexander Tokmakov 2020-10-20 15:29:46 +03:00
parent b4f0e08369
commit 62a0ee8255

View File

@ -23,6 +23,7 @@ namespace ErrorCodes
extern const int LOGICAL_ERROR;
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
extern const int INCORRECT_FILE_NAME;
extern const int BAD_ARGUMENTS;
}
void ITableFunctionFileLike::parseArguments(const ASTPtr & ast_function, const Context & context)
@ -46,15 +47,18 @@ void ITableFunctionFileLike::parseArguments(const ASTPtr & ast_function, const C
if (args.size() == 2 && getName() == "file")
{
if (format != "Distributed")
if (format == "Distributed")
return;
throw Exception("Table function '" + getName() + "' allows 2 arguments only for Distributed format.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
}
else if (args.size() != 3 && args.size() != 4)
if (args.size() != 3 && args.size() != 4)
throw Exception("Table function '" + getName() + "' requires 3 or 4 arguments: filename, format, structure and compression method (default auto).",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
if (args.size() > 2)
structure = args[2]->as<ASTLiteral &>().value.safeGet<String>();
if (structure.empty())
throw Exception("Table structure is empty", ErrorCodes::BAD_ARGUMENTS);
if (args.size() == 4)
compression_method = args[3]->as<ASTLiteral &>().value.safeGet<String>();