1 | #include "duckdb/verification/parsed_statement_verifier.hpp" |
---|---|
2 | |
3 | #include "duckdb/parser/parser.hpp" |
4 | |
5 | namespace duckdb { |
6 | |
7 | ParsedStatementVerifier::ParsedStatementVerifier(unique_ptr<SQLStatement> statement_p) |
8 | : StatementVerifier(VerificationType::PARSED, "Parsed", std::move(statement_p)) { |
9 | } |
10 | |
11 | unique_ptr<StatementVerifier> ParsedStatementVerifier::Create(const SQLStatement &statement) { |
12 | auto query_str = statement.ToString(); |
13 | Parser parser; |
14 | try { |
15 | parser.ParseQuery(query: query_str); |
16 | } catch (std::exception &ex) { |
17 | throw InternalException("Parsed statement verification failed. Query:\n%s\n\nError: %s", query_str, ex.what()); |
18 | } |
19 | D_ASSERT(parser.statements.size() == 1); |
20 | D_ASSERT(parser.statements[0]->type == StatementType::SELECT_STATEMENT); |
21 | return make_uniq<ParsedStatementVerifier>(args: std::move(parser.statements[0])); |
22 | } |
23 | |
24 | } // namespace duckdb |
25 |