mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Merge pull request #16189 from ClickHouse/fix_assertion_table_function_file
Fix assertion in table function file()
This commit is contained in:
commit
3c53d47840
@ -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")
|
||||
throw Exception("Table function '" + getName() + "' allows 2 arguments only for Distributed format.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
||||
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>();
|
||||
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>();
|
||||
|
Loading…
Reference in New Issue
Block a user