You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/15 11:41:21 UTC

[GitHub] [spark] dcoliversun opened a new pull request, #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

dcoliversun opened a new pull request, #37521:
URL: https://github.com/apache/spark/pull/37521

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR proposes to add parameters/returns and improve the examples in `pyspark.sql.column` by making each example self-contained with a brief explanation and a bit more realistic example.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   To make the documentation more readable and able to copy and paste directly in PySpark shell.
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes, it changes the documentation.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Manually ran each doctest.


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1225003808

   Merged to master.


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r950000222


##########
python/pyspark/sql/column.py:
##########
@@ -495,6 +544,17 @@ def dropFields(self, *fieldNames: str) -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldNames : str or list
+            Literal values.
+            The result will drop at a location if any field matches in the Column.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column which field dropped by fileName.

Review Comment:
   oh, it's a mistake, updated with [f379ec3](https://github.com/apache/spark/pull/37521/commits/f379ec368c2309e353bba97d86ede443abb800ce)



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r952480670


##########
python/pyspark/sql/column.py:
##########
@@ -495,6 +544,17 @@ def dropFields(self, *fieldNames: str) -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldNames : str or list

Review Comment:
   Yeah, updated



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r950002327


##########
python/pyspark/sql/column.py:
##########
@@ -720,8 +817,20 @@ def isin(self, *cols: Any) -> "Column":
 
         .. versionadded:: 1.5.0
 
+        Parameters
+        ----------
+        cols
+            The result will only be true at a location if all the labels match in the Column.

Review Comment:
   Thanks. Better match the method function.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1216071799

   cc @zero323 too


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] xinrong-meng commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
xinrong-meng commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r947079687


##########
python/pyspark/sql/column.py:
##########
@@ -405,6 +415,20 @@ def getItem(self, key: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        key
+            a literal value, or a :class:`Column` expression.
+            The result will only be true at a location if item matches in the column.
+
+             .. deprecated:: 3.0.0
+                 :class:`Column` as a parameter is deprecated.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column as items contained in key.

Review Comment:
   nit: how about `Column representing the item(s) got at position ``ordinal`` out of a list or by key out of a dict`?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon closed pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained
URL: https://github.com/apache/spark/pull/37521


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946371134


##########
python/pyspark/sql/column.py:
##########
@@ -187,18 +187,26 @@ class Column:
     """
     A column in a DataFrame.
 
-    :class:`Column` instances can be created by::
+    .. versionadded:: 1.3.0
 
-        # 1. Select a column out of a DataFrame
+    Examples
+    --------
+    :class:`Column` instances can be created by::
 
-        df.colName
-        df["colName"]
+    >>> df = spark.createDataFrame(
+    ...      [(2, "Alice"), (5, "Bob")], ["age", "name"])
 
-        # 2. Create from an expression
-        df.colName + 1
-        1 / df.colName
+    1. Select a column out of a DataFrame
+    >>> df.name
+    Column<'name'>
+    >>> df["name"]
+    Column<'name'>
 
-    .. versionadded:: 1.3.0
+    2. Create from an expression

Review Comment:
   Otherwise, I think the documentation rendering is broken IIRC



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1216069162

   cc @zhengruifeng @Yikun too


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946281530


##########
python/pyspark/sql/column.py:
##########
@@ -430,6 +441,17 @@ def getField(self, name: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        name
+            a literal value, or a :class:`Column` expression.
+            The result will only be true at a location if field matches in the Column.
+

Review Comment:
   ```suggestion
   
                .. deprecated:: 3.0.0
                    :class:`Column` as a parameter is deprecated.
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zero323 commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
zero323 commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946537626


##########
python/pyspark/sql/column.py:
##########
@@ -934,8 +1064,25 @@ def between(
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        lowerBound : :class:`Column` or :class:`LiteralType`

Review Comment:
   I think it is better to avoid referencing typing aliases in the docs.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] xinrong-meng commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
xinrong-meng commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r947080266


##########
python/pyspark/sql/column.py:
##########
@@ -462,6 +499,18 @@ def withField(self, fieldName: str, col: "Column") -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldName : str
+            a literal value.
+            The result will only be true at a location if any field matches in the Column.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column
+            which field added/replaced by fileName.

Review Comment:
   nit: `fieldName`



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1217432637

   @zero323 @xinrong-meng Thanks for your review and I will clarify and update later :)


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946644594


##########
python/pyspark/sql/column.py:
##########
@@ -934,8 +1064,25 @@ def between(
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        lowerBound : :class:`Column` or :class:`LiteralType`

Review Comment:
   oh, I just find that `LiteralType`/`DateTimeLiteral`/`DecimalLiteral` are typing aliases. Do you mean that we need use origin type here?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] xinrong-meng commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
xinrong-meng commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r947079687


##########
python/pyspark/sql/column.py:
##########
@@ -405,6 +415,20 @@ def getItem(self, key: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        key
+            a literal value, or a :class:`Column` expression.
+            The result will only be true at a location if item matches in the column.
+
+             .. deprecated:: 3.0.0
+                 :class:`Column` as a parameter is deprecated.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column as items contained in key.

Review Comment:
   nit: how about `Column representing the item(s) got at position out of a list or by key out of a dict`?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946382539


##########
python/pyspark/sql/column.py:
##########
@@ -187,18 +187,26 @@ class Column:
     """
     A column in a DataFrame.
 
-    :class:`Column` instances can be created by::
+    .. versionadded:: 1.3.0
 
-        # 1. Select a column out of a DataFrame
+    Examples
+    --------
+    :class:`Column` instances can be created by::
 
-        df.colName
-        df["colName"]
+    >>> df = spark.createDataFrame(
+    ...      [(2, "Alice"), (5, "Bob")], ["age", "name"])
 
-        # 2. Create from an expression
-        df.colName + 1
-        1 / df.colName
+    1. Select a column out of a DataFrame
+    >>> df.name
+    Column<'name'>
+    >>> df["name"]
+    Column<'name'>
 
-    .. versionadded:: 1.3.0
+    2. Create from an expression

Review Comment:
   Thanks, updated in latest commit. Let's see result.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Yikun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
Yikun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r952062535


##########
python/pyspark/sql/column.py:
##########
@@ -495,6 +544,17 @@ def dropFields(self, *fieldNames: str) -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldNames : str or list

Review Comment:
   ```suggestion
           fieldNames : str
   ```
   
   `list` is not accurate, it's just a positional arguments.
   
   
   ```
   >>> df.withColumn('a', df['a'].dropFields('b', 'c')).show()
   +--------------+
   |             a|
   +--------------+
   |{3, {4, 5, 6}}|
   +--------------+
   
   >>> df.withColumn('a', df['a'].dropFields(['b', 'c'])).show()
   Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/Users/yikun/spark/python/pyspark/sql/column.py", line 543, in dropFields
       jc = self._jc.dropFields(_to_seq(sc, fieldNames))
     File "/Users/yikun/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1322, in __call__
     File "/Users/yikun/spark/python/pyspark/sql/utils.py", line 190, in deco
       return f(*a, **kw)
     File "/Users/yikun/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/protocol.py", line 326, in get_return_value
   py4j.protocol.Py4JJavaError: An error occurred while calling o88.dropFields.
   : java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
   ```
   
   I think below is a good example to describe positional arguments:
   https://github.com/apache/spark/blob/af2d2ee11530a98e748518a81925f3f0a2392209/python/pyspark/sql/column.py#L861



##########
python/pyspark/sql/column.py:
##########
@@ -462,6 +499,18 @@ def withField(self, fieldName: str, col: "Column") -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldName : str
+            a literal value.
+            The result will only be true at a location if any field matches in the Column.

Review Comment:
   `col` parameter?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r952480335


##########
python/pyspark/sql/column.py:
##########
@@ -462,6 +499,18 @@ def withField(self, fieldName: str, col: "Column") -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldName : str
+            a literal value.
+            The result will only be true at a location if any field matches in the Column.

Review Comment:
   Thanks, updated :)



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946281949


