| 69 | } |
| 70 | |
| 71 | void TableFunctionViewIfPermitted::parseArguments(const ASTPtr & ast_function, ContextPtr context) |
| 72 | { |
| 73 | const auto * function = ast_function->as<ASTFunction>(); |
| 74 | if (!function || !function->arguments || (function->arguments->children.size() != 2)) |
| 75 | throw Exception( |
| 76 | ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, |
| 77 | "Table function '{}' requires two arguments: a SELECT query and a table function", |
| 78 | getName()); |
| 79 | |
| 80 | const auto & arguments = function->arguments->children; |
| 81 | auto * select = arguments[0]->as<ASTSelectWithUnionQuery>(); |
| 82 | if (!select) |
| 83 | throw Exception(ErrorCodes::BAD_ARGUMENTS, "Table function '{}' requires a SELECT query as its first argument", getName()); |
| 84 | create.set(create.select, select->clone()); |
| 85 | |
| 86 | else_ast = arguments[1]; |
| 87 | if (!else_ast->as<ASTFunction>()) |
| 88 | throw Exception(ErrorCodes::BAD_ARGUMENTS, "Table function '{}' requires a table function as its second argument", getName()); |
| 89 | else_table_function = TableFunctionFactory::instance().get(else_ast, context); |
| 90 | } |
| 91 | |
| 92 | ColumnsDescription TableFunctionViewIfPermitted::getActualTableStructure(ContextPtr context, bool is_insert_query) const |
| 93 | { |