Skip to content

Commit c3b899b

Browse files
committed
WIP: start parsing select statements
1 parent 8935fc0 commit c3b899b

File tree

6 files changed

+360
-15
lines changed

6 files changed

+360
-15
lines changed

lib/plume/ast/result_column.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
module Plume
44
class ResultColumn < Node
5-
prop :result, Expression
6-
prop :alias, _Nilable(String)
5+
token :as_kw
6+
token :alias_tk
7+
8+
node :result, Expression
9+
attr :alias, Stringy
10+
11+
def self.new(*, result:, **) = super
12+
def self.concrete(*, result:, **) = super
13+
14+
def alias = (@alias == LiteralNil) ? alias_tk_val : @alias
715
end
816
end

lib/plume/ast/select_statement.rb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@ module Plume
88
#
99
# ```
1010
class SelectStatement < Node
11-
prop :type, _Void
12-
prop :columns, _Void
13-
prop :from, _Void
14-
prop :where, _Void
15-
prop :group_by, _Void
16-
prop :having, _Void
17-
prop :window, _Void
18-
prop :compound, _Void
19-
prop :order_by, _Void
20-
prop :limit, _Void
21-
prop :offset, _Void
11+
token :select_kw
12+
token :type_tk
13+
token :from_kw
14+
token :where_kw
15+
token :group_by_kw
16+
token :having_kw
17+
token :window_kw
18+
19+
nodes :columns, _Any
20+
node :source, _Any
21+
node :condition, _Any
22+
nodes :groupings, _Any
23+
node :having, _Any
24+
nodes :windows, _Any
25+
26+
def self.new(*, **) = super
27+
def self.concrete(*, **) = super
2228
end
2329
end

lib/plume/ast/star_result_column.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
module Plume
44
class StarResultColumn < Node
5-
prop :table_name, _Nilable(String)
5+
token :table_tk
6+
token :dot_tk
7+
token :star_tk
8+
9+
attr :table, Stringy
10+
11+
def self.new(*, **) = super
12+
def self.concrete(*, star_tk:, **) = super
13+
14+
def table = (@table == LiteralNil) ? table_tk_val : @table
615
end
716
end

lib/plume/ast/table_name.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ class TableName < Node
55
token :schema_tk
66
token :dot_tk
77
token :table_tk
8+
token :as_kw
9+
token :alias_tk
810

911
attr :schema, Stringy
1012
attr :table, Stringy
13+
attr :alias, Stringy
1114

1215
def self.new(*, table:, **) = super
1316
def self.concrete(*, table_tk:, **) = super
1417

1518
def schema = (@schema == LiteralNil) ? schema_tk_val : @schema
1619
def table = (@table == LiteralNil) ? table_tk_val : @table
20+
def alias = (@alias == LiteralNil) ? alias_tk_val : @alias
1721

1822
alias_method :name, :table
1923
end

0 commit comments

Comments
 (0)