##########
python/pyspark/sql/column.py:
##########
@@ -934,8 +1049,25 @@ def between(
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        lowerBound : :class:`Column` or :class:`LiteralType`
+        or :class:`DateTimeLiteral` or :class:`DecimalLiteral`

Review Comment:
   ```suggestion
               or :class:`DateTimeLiteral` or :class:`DecimalLiteral`
   ```



##########
python/pyspark/sql/column.py:
##########
@@ -934,8 +1049,25 @@ def between(
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        lowerBound : :class:`Column` or :class:`LiteralType`
+        or :class:`DateTimeLiteral` or :class:`DecimalLiteral`
+            a boolean expression that boundary start, inclusive..
+        upperBound : :class:`Column` or :class:`LiteralType`
+        or :class:`DateTimeLiteral` or :class:`DecimalLiteral`

Review Comment:
   ```suggestion
               or :class:`DateTimeLiteral` or :class:`DecimalLiteral`
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zero323 commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
zero323 commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r947044946


##########
python/pyspark/sql/column.py:
##########
@@ -495,6 +544,17 @@ def dropFields(self, *fieldNames: str) -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldNames : str or list
+            Literal values.
+            The result will drop at a location if any field matches in the Column.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column which field dropped by fileName.

Review Comment:
   These look like typos:
   
   - `which` -> `with`
   - `fileName` -> `fieldName`



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] Yikun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
Yikun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r952057393


##########
python/pyspark/sql/column.py:
##########
@@ -462,6 +499,18 @@ def withField(self, fieldName: str, col: "Column") -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldName : str
+            a literal value.
+            The result will only be true at a location if any field matches in the Column.

Review Comment:
   forgot `col` parameter?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r949999640


##########
python/pyspark/sql/column.py:
##########
@@ -405,6 +415,20 @@ def getItem(self, key: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        key
+            a literal value, or a :class:`Column` expression.
+            The result will only be true at a location if item matches in the column.
+
+             .. deprecated:: 3.0.0
+                 :class:`Column` as a parameter is deprecated.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column as items contained in key.

Review Comment:
   Thanks. Better than older.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zero323 commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
zero323 commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946538029


##########
python/pyspark/sql/column.py:
##########
@@ -934,8 +1064,25 @@ def between(
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        lowerBound : :class:`Column` or :class:`LiteralType`

Review Comment:
   I think it is better to avoid referencing typing aliases in the docs.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1214969418

   Can one of the admins verify this patch?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946370890


##########
python/pyspark/sql/column.py:
##########
@@ -187,18 +187,26 @@ class Column:
     """
     A column in a DataFrame.
 
-    :class:`Column` instances can be created by::
+    .. versionadded:: 1.3.0
 
-        # 1. Select a column out of a DataFrame
+    Examples
+    --------
+    :class:`Column` instances can be created by::
 
-        df.colName
-        df["colName"]
+    >>> df = spark.createDataFrame(
+    ...      [(2, "Alice"), (5, "Bob")], ["age", "name"])
 
-        # 2. Create from an expression
-        df.colName + 1
-        1 / df.colName
+    1. Select a column out of a DataFrame

Review Comment:
   ```suggestion
       Select a column out of a DataFrame
   
   ```



##########
python/pyspark/sql/column.py:
##########
@@ -187,18 +187,26 @@ class Column:
     """
     A column in a DataFrame.
 
-    :class:`Column` instances can be created by::
+    .. versionadded:: 1.3.0
 
-        # 1. Select a column out of a DataFrame
+    Examples
+    --------
+    :class:`Column` instances can be created by::
 
-        df.colName
-        df["colName"]
+    >>> df = spark.createDataFrame(
+    ...      [(2, "Alice"), (5, "Bob")], ["age", "name"])
 
-        # 2. Create from an expression
-        df.colName + 1
-        1 / df.colName
+    1. Select a column out of a DataFrame
+    >>> df.name
+    Column<'name'>
+    >>> df["name"]
+    Column<'name'>
 
-    .. versionadded:: 1.3.0
+    2. Create from an expression

Review Comment:
   ```suggestion
       Create from an expression
   
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1223376601

   @Yikun @itholic mind taking another pass when you find some time please?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946281300


##########
python/pyspark/sql/column.py:
##########
@@ -405,6 +405,17 @@ def getItem(self, key: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        key
+            a literal value, or a :class:`Column` expression (deprecated since Spark 3.0).
+            The result will only be true at a location if item matches in the Column.

Review Comment:
   ```suggestion
               a literal value, or a :class:`Column` expression.
               The result will only be true at a location if item matches in the column.
   
                .. deprecated:: 3.0.0
                    :class:`Column` as a parameter is deprecated.
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on PR #37521:
URL: https://github.com/apache/spark/pull/37521#issuecomment-1216050558

   cc @HyukjinKwon @xinrong-meng   
   It would be good if you have time to review this PR.


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r950000562


##########
python/pyspark/sql/column.py:
##########
@@ -462,6 +499,18 @@ def withField(self, fieldName: str, col: "Column") -> "Column":
 
         .. versionadded:: 3.1.0
 
+        Parameters
+        ----------
+        fieldName : str
+            a literal value.
+            The result will only be true at a location if any field matches in the Column.
+
+        Returns
+        -------
+        :class:`Column`
+            Column representing whether each element of Column
+            which field added/replaced by fileName.

Review Comment:
   Thanks, my mistake, updated in [f379ec3](https://github.com/apache/spark/pull/37521/commits/f379ec368c2309e353bba97d86ede443abb800ce)



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zero323 commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
zero323 commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r947046722


##########
python/pyspark/sql/column.py:
##########
@@ -720,8 +817,20 @@ def isin(self, *cols: Any) -> "Column":
 
         .. versionadded:: 1.5.0
 
+        Parameters
+        ----------
+        cols
+            The result will only be true at a location if all the labels match in the Column.

Review Comment:
   Shouldn't it be "any" instead of "all"? Also "value" might be a better wording than "label".



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r946661523


##########
python/pyspark/sql/column.py:
##########
@@ -934,8 +1064,25 @@ def between(
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        lowerBound : :class:`Column` or :class:`LiteralType`

Review Comment:
   Updated. Use origin type in latest commit.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] zero323 commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
zero323 commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r947044118


##########
python/pyspark/sql/column.py:
##########
@@ -430,6 +454,19 @@ def getField(self, name: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        name
+            a literal value, or a :class:`Column` expression.
+            The result will only be true at a location if field matches in the Column.

Review Comment:
   @dcoliversun Could you clarify what you mean here and in other places where you use similar phrasing? 



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #37521: [SPARK-40078][PYTHON][DOCS] Make pyspark.sql.column examples self-contained

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #37521:
URL: https://github.com/apache/spark/pull/37521#discussion_r949995206


##########
python/pyspark/sql/column.py:
##########
@@ -430,6 +454,19 @@ def getField(self, name: Any) -> "Column":
 
         .. versionadded:: 1.3.0
 
+        Parameters
+        ----------
+        name
+            a literal value, or a :class:`Column` expression.
+            The result will only be true at a location if field matches in the Column.

Review Comment:
   I refer to [isin](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.isin.html) in pandas document. It phrases that Column is selected when field in the column matches conditions.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org