You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by GitBox <gi...@apache.org> on 2022/09/24 16:07:56 UTC

[GitHub] [incubator-sedona] Imbruced commented on a diff in pull request #693: [SEDONA-166] Support type-safe dataframe style API

Imbruced commented on code in PR #693:
URL: https://github.com/apache/incubator-sedona/pull/693#discussion_r979267953


##########
python/sedona/sql/dataframe_api.py:
##########
@@ -0,0 +1,35 @@
+from typing import Any, Tuple, Union, Iterable
+from pyspark.sql import SparkSession, Column, functions as f
+
+
+ColumnOrName = Union[Column, str]
+ColumnOrNameOrNumber = Union[Column, str, float, int]
+
+
+def _convert_argument_to_java_column(arg: Any) -> Column:
+    if isinstance(arg, Column):
+        return arg._jc
+    elif isinstance(arg, str):
+        return f.col(arg)._jc
+    elif isinstance(arg, Iterable):
+        return f.array(*[Column(x) for x in map(_convert_argument_to_java_column, arg)])._jc

Review Comment:
   Whats the advantage of using map and list comprehension in one place instead of applying two functions using list comprehension ? 



-- 
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: dev-unsubscribe@sedona.apache.org

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