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 2021/06/03 22:31:15 UTC

[GitHub] [spark] ueshin opened a new pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

ueshin opened a new pull request #32775:
URL: https://github.com/apache/spark/pull/32775


   ### What changes were proposed in this pull request?
   
   Introduces `Field` to manage dtypes and `StructField`s.
   
   `InternalFrame` is already managing dtypes, but when it checks the Spark's data types, column names, and nullabilities, it tries to run the analysis phase each time it needs, which will cause a performance issue.
   
   It will use `Field` class which stores the retrieved Spark's data types, column names, and nullabilities, and reuse them. Also, in case those can be known, just update and reuse them without asking Spark.
   
   ### Why are the changes needed?
   
   Currently there are some performance issues in the pandas-on-Spark layer.
   
   One of them is accessing Java DataFrame and run analysis phase too many times, especially just for retrieving the current column names or data types.
   
   We should reduce the amount of unnecessary access.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Improves the performance in pandas-on-Spark layer:
   
   ```py
   df = ps.read_parquet("/path/to/test.parquet")  # contains ~75 columns
   df = df[(df["col"] > 0) & (df["col"] < 10000)]
   ```
   
   Before the PR, it took about **2.15 sec** and after **1.15 sec**.
   
   ### How was this patch tested?
   
   Existing tests.


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855034404


   **[Test build #139355 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139355/testReport)** for PR 32775 at commit [`5804ee6`](https://github.com/apache/spark/commit/5804ee650dba2fd721b013b2667c90058275736a).


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855109700


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43877/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854258121


   Kubernetes integration test unable to build dist.
   
   exiting with code: 1
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43825/
   


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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #32775:
URL: https://github.com/apache/spark/pull/32775


   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854241466






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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   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.

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854241466


   **[Test build #139302 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139302/testReport)** for PR 32775 at commit [`339241c`](https://github.com/apache/spark/commit/339241c24cbf7d22dc5a0d210ed88f7d7b3dea90).


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855058940


   **[Test build #139355 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139355/testReport)** for PR 32775 at commit [`5804ee6`](https://github.com/apache/spark/commit/5804ee650dba2fd721b013b2667c90058275736a).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854252852


   **[Test build #139302 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139302/testReport)** for PR 32775 at commit [`339241c`](https://github.com/apache/spark/commit/339241c24cbf7d22dc5a0d210ed88f7d7b3dea90).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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

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] SparkQA removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854241466


   **[Test build #139302 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139302/testReport)** for PR 32775 at commit [`339241c`](https://github.com/apache/spark/commit/339241c24cbf7d22dc5a0d210ed88f7d7b3dea90).


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

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 #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

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


   LGTM


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856340710


   **[Test build #139436 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139436/testReport)** for PR 32775 at commit [`e0c9767`](https://github.com/apache/spark/commit/e0c9767ae6a1ec625995616da387dd3b0e88455c).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856176782


   **[Test build #139431 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139431/testReport)** for PR 32775 at commit [`84f45df`](https://github.com/apache/spark/commit/84f45dfc196039ec8d03f04093fba3c7a02984de).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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

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 #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

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






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

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-databricks commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854882969


   Looks great, thanks!


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856316904


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43957/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856301305


   **[Test build #139434 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139434/testReport)** for PR 32775 at commit [`683f657`](https://github.com/apache/spark/commit/683f657d69ab89cdce501d87f3683c79fdd6c2b2).


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

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 change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645263788



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -385,10 +528,10 @@ def __init__(
         spark_frame: spark.DataFrame,
         index_spark_columns: Optional[List[spark.Column]],
         index_names: Optional[List[Optional[Tuple]]] = None,
-        index_dtypes: Optional[List[Dtype]] = None,
+        index_fields: Optional[List[Field]] = None,

Review comment:
       Hm .. should we maybe combine it with `index_spark_columns` and `data_spark_columns` respectively?

##########
File path: python/pyspark/pandas/internal.py
##########
@@ -385,10 +528,10 @@ def __init__(
         spark_frame: spark.DataFrame,
         index_spark_columns: Optional[List[spark.Column]],
         index_names: Optional[List[Optional[Tuple]]] = None,
-        index_dtypes: Optional[List[Dtype]] = None,
+        index_fields: Optional[List[Field]] = None,

Review comment:
       Can be done in a followup but just wondering.




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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855074702


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43877/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856160743


   **[Test build #139431 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139431/testReport)** for PR 32775 at commit [`84f45df`](https://github.com/apache/spark/commit/84f45dfc196039ec8d03f04093fba3c7a02984de).


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856193170


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139431/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856345334


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43959/
   


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

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 change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645263623



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -73,6 +80,131 @@
 SPARK_DEFAULT_SERIES_NAME = str(DEFAULT_SERIES_NAME)
 
 
+class Field:

Review comment:
       Should we maybe name it `InternalField`?




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

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 #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

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






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

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 #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139355/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856357006


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43959/
   


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855109755


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43877/
   


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

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] SparkQA removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856329795


   **[Test build #139436 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139436/testReport)** for PR 32775 at commit [`e0c9767`](https://github.com/apache/spark/commit/e0c9767ae6a1ec625995616da387dd3b0e88455c).


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856367230


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43959/
   


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

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-databricks commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645720199



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -120,13 +252,13 @@ class InternalFrame(object):
 
     * `data_spark_columns` represents non-indexing Spark columns
 
-    * `data_dtypes` represents external non-indexing dtypes
+    * `data_fields` represents non-indexing field metadata

Review comment:
       I'm wondering if `field metadata` and `Return the metadata for the field` are confusing for people out of context.




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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855091658


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139355/
   


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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139431/
   


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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139436/
   


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

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] ueshin commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
ueshin commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854276308


   cc @HyukjinKwon @itholic @xinrong-databricks 


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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139434/
   


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

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] SparkQA removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-855034404


   **[Test build #139355 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139355/testReport)** for PR 32775 at commit [`5804ee6`](https://github.com/apache/spark/commit/5804ee650dba2fd721b013b2667c90058275736a).


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

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] ueshin commented on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
ueshin commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854276308


   cc @HyukjinKwon @itholic @xinrong-databricks 


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856185786


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43954/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856311063


   **[Test build #139434 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139434/testReport)** for PR 32775 at commit [`683f657`](https://github.com/apache/spark/commit/683f657d69ab89cdce501d87f3683c79fdd6c2b2).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856346771


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139436/
   


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

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] SparkQA removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856160743


   **[Test build #139431 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139431/testReport)** for PR 32775 at commit [`84f45df`](https://github.com/apache/spark/commit/84f45dfc196039ec8d03f04093fba3c7a02984de).


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

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] ueshin commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
ueshin commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645879993



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -73,6 +80,131 @@
 SPARK_DEFAULT_SERIES_NAME = str(DEFAULT_SERIES_NAME)
 
 
+class Field:
+    """
+    The field metadata to store the dtype as well as the Spark's StructField optionally.
+
+    Parameters
+    ----------
+    dtype : numpy.dtype or pandas' ExtensionDtype
+        The dtype for the field
+    struct_field : StructField, optional
+        The `StructField` for the field. If None, InternalFrame will properly set.
+    """
+    def __init__(self, dtype: Dtype, struct_field: Optional[StructField] = None):
+        self._dtype = dtype
+        self._struct_field = struct_field
+
+    @staticmethod
+    def from_struct_field(
+        struct_field: StructField, *, use_extension_dtypes: bool = False
+    ) -> "Field":
+        """
+        Returns a new Field object created from the given StructField.
+
+        The dtype will be inferred from the data type of the given StructField.
+
+        Parameters
+        ----------
+        struct_field : StructField
+            The StructField used to create a new Field object.
+        use_extension_dtypes : bool
+            If True, try to use the extension dtypes.
+
+        Returns
+        -------
+        Field
+        """
+        return Field(
+            dtype=spark_type_to_pandas_dtype(
+                struct_field.dataType, use_extension_dtypes=use_extension_dtypes
+            ),
+            struct_field=struct_field,
+        )
+
+    @property
+    def dtype(self) -> Dtype:
+        """ Return the dtype for the field. """
+        return self._dtype
+
+    @property
+    def struct_field(self) -> Optional[StructField]:
+        """ Return the StructField for the field. """
+        return self._struct_field
+
+    @property
+    def name(self) -> str:
+        """ Return the field name if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.name
+
+    @property
+    def spark_type(self) -> DataType:
+        """ Return the spark data type for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.dataType
+
+    @property
+    def nullable(self) -> bool:
+        """ Return the nullability for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.nullable
+
+    @property
+    def metadata(self) -> Dict[str, Any]:
+        """ Return the metadata for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.metadata
+
+    @property
+    def is_extension_dtype(self) -> bool:
+        """ Return whether the dtype for the field is an extension type or not. """
+        return isinstance(self.dtype, extension_dtypes)
+
+    def normalize_spark_type(self) -> "Field":
+        """ Return a new Field object with normalized Spark data type. """

Review comment:
       I thought `normalize` was good enough here, but it would be great if there is a better word.




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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43954/
   


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

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] SparkQA removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854241466


   **[Test build #139302 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139302/testReport)** for PR 32775 at commit [`339241c`](https://github.com/apache/spark/commit/339241c24cbf7d22dc5a0d210ed88f7d7b3dea90).


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

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] SparkQA removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856301305


   **[Test build #139434 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139434/testReport)** for PR 32775 at commit [`683f657`](https://github.com/apache/spark/commit/683f657d69ab89cdce501d87f3683c79fdd6c2b2).


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854261326






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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856351959


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43957/
   


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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43959/
   


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856329795


   **[Test build #139436 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/139436/testReport)** for PR 32775 at commit [`e0c9767`](https://github.com/apache/spark/commit/e0c9767ae6a1ec625995616da387dd3b0e88455c).


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856351947


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43957/
   


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

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-databricks commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645890652



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -73,6 +80,131 @@
 SPARK_DEFAULT_SERIES_NAME = str(DEFAULT_SERIES_NAME)
 
 
+class Field:
+    """
+    The field metadata to store the dtype as well as the Spark's StructField optionally.
+
+    Parameters
+    ----------
+    dtype : numpy.dtype or pandas' ExtensionDtype
+        The dtype for the field
+    struct_field : StructField, optional
+        The `StructField` for the field. If None, InternalFrame will properly set.
+    """
+    def __init__(self, dtype: Dtype, struct_field: Optional[StructField] = None):
+        self._dtype = dtype
+        self._struct_field = struct_field
+
+    @staticmethod
+    def from_struct_field(
+        struct_field: StructField, *, use_extension_dtypes: bool = False
+    ) -> "Field":
+        """
+        Returns a new Field object created from the given StructField.
+
+        The dtype will be inferred from the data type of the given StructField.
+
+        Parameters
+        ----------
+        struct_field : StructField
+            The StructField used to create a new Field object.
+        use_extension_dtypes : bool
+            If True, try to use the extension dtypes.
+
+        Returns
+        -------
+        Field
+        """
+        return Field(
+            dtype=spark_type_to_pandas_dtype(
+                struct_field.dataType, use_extension_dtypes=use_extension_dtypes
+            ),
+            struct_field=struct_field,
+        )
+
+    @property
+    def dtype(self) -> Dtype:
+        """ Return the dtype for the field. """
+        return self._dtype
+
+    @property
+    def struct_field(self) -> Optional[StructField]:
+        """ Return the StructField for the field. """
+        return self._struct_field
+
+    @property
+    def name(self) -> str:
+        """ Return the field name if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.name
+
+    @property
+    def spark_type(self) -> DataType:
+        """ Return the spark data type for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.dataType
+
+    @property
+    def nullable(self) -> bool:
+        """ Return the nullability for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.nullable
+
+    @property
+    def metadata(self) -> Dict[str, Any]:
+        """ Return the metadata for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.metadata
+
+    @property
+    def is_extension_dtype(self) -> bool:
+        """ Return whether the dtype for the field is an extension type or not. """
+        return isinstance(self.dtype, extension_dtypes)
+
+    def normalize_spark_type(self) -> "Field":
+        """ Return a new Field object with normalized Spark data type. """

Review comment:
       Oh I was just wondering whether people have the same understanding of column normalization. `normalize` looks good.




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

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] ueshin commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
ueshin commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645879337



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -120,13 +252,13 @@ class InternalFrame(object):
 
     * `data_spark_columns` represents non-indexing Spark columns
 
-    * `data_dtypes` represents external non-indexing dtypes
+    * `data_fields` represents non-indexing field metadata

Review comment:
       Makes sense. I changed the wording.




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

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] ueshin commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
ueshin commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645882104



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -718,8 +927,11 @@ def attach_distributed_sequence_column(
                     sql_ctx,
                 )
                 columns = df.columns
-                return df.selectExpr(
-                    "`{}` as `{}`".format(columns[1], column_name), "`{}`.*".format(columns[0])
+                return (
+                    df.selectExpr(
+                        "`{}` as `{}`".format(columns[1], column_name), "`{}`.*".format(columns[0])
+                    ),
+                    True,

Review comment:
       The `Encoders.tuple` makes object-like elements nullable, which is the struct converted from the original data frame, and `GetStructField.nullable` depends on the child's nullability.




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

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 change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645252024



##########
File path: python/pyspark/pandas/frame.py
##########
@@ -7703,7 +7734,7 @@ def join(
         right: DataFrame, Series
         on: str, list of str, or array-like, optional
             Column or index level name(s) in the caller to join on the index in `right`, otherwise
-            joins index-on-index. If multiple values given, the `right` DataFrame must have a
+            joins index-on-index. If mult iple values given, the `right` DataFrame must have a

Review comment:
       nit: typo




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

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 #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

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


   LGTM


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

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] SparkQA commented on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856203952


   Kubernetes integration test status success
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/43954/
   


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

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] ueshin commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
ueshin commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645879152



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -385,10 +528,10 @@ def __init__(
         spark_frame: spark.DataFrame,
         index_spark_columns: Optional[List[spark.Column]],
         index_names: Optional[List[Optional[Tuple]]] = None,
-        index_dtypes: Optional[List[Dtype]] = None,
+        index_fields: Optional[List[Field]] = None,

Review comment:
       Yeah, we can, I guess. Let me think about it as a future work.




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

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 #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43957/
   


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-854261326






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

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-databricks commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645890875



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -718,8 +927,11 @@ def attach_distributed_sequence_column(
                     sql_ctx,
                 )
                 columns = df.columns
-                return df.selectExpr(
-                    "`{}` as `{}`".format(columns[1], column_name), "`{}`.*".format(columns[0])
+                return (
+                    df.selectExpr(
+                        "`{}` as `{}`".format(columns[1], column_name), "`{}`.*".format(columns[0])
+                    ),
+                    True,

Review comment:
       Thanks!




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

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-databricks commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645723865



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -718,8 +927,11 @@ def attach_distributed_sequence_column(
                     sql_ctx,
                 )
                 columns = df.columns
-                return df.selectExpr(
-                    "`{}` as `{}`".format(columns[1], column_name), "`{}`.*".format(columns[0])
+                return (
+                    df.selectExpr(
+                        "`{}` as `{}`".format(columns[1], column_name), "`{}`.*".format(columns[0])
+                    ),
+                    True,

Review comment:
       Why is `force_nullable` `True` 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.

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-databricks commented on a change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
xinrong-databricks commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645717705



##########
File path: python/pyspark/pandas/internal.py
##########
@@ -73,6 +80,131 @@
 SPARK_DEFAULT_SERIES_NAME = str(DEFAULT_SERIES_NAME)
 
 
+class Field:
+    """
+    The field metadata to store the dtype as well as the Spark's StructField optionally.
+
+    Parameters
+    ----------
+    dtype : numpy.dtype or pandas' ExtensionDtype
+        The dtype for the field
+    struct_field : StructField, optional
+        The `StructField` for the field. If None, InternalFrame will properly set.
+    """
+    def __init__(self, dtype: Dtype, struct_field: Optional[StructField] = None):
+        self._dtype = dtype
+        self._struct_field = struct_field
+
+    @staticmethod
+    def from_struct_field(
+        struct_field: StructField, *, use_extension_dtypes: bool = False
+    ) -> "Field":
+        """
+        Returns a new Field object created from the given StructField.
+
+        The dtype will be inferred from the data type of the given StructField.
+
+        Parameters
+        ----------
+        struct_field : StructField
+            The StructField used to create a new Field object.
+        use_extension_dtypes : bool
+            If True, try to use the extension dtypes.
+
+        Returns
+        -------
+        Field
+        """
+        return Field(
+            dtype=spark_type_to_pandas_dtype(
+                struct_field.dataType, use_extension_dtypes=use_extension_dtypes
+            ),
+            struct_field=struct_field,
+        )
+
+    @property
+    def dtype(self) -> Dtype:
+        """ Return the dtype for the field. """
+        return self._dtype
+
+    @property
+    def struct_field(self) -> Optional[StructField]:
+        """ Return the StructField for the field. """
+        return self._struct_field
+
+    @property
+    def name(self) -> str:
+        """ Return the field name if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.name
+
+    @property
+    def spark_type(self) -> DataType:
+        """ Return the spark data type for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.dataType
+
+    @property
+    def nullable(self) -> bool:
+        """ Return the nullability for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.nullable
+
+    @property
+    def metadata(self) -> Dict[str, Any]:
+        """ Return the metadata for the field if the StructField exists. """
+        assert self.struct_field is not None
+        return self.struct_field.metadata
+
+    @property
+    def is_extension_dtype(self) -> bool:
+        """ Return whether the dtype for the field is an extension type or not. """
+        return isinstance(self.dtype, extension_dtypes)
+
+    def normalize_spark_type(self) -> "Field":
+        """ Return a new Field object with normalized Spark data type. """

Review comment:
       Out of curiosity, is the definition of `normalize` universal?




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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856203973


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43954/
   


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

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 removed a comment on pull request #32775: [SPARK-35638][PYTHON] Introduce InternalField to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32775:
URL: https://github.com/apache/spark/pull/32775#issuecomment-856323332


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/139434/
   


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

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 #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

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


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/43877/
   


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

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 change in pull request #32775: [SPARK-35638][PYTHON] Introduce Field to manage dtypes and StructFields.

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #32775:
URL: https://github.com/apache/spark/pull/32775#discussion_r645252024



##########
File path: python/pyspark/pandas/frame.py
##########
@@ -7703,7 +7734,7 @@ def join(
         right: DataFrame, Series
         on: str, list of str, or array-like, optional
             Column or index level name(s) in the caller to join on the index in `right`, otherwise
-            joins index-on-index. If multiple values given, the `right` DataFrame must have a
+            joins index-on-index. If mult iple values given, the `right` DataFrame must have a

Review comment:
       nit: typo

##########
File path: python/pyspark/pandas/internal.py
##########
@@ -73,6 +80,131 @@
 SPARK_DEFAULT_SERIES_NAME = str(DEFAULT_SERIES_NAME)
 
 
+class Field:

Review comment:
       Should we maybe name it `InternalField`?

##########
File path: python/pyspark/pandas/internal.py
##########
@@ -385,10 +528,10 @@ def __init__(
         spark_frame: spark.DataFrame,
         index_spark_columns: Optional[List[spark.Column]],
         index_names: Optional[List[Optional[Tuple]]] = None,
-        index_dtypes: Optional[List[Dtype]] = None,
+        index_fields: Optional[List[Field]] = None,

Review comment:
       Hm .. should we maybe combine it with `index_spark_columns` and `data_spark_columns` respectively?

##########
File path: python/pyspark/pandas/internal.py
##########
@@ -385,10 +528,10 @@ def __init__(
         spark_frame: spark.DataFrame,
         index_spark_columns: Optional[List[spark.Column]],
         index_names: Optional[List[Optional[Tuple]]] = None,
-        index_dtypes: Optional[List[Dtype]] = None,
+        index_fields: Optional[List[Field]] = None,

Review comment:
       Can be done in a followup but just wondering.




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

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