From 1a2694ac605db15901f2e105edab276fa4c39eb0 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Fri, 15 Sep 2023 14:59:15 +0530 Subject: [PATCH] fix: skip invalid joins while building query --- insights/insights/query_builders/sql_builder.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/insights/insights/query_builders/sql_builder.py b/insights/insights/query_builders/sql_builder.py index 42225315b..8517a7dd0 100644 --- a/insights/insights/query_builders/sql_builder.py +++ b/insights/insights/query_builders/sql_builder.py @@ -538,17 +538,20 @@ def process_tables_and_joins(self): continue _join = parse_json(row.join) - join_type = _join.get("type").get("value") + join_type = _join.get("type", {}).get("value") left_table = self.make_table(row.table) - right_table = self.make_table(_join.get("with").get("value")) + right_table = self.make_table(_join.get("with", {}).get("value")) condition = _join.get("condition") - left_key = condition.get("left").get("value") - right_key = condition.get("right").get("value") + left_key = condition.get("left", {}).get("value") + right_key = condition.get("right", {}).get("value") left_key = self.make_column(left_key, row.table) - right_key = self.make_column(right_key, _join.get("with").get("value")) + right_key = self.make_column(right_key, _join.get("with", {}).get("value")) + + if not left_key or not right_key: + continue self._joins.append( _dict(