diff --git a/generator/views/funnel_analysis_view.py b/generator/views/funnel_analysis_view.py index f7d6302..e206924 100644 --- a/generator/views/funnel_analysis_view.py +++ b/generator/views/funnel_analysis_view.py @@ -157,13 +157,17 @@ class FunnelAnalysisView(View): "sql": ( "SELECT " "mozfun.event_analysis.aggregate_match_strings( " - "ARRAY_AGG( " - "mozfun.event_analysis.event_index_to_match_string(index))) AS match_string " + "ARRAY_AGG( CONCAT(mozfun.event_analysis.escape_metachars(property_value.value)," + "mozfun.event_analysis.event_index_to_match_string(et.index)))) AS match_string " "FROM " - f"{self.tables[0]['event_types']} " + f"{self.tables[0]['event_types']} as et " + "CROSS JOIN UNNEST(event_properties) AS properties " + "CROSS JOIN UNNEST(properties.value) AS property_value " "WHERE " "{% condition category %} category {% endcondition %} " - "AND {% condition event %} event {% endcondition %}" + "AND {% condition event %} event {% endcondition %} " + "AND {% condition property_name %} properties.key {% endcondition %} " + "AND {% condition property_value %} property_value.key {% endcondition %}" ) }, "filters": [ @@ -221,6 +225,7 @@ class FunnelAnalysisView(View): " event, " " property.key AS property_name, " " property_value.key AS property_value, " + " property_value.index as property_index " f"FROM {self.tables[0]['event_types']} " "LEFT JOIN UNNEST(event_properties) AS property " "LEFT JOIN UNNEST(property.value) AS property_value " diff --git a/tests/test_funnel_analysis.py b/tests/test_funnel_analysis.py index 66ff5d4..2b298c2 100644 --- a/tests/test_funnel_analysis.py +++ b/tests/test_funnel_analysis.py @@ -165,13 +165,17 @@ def test_view_lookml(funnel_analysis_view): "sql": ( "SELECT " "mozfun.event_analysis.aggregate_match_strings( " - "ARRAY_AGG( " - "mozfun.event_analysis.event_index_to_match_string(index))) AS match_string " + "ARRAY_AGG( CONCAT(mozfun.event_analysis.escape_metachars(property_value.value)," + "mozfun.event_analysis.event_index_to_match_string(et.index)))) AS match_string " "FROM " - "`mozdata.glean_app.event_types` " + "`mozdata.glean_app.event_types` as et " + "CROSS JOIN UNNEST(event_properties) AS properties " + "CROSS JOIN UNNEST(properties.value) AS property_value " "WHERE " "{% condition category %} category {% endcondition %} " - "AND {% condition event %} event {% endcondition %}" + "AND {% condition event %} event {% endcondition %} " + "AND {% condition property_name %} properties.key {% endcondition %} " + "AND {% condition property_value %} property_value.key {% endcondition %}" ) }, "filters": [ @@ -228,6 +232,7 @@ def test_view_lookml(funnel_analysis_view): " event, " " property.key AS property_name, " " property_value.key AS property_value, " + " property_value.index as property_index " "FROM `mozdata.glean_app.event_types` " "LEFT JOIN UNNEST(event_properties) AS property " "LEFT JOIN UNNEST(property.value) AS property_value "