@@ -38,24 +38,8 @@ macro slice_min(sqlquery, column, n=1)
3838 # rank_clause = "RANK() OVER (ORDER BY " * $(string(column)) *" ASC) AS rank_col"
3939 partition_by_clause = ! isempty (sq. groupBy) && ! sq. is_aggregated ? " PARTITION BY " * sq. groupBy : " "
4040 # partition_by_clause = isempty(sq.groupBy) && !sq.is_aggregated ? "PARTITION BY " * most_recent_groupBy : ""
41- if isempty (sq. groupBy) && ! sq. is_aggregated
42- for cte in reverse (sq. ctes)
43- if ! isempty (cte. groupBy)
44- most_recent_groupBy = cte. groupBy
45- # println(most_recent_groupBy)
46- partition_by_clause = " PARTITION BY " * most_recent_groupBy
47-
48- break
49- # else
50- end
51- end
52- # partition_by_clause = "PARTITION BY " * most_recent_groupBy
53- else
54- nothing
55- end
56- if ! isempty (partition_by_clause)
57- sq. groupBy = " "
58- end
41+
42+ if ! isempty (partition_by_clause) sq. groupBy = " " ; end
5943
6044 # Update rank_clause to correctly order by column in ASCENDING order for slice_min
6145 rank_clause = " RANK() OVER (" * partition_by_clause * " ORDER BY " * $ (string (column)) * " ASC) AS rank_col"
@@ -124,24 +108,8 @@ macro slice_max(sqlquery, column, n=1)
124108 sq. cte_count += 1
125109 partition_by_clause = ! isempty (sq. groupBy) && ! sq. is_aggregated ? " PARTITION BY " * sq. groupBy : " "
126110 # partition_by_clause = isempty(sq.groupBy) && !sq.is_aggregated ? "PARTITION BY " * most_recent_groupBy : ""
127- if isempty (sq. groupBy) && ! sq. is_aggregated
128- for cte in reverse (sq. ctes)
129- if ! isempty (cte. groupBy)
130- most_recent_groupBy = cte. groupBy
131- # println(most_recent_groupBy)
132- partition_by_clause = " PARTITION BY " * most_recent_groupBy
133-
134- break
135- # else
136- end
137- end
138- # partition_by_clause = "PARTITION BY " * most_recent_groupBy
139- else
140- nothing
141- end
142- if ! isempty (partition_by_clause)
143- sq. groupBy = " "
144- end
111+
112+ if ! isempty (partition_by_clause) sq. groupBy = " " ; end
145113
146114 # Update rank_clause to correctly order by column in ASCENDING order for slice_min
147115 rank_clause = " RANK() OVER (" * partition_by_clause * " ORDER BY " * $ (string (column)) * " DESC) AS rank_col"
0 commit comments