Polber commented on code in PR #29169:
URL: https://github.com/apache/beam/pull/29169#discussion_r1375060075


##########
sdks/python/apache_beam/yaml/yaml_mapping.py:
##########
@@ -75,28 +99,89 @@ def __setstate__(self, state):
     self.__dict__.update(state)
 
 
+def row_to_dict(row):
+  if (str(type(row).__name__).startswith('BeamSchema_') or
+      isinstance(row, Row)):
+    row = row._asdict()
+  if isinstance(row, dict):
+    for key, value in row.items():
+      row[key] = row_to_dict(value)
+  elif not isinstance(row, str) and isinstance(row, Iterable):
+    row_list = list(row)
+    for idx in range(len(row_list)):
+      row_list[idx] = row_to_dict(row_list[idx])
+  return row
+
+
 # TODO(yaml) Consider adding optional language version parameter to support
 #  ECMAScript 5 and 6
 def _expand_javascript_mapping_func(
     original_fields, expression=None, callable=None, path=None, name=None):
+
+  js_array_type = (
+      PyJsArray,
+      PyJsArrayBuffer,
+      PyJsInt8Array,
+      PyJsUint8Array,
+      PyJsUint8ClampedArray,
+      PyJsInt16Array,
+      PyJsUint16Array,
+      PyJsInt32Array,
+      PyJsUint32Array,
+      PyJsFloat32Array,
+      PyJsFloat64Array)
+
+  def _js_object_to_py_object(obj):
+    if isinstance(obj, (PyJsNumber, PyJsString, PyJsBoolean)):
+      obj = to_python(obj)

Review Comment:
   Done.



-- 
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