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 2020/06/11 00:31:45 UTC
[GitHub] [spark] BryanCutler opened a new pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
BryanCutler opened a new pull request #28793:
URL: https://github.com/apache/spark/pull/28793
### 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.
-->
When using pyarrow to convert a Pandas categorical column, use `is_categorical` instead of trying to import `CategoricalDtype`
### 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.
-->
The import for `CategoricalDtype` had changed from Pandas 0.23 to 1.0 and pyspark currently tries both locations. Using `is_categorical` is a more stable API.
### 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'.
-->
No
### 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.
-->
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] HyukjinKwon commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642350475
@dongjoon-hyun, do you mean you tested `./run-tests --modules=pyspark-sql` I guess? Pandas is SQL only dependency in Spark. The tests look okay fine in my local:
```bash
➜ ~ pip list | grep pandas
pandas 0.23.2 /usr/local/lib/python3.7/site-packages
```
```bash
➜ python git:(d2030cf4629) ./run-tests --python-executable=python3 --modules=pyspark-sql
...
```
What kind of test failure did you meet?
----------------------------------------------------------------
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] dongjoon-hyun commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642342609
cc @williamhyun , 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.
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642364152
Got it. I just double checked and all tests passed. If there's an issue with pandas 0.23.2 in other modules, it might be related to numpy which is a dependency in ML/Mllib in PySpark.
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642356059
Interesting .. other modules don't use pandas .. let me test it out.
----------------------------------------------------------------
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] dongjoon-hyun commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642371839
Thank you so much for confirming~ Then, it's okay. I'll check my environment again. I didn't run pyspark test for a long time. :)
----------------------------------------------------------------
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] dongjoon-hyun edited a comment on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun edited a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642342345
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642350844
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] dongjoon-hyun commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642362881
Thanks. Yes. I agree that should not affect the other modules~ So, I didn't investigate further.
----------------------------------------------------------------
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] dongjoon-hyun edited a comment on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun edited a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642342345
BTW, @BryanCutler and @HyukjinKwon .
At the previous PR, I tested `pyspark sql` only. For the other test suite, it seems to have the similar issues. When I use Pandas 0.23.2, the test fails. Could you confirm if `master` branch is healthy or not, 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.
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642350610
Let me merge this one first anyway :-).
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642347257
----------------------------------------------------------------
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] BryanCutler commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
BryanCutler commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642337309
@HyukjinKwon I though we could avoid any categorical imports by comparing the dtype with strings, e.g. `s.dtype == 'category'` but that seems to fail for any other types than categories. It seems `is_categorical` is the preferred stable api. This change is not that different from what is there currently, so not a big deal if you think this isn't better.
----------------------------------------------------------------
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] dongjoon-hyun commented on a change in pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #28793:
URL: https://github.com/apache/spark/pull/28793#discussion_r438484371
##########
File path: python/pyspark/sql/pandas/serializers.py
##########
@@ -143,10 +143,7 @@ def _create_batch(self, series):
import pandas as pd
import pyarrow as pa
from pyspark.sql.pandas.types import _check_series_convert_timestamps_internal
- try:
- from pandas import CategoricalDtype
- except ImportError:
- from pandas.api.types import CategoricalDtype
+ from pandas.api.types import is_categorical
Review comment:
Oh, nice!
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642346815
**[Test build #123800 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/123800/testReport)** for PR 28793 at commit [`d2030cf`](https://github.com/apache/spark/commit/d2030cf4629a640b3b4b24e7ebe21dc32e645f36).
* 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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642347257
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642337577
----------------------------------------------------------------
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] dongjoon-hyun edited a comment on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun edited a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642353545
I meant `pyspark-sql` test was okay, but the other module failed when you use `pandas 0.23.2` and run `python/run-tests.py --python-executables python`.
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #28793:
URL: https://github.com/apache/spark/pull/28793
----------------------------------------------------------------
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] dongjoon-hyun commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642342345
BTW, @BryanCutler and @HyukjinKwon .
Previously, I tested `pyspark sql` only. For the other test suite, it seems to have the similar issues. When I use Pandas 0.23.2, the test fails. Could you confirm if `master` branch is healthy or not, 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.
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] dongjoon-hyun edited a comment on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun edited a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642362881
Thanks. Yes. I agree that it should not affect the other modules~ So, I didn't investigate further.
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642337238
**[Test build #123800 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/123800/testReport)** for PR 28793 at commit [`d2030cf`](https://github.com/apache/spark/commit/d2030cf4629a640b3b4b24e7ebe21dc32e645f36).
----------------------------------------------------------------
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] dongjoon-hyun commented on pull request #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642353545
I meant `pyspark-sql` test was okay, but the other module fails when you use `pandas 0.23.2` and run `python/run-tests.py --python-executables python`.
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642337577
----------------------------------------------------------------
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 #28793: [SPARK-31964][PYTHON] Use Pandas is_categorical on Arrow category type conversion
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28793:
URL: https://github.com/apache/spark/pull/28793#issuecomment-642337238
**[Test build #123800 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/123800/testReport)** for PR 28793 at commit [`d2030cf`](https://github.com/apache/spark/commit/d2030cf4629a640b3b4b24e7ebe21dc32e645f36).
----------------------------------------------------------------
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