-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathparse_tables.hpp
More file actions
39 lines (31 loc) · 1.08 KB
/
parse_tables.hpp
File metadata and controls
39 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include "duckdb.hpp"
namespace duckdb {
/**
* Represents where a table is used in a query.
*/
enum class TableContext {
From, // table in from clause
JoinLeft, // table in left side of a join
JoinRight, // table in right side of a join
FromCTE, // table in from clause that references a CTE
CTE, // table is defined as a CTE
Subquery // table in a subquery
};
const char *ToString(TableContext context);
const TableContext FromString(const char *context);
struct TableRefResult {
std::string schema;
std::string table;
TableContext context;
};
static void ExtractTablesFromSQL(const std::string &sql, std::vector<TableRefResult> &results);
static void ExtractTablesFromQueryNode(
const duckdb::QueryNode &node,
std::vector<TableRefResult> &results,
const TableContext context = TableContext::From,
const duckdb::CommonTableExpressionMap *cte_map = nullptr
);
void RegisterParseTablesFunction(duckdb::ExtensionLoader &loader);
void RegisterParseTableScalarFunction(ExtensionLoader &loader);
} // namespace duckdb