@@ -17,32 +17,79 @@ function translate_dispatch(::typeof(QueryOperators.filter), iterator, call, cal
1717end
1818
1919@code_instead QueryOperators. groupby SourceCode Any Expr Any Expr
20+ <<<<<< < HEAD
2021function translate_dispatch (:: typeof (QueryOperators. groupby), ungrouped, group_function, group_function_expression, map_selector, map_function_expression; options... )
2122 SQLExpression (Symbol (" GROUP BY" ),
2223 translate (ungrouped; options... ),
2324 translate (group_function (model_row (ungrouped)). code; options... )
25+ ====== =
26+
27+ struct GroupOfRows{Group, Row}
28+ group:: Group
29+ row:: Row
30+ end
31+
32+ function key (group_of_rows:: GroupOfRows )
33+ translate (getfield (group_of_rows, :group ))
34+ end
35+
36+ function getproperty (group_of_rows:: GroupOfRows , column_name:: Symbol )
37+ getproperty (getfield (group_of_rows, :row ), column_name)
38+ end
39+
40+ function length (group_of_rows:: GroupOfRows )
41+ length (first (getfield (group_of_rows, :row )))
42+ end
43+
44+ function model_row_dispatch (:: typeof (QueryOperators. groupby), ungrouped, group_function, group_function_expression, map_selector, map_function_expression; options... )
45+ model = model_row (ungrouped; options... )
46+ GroupOfRows (group_function (model), model)
47+ end
48+
49+ function translate_dispatch (:: typeof (QueryOperators. groupby), ungrouped, group_function, group_function_expression, map_selector, map_function_expression; options... )
50+ # TODO : map_selector
51+ model = model_row (ungrouped; options... )
52+ SQLExpression (Symbol (" GROUP BY" ),
53+ translate (ungrouped; options... ),
54+ translate (group_function (model). code; options... )
55+ >>>>>> > 60e2521
2456 )
2557end
2658
2759@code_instead QueryOperators. join SourceCode SourceCode Any Expr Any Expr Any Expr
2860function translate_dispatch (:: typeof (QueryOperators. join), source1, source2, key1, key1_expression, key2, key2_expression, combine, combine_expression; options... )
29- model_row_1 = model_row (source1; other = true )
30- model_row_2 = model_row (source2; other = true )
31- SQLExpression (:ON ,
32- SQLExpression (Symbol ( " INNER JOIN " ) ,
33- SQLExpression (:SELECT ,
61+ model_row_1 = model_row (source1; other = true , options ... )
62+ model_row_2 = model_row (source2; other = true , options ... )
63+ SQLExpression (:SELECT ,
64+ SQLExpression (:ON ,
65+ SQLExpression (Symbol ( " INNER JOIN " ) ,
3466 translate (source1; options... ),
35- Generator (
36- pair -> as (pair; options... ),
37- pairs (combine (model_row_1, model_row_2))
38- )...
67+ translate (source2; other = true , options... )
3968 ),
40- translate (source2; other = true , options... )
69+ SQLExpression (:(= ),
70+ translate (key1 (model_row_1). code; options... ),
71+ translate (key2 (model_row_2). code; other = true , options... )
72+ )
4173 ),
42- SQLExpression (:(= ),
43- translate (key1 (model_row_1). code; options... ),
44- translate (key2 (model_row_2). code; other = true , options... )
45- )
74+ Generator (
75+ pair -> as (pair; options... ),
76+ pairs (combine (model_row_1, model_row_2))
77+ )...
78+ )
79+ end
80+
81+ @code_instead QueryOperators. map SourceCode Any Expr
82+ function model_row_dispatch (:: typeof (QueryOperators. map), iterator, call, call_expression; options... )
83+ call (model_row (iterator; options... ))
84+ end
85+
86+ function translate_dispatch (:: typeof (QueryOperators. map), select_table, call, call_expression; options... )
87+ SQLExpression (
88+ Symbol (" SELECT" ), translate (select_table; options... ),
89+ Generator (
90+ pair -> as (pair; options... ),
91+ pairs (call (model_row (select_table; options... )))
92+ )...
4693 )
4794end
4895
@@ -80,21 +127,6 @@ function translate_dispatch(::typeof(QueryOperators.thenby_descending), unordere
80127 )
81128end
82129
83- @code_instead QueryOperators. map SourceCode Any Expr
84- function model_row_dispatch (:: typeof (QueryOperators. map), iterator, call, call_expression; options... )
85- call (model_row (iterator; options... ))
86- end
87-
88- function translate_dispatch (:: typeof (QueryOperators. map), select_table, call, call_expression; options... )
89- SQLExpression (
90- Symbol (" SELECT" ), translate (select_table; options... ),
91- Generator (
92- pair -> as (pair; options... ),
93- pairs (call (model_row (select_table; options... )))
94- )...
95- )
96- end
97-
98130@code_instead QueryOperators. take SourceCode Any
99131@translate_default :: typeof (QueryOperators. take) :LIMIT
100132
0 commit comments