You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/03 09:58:45 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #25394: Do not convert boolean values to string in deep_string_coerce function

uranusjr commented on code in PR #25394:
URL: https://github.com/apache/airflow/pull/25394#discussion_r936474033


##########
airflow/providers/databricks/utils/databricks.py:
##########
@@ -23,16 +23,25 @@
 from airflow.providers.databricks.hooks.databricks import RunState
 
 
-def deep_string_coerce(content, json_path: str = 'json') -> Union[str, list, dict]:
+def normalise_json_content(content, json_path: str = 'json') -> Union[str, bool, list, dict]:
     """
-    Coerces content or all values of content if it is a dict to a string. The
-    function will throw if content contains non-string or non-numeric types.
+    Normalises content or all values of content if it is a dict to a string. The
+    function will throw if content contains non-string or non-numeric non-boolean types.
     The reason why we have this function is because the ``self.json`` field must be a
     dict with only string values. This is because ``render_template`` will fail
     for numerical values.
+
+    The only one exception is when we have boolean values, they can not be converted
+    to string type because databricks does not understand 'True' or 'False' values.
     """
-    coerce = deep_string_coerce
-    if isinstance(content, str):
+    normalise = normalise_json_content
+    if isinstance(
+        content,
+        (
+            str,
+            bool,
+        ),
+    ):

Review Comment:
   ```suggestion
       if isinstance(content, (str, bool)):
   ```
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org