You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// weight column exists - use SUM (but still call it "count")
172
-
format!("SUM({}) AS {}", weight_col, stat_count)
172
+
format!("SUM({}) AS \"{}\"", weight_col, stat_count)
173
173
}else{
174
174
// weight mapped but column doesn't exist - fall back to COUNT
175
175
// (this shouldn't happen with upfront validation, but handle gracefully)
176
-
format!("COUNT(*) AS {}", stat_count)
176
+
format!("COUNT(*) AS \"{}\"", stat_count)
177
177
}
178
178
}else{
179
179
// Shouldn't happen (not literal, not column), fall back to COUNT
180
-
format!("COUNT(*) AS {}", stat_count)
180
+
format!("COUNT(*) AS \"{}\"", stat_count)
181
181
}
182
182
}else{
183
183
// weight not mapped - use COUNT
184
-
format!("COUNT(*) AS {}", stat_count)
184
+
format!("COUNT(*) AS \"{}\"", stat_count)
185
185
};
186
186
187
187
// Build the query based on whether x is mapped or not
@@ -191,13 +191,13 @@ fn stat_bar_count(
191
191
let(grouped_select, final_select) = if group_by.is_empty(){
192
192
(
193
193
format!(
194
-
"'{dummy}' AS {x}, {agg}",
194
+
"'{dummy}' AS \"{x}\", {agg}",
195
195
dummy = stat_dummy_value,
196
196
x = stat_x,
197
197
agg = agg_expr
198
198
),
199
199
format!(
200
-
"*, {count} * 1.0 / SUM({count}) OVER () AS {prop}",
200
+
"*, \"{count}\" * 1.0 / SUM(\"{count}\") OVER () AS \"{prop}\"",
201
201
count = stat_count,
202
202
prop = stat_proportion
203
203
),
@@ -206,14 +206,14 @@ fn stat_bar_count(
206
206
let grp_cols = group_by.join(", ");
207
207
(
208
208
format!(
209
-
"{g}, '{dummy}' AS {x}, {agg}",
209
+
"{g}, '{dummy}' AS \"{x}\", {agg}",
210
210
g = grp_cols,
211
211
dummy = stat_dummy_value,
212
212
x = stat_x,
213
213
agg = agg_expr
214
214
),
215
215
format!(
216
-
"*, {count} * 1.0 / SUM({count}) OVER (PARTITION BY {grp}) AS {prop}",
216
+
"*, \"{count}\" * 1.0 / SUM(\"{count}\") OVER (PARTITION BY {grp}) AS \"{prop}\"",
217
217
count = stat_count,
218
218
grp = grp_cols,
219
219
prop = stat_proportion
@@ -224,7 +224,7 @@ fn stat_bar_count(
224
224
let query_str = if group_by.is_empty(){
225
225
// No grouping at all - single aggregate
226
226
format!(
227
-
"WITH __stat_src__ AS ({query}), __grouped__ AS (SELECT {grouped} FROM __stat_src__) SELECT {final} FROM __grouped__",
227
+
"WITH \"__stat_src__\" AS ({query}), \"__grouped__\" AS (SELECT {grouped} FROM \"__stat_src__\") SELECT {final} FROM \"__grouped__\"",
228
228
query = query,
229
229
grouped = grouped_select,
230
230
final = final_select
@@ -233,7 +233,7 @@ fn stat_bar_count(
233
233
// Group by partition/facet variables only
234
234
let group_cols = group_by.join(", ");
235
235
format!(
236
-
"WITH __stat_src__ AS ({query}), __grouped__ AS (SELECT {grouped} FROM __stat_src__ GROUP BY {group}) SELECT {final} FROM __grouped__",
236
+
"WITH \"__stat_src__\" AS ({query}), \"__grouped__\" AS (SELECT {grouped} FROM \"__stat_src__\" GROUP BY {group}) SELECT {final} FROM \"__grouped__\"",
237
237
query = query,
238
238
grouped = grouped_select,
239
239
group = group_cols,
@@ -271,7 +271,7 @@ fn stat_bar_count(
271
271
(
272
272
format!("{x}, {agg}", x = x_col, agg = agg_expr),
273
273
format!(
274
-
"*, {count} * 1.0 / SUM({count}) OVER () AS {prop}",
274
+
"*, \"{count}\" * 1.0 / SUM(\"{count}\") OVER () AS \"{prop}\"",
275
275
count = stat_count,
276
276
prop = stat_proportion
277
277
),
@@ -281,7 +281,7 @@ fn stat_bar_count(
281
281
(
282
282
format!("{g}, {x}, {agg}", g = grp_cols, x = x_col, agg = agg_expr),
283
283
format!(
284
-
"*, {count} * 1.0 / SUM({count}) OVER (PARTITION BY {grp}) AS {prop}",
284
+
"*, \"{count}\" * 1.0 / SUM(\"{count}\") OVER (PARTITION BY {grp}) AS \"{prop}\"",
285
285
count = stat_count,
286
286
grp = grp_cols,
287
287
prop = stat_proportion
@@ -290,7 +290,7 @@ fn stat_bar_count(
290
290
};
291
291
292
292
let query_str = format!(
293
-
"WITH __stat_src__ AS ({query}), __grouped__ AS (SELECT {grouped} FROM __stat_src__ GROUP BY {group}) SELECT {final} FROM __grouped__",
293
+
"WITH \"__stat_src__\" AS ({query}), \"__grouped__\" AS (SELECT {grouped} FROM \"__stat_src__\" GROUP BY {group}) SELECT {final} FROM \"__grouped__\"",
0 commit comments