@@ -224,8 +224,25 @@ def _generate_code_for_recipe(self, recipe, entrypoint_name):
224224 rp = raw ["params" ]["engineParams" ].get ("spark" , {}).get ("readParams" , {})
225225 if rp .get ("mode" , "?" ) == "AUTO" :
226226 rp ["map" ] = {}
227-
228-
227+
228+ def cleanup_grouping ():
229+ for grouping_key in settings .obj_payload .get ("keys" , []):
230+ for item in ["count" , "last" , "min" , "max" , "sum" , "countDistinct" , "stddev" , "avg" , "concat" , "first" ]:
231+ if item in grouping_key and grouping_key [item ] == False :
232+ del grouping_key [item ]
233+ for aggregation in settings .obj_payload .get ("values" , []):
234+ for item in ["count" , "last" , "min" , "max" , "sum" , "countDistinct" , "stddev" , "avg" , "concat" , "first" ,
235+ "concatDistinct" , "$idx" , "sum2" , "firstLastNotNull" ]:
236+ if item in aggregation and aggregation .get (item , None ) == False :
237+ del aggregation [item ]
238+
239+ cleanup_by_type = {
240+ "grouping" : cleanup_grouping
241+ }
242+
243+ if settings .type in cleanup_by_type :
244+ cleanup_by_type [settings .type ]()
245+
229246 if isinstance (settings , CodeRecipeSettings ):
230247 code = settings .get_code ()
231248 self .gen (" # Recipe code" )
0 commit comments