mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
fix assertion in table function file()
This commit is contained in:
parent
b4f0e08369
commit
62a0ee8255
@ -23,6 +23,7 @@ namespace ErrorCodes
|
|||||||
extern const int LOGICAL_ERROR;
|
extern const int LOGICAL_ERROR;
|
||||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||||
extern const int INCORRECT_FILE_NAME;
|
extern const int INCORRECT_FILE_NAME;
|
||||||
|
extern const int BAD_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITableFunctionFileLike::parseArguments(const ASTPtr & ast_function, const Context & context)
|
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 (args.size() == 2 && getName() == "file")
|
||||||
{
|
{
|
||||||
if (format != "Distributed")
|
if (format == "Distributed")
|
||||||
throw Exception("Table function '" + getName() + "' allows 2 arguments only for Distributed format.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
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).",
|
throw Exception("Table function '" + getName() + "' requires 3 or 4 arguments: filename, format, structure and compression method (default auto).",
|
||||||
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
|
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)
|
if (args.size() == 4)
|
||||||
compression_method = args[3]->as<ASTLiteral &>().value.safeGet<String>();
|
compression_method = args[3]->as<ASTLiteral &>().value.safeGet<String>();
|
||||||
|
Loading…
Reference in New Issue
Block a user