| 9 | namespace duckdb { |
| 10 | |
| 11 | static unique_ptr<SubqueryRef> ParseSubquery(const string &query, const ParserOptions &options, const string &err_msg) { |
| 12 | Parser parser(options); |
| 13 | parser.ParseQuery(query); |
| 14 | if (parser.statements.size() != 1) { |
| 15 | throw ParserException(err_msg); |
| 16 | } |
| 17 | |
| 18 | auto &stmt = parser.statements[0]; |
| 19 | |
| 20 | if (stmt->type == StatementType::SELECT_STATEMENT) { |
| 21 | // Regular SELECT statement |
| 22 | auto select_stmt = unique_ptr_cast<SQLStatement, SelectStatement>(std::move(stmt)); |
| 23 | return duckdb::make_uniq<SubqueryRef>(std::move(select_stmt)); |
| 24 | } else if (stmt->type == StatementType::MULTI_STATEMENT) { |
| 25 | // MultiStatement (e.g., from PIVOT statements that create enum types) |
| 26 | throw ParserException( |
| 27 | "PIVOT statements without explicit IN clauses are not supported in query() function. " |
| 28 | "Please specify the pivot values explicitly, e.g.: PIVOT ... ON col IN (val1, val2, ...)"); |
| 29 | } else { |
| 30 | throw ParserException(err_msg); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | static string UnionTablesQuery(TableFunctionBindInput &input) { |
| 35 | for (auto &input_val : input.inputs) { |
no test coverage detected