gluesql_core/query_builder/
source.rs1use {
2 super::{ExprNode, QueryNode, SelectNode, TableAccessNode},
3 crate::ast::Dictionary,
4};
5
6#[derive(Clone, Debug)]
7pub enum SourceNode<'a> {
8 Table {
9 name: String,
10 alias: Option<String>,
11 access: TableAccessNode<'a>,
12 },
13 Series {
14 size: ExprNode<'a>,
15 alias: String,
16 },
17 Dictionary {
18 dictionary: Dictionary,
19 alias: String,
20 },
21 Derived {
22 query: Box<QueryNode<'a>>,
23 alias: String,
24 },
25}
26
27impl<'a> SourceNode<'a> {
28 pub fn select(self) -> SelectNode<'a> {
29 SelectNode::new(self)
30 }
31}
32
33pub fn glue_objects() -> SourceNode<'static> {
34 SourceNode::Dictionary {
35 dictionary: Dictionary::GlueObjects,
36 alias: "GLUE_OBJECTS".to_owned(),
37 }
38}
39
40pub fn glue_tables() -> SourceNode<'static> {
41 SourceNode::Dictionary {
42 dictionary: Dictionary::GlueTables,
43 alias: "GLUE_TABLES".to_owned(),
44 }
45}
46
47pub fn glue_indexes() -> SourceNode<'static> {
48 SourceNode::Dictionary {
49 dictionary: Dictionary::GlueIndexes,
50 alias: "GLUE_INDEXES".to_owned(),
51 }
52}
53
54pub fn glue_table_columns() -> SourceNode<'static> {
55 SourceNode::Dictionary {
56 dictionary: Dictionary::GlueTableColumns,
57 alias: "GLUE_TABLE_COLUMNS".to_owned(),
58 }
59}
60
61pub fn series<'a, T: Into<ExprNode<'a>>>(args: T) -> SourceNode<'a> {
62 SourceNode::Series {
63 size: args.into(),
64 alias: "SERIES".to_owned(),
65 }
66}