findly.unified-reporting-sdk 0.6.19__py3-none-any.whl → 0.6.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,6 +36,17 @@ def parse_where_columns_from_sql_query(
36
36
  )
37
37
  return None
38
38
 
39
+ # Check: Verify if the where_clause_str contains only 'where' with no conditions
40
+ if where_clause_str.strip().lower() == "where":
41
+ LOGGER.info(
42
+ {
43
+ "msg": "where_clause_contains_no_conditions",
44
+ "where_clause": where_clause_str,
45
+ "sql_query": sql_query,
46
+ }
47
+ )
48
+ return None
49
+
39
50
  try:
40
51
  where_clause_maybe: Optional[Expression] = parse_one(
41
52
  sql=sql_query,
@@ -68,7 +79,7 @@ def parse_where_columns_from_sql_query(
68
79
  pass
69
80
 
70
81
  column_operator_used_for_where_clause = condition.key
71
- if column_operator_used_for_where_clause == "in":
82
+ if column_operator_used_for_where_clause.lower() == "in":
72
83
  # expression list cause this is an IN operator, so we get back
73
84
  # an array, lets handle that by iterating over the expressions
74
85
  for expression in condition.expressions:
@@ -80,7 +91,7 @@ def parse_where_columns_from_sql_query(
80
91
  is_not_condition=not_condition,
81
92
  )
82
93
  )
83
- elif column_operator_used_for_where_clause == "between":
94
+ elif column_operator_used_for_where_clause.lower() == "between":
84
95
  where_clause_values.append(
85
96
  WhereClauseInformation(
86
97
  column_name=condition.args["this"].sql(),
@@ -89,6 +100,19 @@ def parse_where_columns_from_sql_query(
89
100
  is_not_condition=not_condition,
90
101
  )
91
102
  )
103
+ # Handle LIKE operator specifically
104
+ elif column_operator_used_for_where_clause.lower() == "like":
105
+ # Ensure correct handling of LIKE patterns, including special characters
106
+ column_name = condition.this.sql()
107
+ column_value = condition.expression.sql()
108
+ where_clause_values.append(
109
+ WhereClauseInformation(
110
+ column_name=column_name,
111
+ column_operator="like",
112
+ column_value=column_value,
113
+ is_not_condition=not_condition,
114
+ )
115
+ )
92
116
  else:
93
117
  # We fail on parsing things like:
94
118
  # CAST(A as B)
@@ -158,3 +182,12 @@ def parse_where_column_condition(
158
182
  dialect=dialect,
159
183
  where_clause_str=where_clause_str,
160
184
  )
185
+
186
+
187
+ # main method to test it
188
+ if __name__ == "__main__":
189
+ # ERROR:findly.unified_reporting_sdk.data_sources.common.where_string_comparison:{'msg': 'error_parse_where_column_condition', 'where_clause': "WHERE LOWER(cargo) LIKE LOWER('%crude%') AND WHERE LOWER(imo__ais_destination_formatted) LIKE LOWER(%rotterdam%) ", 'sql_query': "select * from table WHERE LOWER(cargo) LIKE LOWER('%crude%') AND WHERE LOWER(imo__ais_destination_formatted) LIKE LOWER(%rotterdam%) ", 'error': "Required keyword: 'expression' missing for <class 'sqlglot.expressions.And'>. Line 1, Col: 70.\n select * from table WHERE LOWER(cargo) LIKE LOWER('%crude%') AND \x1b[4mWHERE\x1b[0m LOWER(imo__ais_destination_formatted) LIKE LOWER(%rotterdam%) "}
190
+ # i want to test this case above
191
+ where_clause_str = "WHERE LOWER(cargo) LIKE LOWER('%crude%') AND WHERE LOWER(imo__ais_destination_formatted) LIKE LOWER(%rotterdam%) "
192
+ dialect = "bigquery"
193
+ print(parse_where_column_condition(where_clause_str, dialect))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: findly.unified-reporting-sdk
3
- Version: 0.6.19
3
+ Version: 0.6.21
4
4
  Summary:
5
5
  License: GPL-3.0-only
6
6
  Requires-Python: >=3.9,<4.0
@@ -5,7 +5,7 @@ findly/unified_reporting_sdk/data_sources/common/__init__.py,sha256=47DEQpj8HBSa
5
5
  findly/unified_reporting_sdk/data_sources/common/common_parser.py,sha256=OymaK3T9U10ZiIpMqwYQv3ukvCmBu9ALgxS5zQmKpLY,7897
6
6
  findly/unified_reporting_sdk/data_sources/common/date_range_helper.py,sha256=z2L1YU1Mzbybkl1wZK_mXL9lKFfG6CEomvlTfADD_80,971
7
7
  findly/unified_reporting_sdk/data_sources/common/reports_client.py,sha256=fCza94iwZz05QPr6B3mmsrvQQdymgD3CzMbvAYEOetw,3647
8
- findly/unified_reporting_sdk/data_sources/common/where_string_comparison.py,sha256=1oIVCZF-E09WfraAvjr0vQ7NDTnao-6QPxjKRf-QMCU,6039
8
+ findly/unified_reporting_sdk/data_sources/common/where_string_comparison.py,sha256=SUueYVxJrItDBwUJ04U5JlhebIbN_0eLuWsmrlO83Yw,8070
9
9
  findly/unified_reporting_sdk/data_sources/fb_ads/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  findly/unified_reporting_sdk/data_sources/fb_ads/fb_ads_client.py,sha256=hVrxsbf0DLoTka5B7DACBbcMeVEh4PRU_s8WZ8nlvFY,21913
11
11
  findly/unified_reporting_sdk/data_sources/fb_ads/fb_ads_query_args_parser.py,sha256=kM1ewN1bQqL_hTfbItkPGJenbwYeEpUXZEYnoTjTbDo,31949
@@ -28,7 +28,7 @@ findly/unified_reporting_sdk/protos/findly_semantic_layer_pb2.pyi,sha256=PmMDYAW
28
28
  findly/unified_reporting_sdk/urs.py,sha256=8um_pLJNOu1FGd0IO7XlNBIFAvGYD2nXnxiHMjkraKs,2915
29
29
  findly/unified_reporting_sdk/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  findly/unified_reporting_sdk/util/create_numeric_string_series.py,sha256=MmufpYatIhcVxA9e3H1dR1CrejXRnA8j4NNjJxfvBVA,457
31
- findly_unified_reporting_sdk-0.6.19.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
32
- findly_unified_reporting_sdk-0.6.19.dist-info/METADATA,sha256=rA_swUXPwV6dWr7xblMwPBGeu01V3_FI2iso9ekDhEc,3160
33
- findly_unified_reporting_sdk-0.6.19.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
34
- findly_unified_reporting_sdk-0.6.19.dist-info/RECORD,,
31
+ findly_unified_reporting_sdk-0.6.21.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
32
+ findly_unified_reporting_sdk-0.6.21.dist-info/METADATA,sha256=CLvuNbY41ZHgs9oUSZdXvOw25ChIt7NuYOWqy74m9yE,3160
33
+ findly_unified_reporting_sdk-0.6.21.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
34
+ findly_unified_reporting_sdk-0.6.21.dist-info/RECORD,,