From af867147c4f12832c01b6d66dccb308f805f1d45 Mon Sep 17 00:00:00 2001 From: parkervg Date: Tue, 30 Jul 2024 12:54:38 -0400 Subject: [PATCH] fix num_ingredients_in_join > 1 post-process logic --- blendsql/blend.py | 8 ++++---- blendsql/ingredients/utils.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blendsql/blend.py b/blendsql/blend.py index 646c561b..7acf02a9 100644 --- a/blendsql/blend.py +++ b/blendsql/blend.py @@ -758,14 +758,14 @@ def _blend( # Since we haven't executed and saved `{{B()}}` to temp table yet, # we need to keep. So we get: temp_uuid = str(uuid.uuid4()) - query_context.node = query_context.node.transform( + _node = query_context.node.transform( transform.replace_join_with_ingredient_multiple_ingredient, ingredient_name=parsed_results_dict["ingredient_aliasname"], ingredient_alias=alias_function_str, temp_uuid=temp_uuid, - ).transform(prune_true_where) - query_context.node = query_context.parse( - query_context.to_string().replace(f'SELECT "{temp_uuid}", ', "") + ).transform(transform.prune_true_where) + query_context.parse( + str(_node).replace(f'SELECT "{temp_uuid}", ', ""), schema=schema ) else: # Case where we have diff --git a/blendsql/ingredients/utils.py b/blendsql/ingredients/utils.py index d641093d..7bdcdb9e 100644 --- a/blendsql/ingredients/utils.py +++ b/blendsql/ingredients/utils.py @@ -14,11 +14,11 @@ def unpack_options( tablename = aliases_to_tablenames.get(tablename, tablename) # Optionally materialize a CTE if tablename in db.lazy_tables: - unpacked_options = ( + unpacked_options: list = ( db.lazy_tables.pop(tablename).collect()[colname].unique().tolist() ) else: - unpacked_options = db.execute_to_list( + unpacked_options: list = db.execute_to_list( f'SELECT DISTINCT "{colname}" FROM "{tablename}"' ) except ValueError: