Suppport Zero-argument variants for table functions zeros, zeros_mt

This commit is contained in:
YenchangChan 2024-03-27 15:08:11 +08:00
parent 1ae8a9fc6f
commit a00ec8e6ed

View File

@ -55,15 +55,24 @@ StoragePtr TableFunctionZeros<multithreaded>::executeImpl(const ASTPtr & ast_fun
{
auto arguments = function->arguments->children;
if (arguments.size() != 1)
if (arguments.size() >= 2)
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Table function '{}' requires 'length'.", getName());
if (arguments.size() == 1)
{
UInt64 length = evaluateArgument(context, arguments[0]);
UInt64 length = evaluateArgument(context, arguments[0]);
auto res = std::make_shared<StorageSystemZeros>(StorageID(getDatabaseName(), table_name), multithreaded, length);
res->startup();
return res;
auto res = std::make_shared<StorageSystemZeros>(StorageID(getDatabaseName(), table_name), multithreaded, length);
res->startup();
return res;
}
else
{
/// zero-argument, the same as system.zeros
auto res = std::make_shared<StorageSystemZeros>(StorageID(getDatabaseName(), table_name), multithreaded);
res->startup();
return res;
}
}
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Table function '{}' requires 'limit'.", getName());
}