@@ -1153,15 +1153,13 @@ def test_generic_metric_filtering_without_chart_flag(login_as_admin):
11531153 database = database ,
11541154 )
11551155
1156- # Add column
11571156 col = TableColumn (
11581157 column_name = "name" ,
11591158 type = "VARCHAR(255)" ,
11601159 table = table ,
11611160 )
11621161 table .columns = [col ]
11631162
1164- # Add metric
11651163 metric = SqlMetric (
11661164 metric_name = "count" ,
11671165 expression = "COUNT(*)" ,
@@ -1173,7 +1171,6 @@ def test_generic_metric_filtering_without_chart_flag(login_as_admin):
11731171 db .session .commit ()
11741172
11751173 try :
1176- # Query with metric filter and NO is_ag_grid_chart flag
11771174 query_obj = {
11781175 "granularity" : None ,
11791176 "from_dttm" : None ,
@@ -1182,22 +1179,20 @@ def test_generic_metric_filtering_without_chart_flag(login_as_admin):
11821179 "metrics" : ["count" ],
11831180 "filter" : [
11841181 {
1185- "col" : "count" , # Filter on metric
1182+ "col" : "count" ,
11861183 "op" : ">" ,
11871184 "val" : 0 ,
11881185 }
11891186 ],
11901187 "is_timeseries" : False ,
1191- "extras" : {}, # No chart-specific flags
1188+ "extras" : {},
11921189 }
11931190
1194- # This should not raise an error
11951191 sqla_query = table .get_sqla_query (** query_obj )
11961192 sql = str (
11971193 sqla_query .sqla_query .compile (compile_kwargs = {"literal_binds" : True })
11981194 ).lower ()
11991195
1200- # Verify HAVING clause is used
12011196 assert "having" in sql , "Metric filter should use HAVING clause. SQL: " + sql
12021197 finally :
12031198 db .session .delete (table )
@@ -1221,12 +1216,10 @@ def test_column_ordering_without_chart_flag(login_as_admin):
12211216 database = database ,
12221217 )
12231218
1224- # Add columns
12251219 col_a = TableColumn (column_name = "col_a" , type = "VARCHAR(255)" , table = table )
12261220 col_b = TableColumn (column_name = "col_b" , type = "VARCHAR(255)" , table = table )
12271221 table .columns = [col_a , col_b ]
12281222
1229- # Add metrics
12301223 metric_x = SqlMetric (metric_name = "metric_x" , expression = "COUNT(*)" , table = table )
12311224 metric_y = SqlMetric (metric_name = "metric_y" , expression = "SUM(val)" , table = table )
12321225 table .metrics = [metric_x , metric_y ]
@@ -1235,7 +1228,6 @@ def test_column_ordering_without_chart_flag(login_as_admin):
12351228 db .session .commit ()
12361229
12371230 try :
1238- # Mock the database response with columns in one order
12391231 mock_df = pd .DataFrame (
12401232 {
12411233 "col_a" : [1 , 2 ],
@@ -1261,15 +1253,11 @@ def mock_get_df(sql, catalog=None, schema=None, mutator=None):
12611253 "metrics" : ["metric_x" , "metric_y" ],
12621254 "filter" : [],
12631255 "is_timeseries" : False ,
1264- "extras" : {
1265- # Specify custom column order (no chart-specific flags)
1266- "column_order" : ["metric_y" , "col_b" , "metric_x" , "col_a" ]
1267- },
1256+ "extras" : {"column_order" : ["metric_y" , "col_b" , "metric_x" , "col_a" ]},
12681257 }
12691258
12701259 result = table .query (query_obj )
12711260
1272- # Verify columns are reordered
12731261 expected_order = ["metric_y" , "col_b" , "metric_x" , "col_a" ]
12741262 assert list (result .df .columns ) == expected_order , (
12751263 f"Expected { expected_order } , got { list (result .df .columns )} "
0 commit comments