MCPcopy Create free account
hub / github.com/duckdb/duckdb / ParseSubquery

Function ParseSubquery

src/function/table/query_function.cpp:11–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace duckdb {
10
11static 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
34static string UnionTablesQuery(TableFunctionBindInput &input) {
35 for (auto &input_val : input.inputs) {

Callers 2

QueryBindReplaceFunction · 0.85
TableBindReplaceFunction · 0.85

Calls 3

ParserExceptionClass · 0.85
ParseQueryMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected