Joffreybvn commented on code in PR #36205:
URL: https://github.com/apache/airflow/pull/36205#discussion_r1428247519


##########
airflow/providers/databricks/hooks/databricks_sql.py:
##########
@@ -241,13 +258,17 @@ def run(
         else:
             return results
 
-    @staticmethod
-    def _make_serializable(result):
-        """Transform the databricks Row objects into JSON-serializable 
lists."""
-        if isinstance(result, list):
-            return [list(row) for row in result]
-        elif isinstance(result, Row):
-            return list(result)
+    def _make_serializable(self, result):
+        """Transform the databricks Row objects into serializable 
namedtuple."""
+        if self.return_serializable:
+            columns: list[str] | None = None
+            if isinstance(result, list):
+                columns = result[0].__fields__
+                row_object = namedtuple("Row", columns)
+                return [row_object(*row) for row in result]
+            elif isinstance(result, Row):
+                columns = result.__fields__
+                return namedtuple("Row", columns)(*result)
         return result

Review Comment:
   The same could be applied to the ODBCHook



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to