This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 6868d6c6a38 [SPARK-44142][PYTHON] Replace type with tpe in utility to 
convert python types to spark types
6868d6c6a38 is described below

commit 6868d6c6a38c4c74f0bad7823a7eaa88b6b86e26
Author: Ted <77486246+ted-je...@users.noreply.github.com>
AuthorDate: Fri Jun 23 09:09:13 2023 +0900

    [SPARK-44142][PYTHON] Replace type with tpe in utility to convert python 
types to spark types
    
    ### What changes were proposed in this pull request?
    
    In the typehints utility to convert python types to spark types, use the 
variable `tpe` for comparison to the string representation of categorical types 
rather than `type`.
    
    ### Why are the changes needed?
    
    Currently, the Python keyword `type` is used in the comparison, which will 
always be false. The user's type is stored in variable `tpe`.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Existing `test_categorical.py` tests
    
    Closes #41697 from ted-jenks/patch-3.
    
    Authored-by: Ted <77486246+ted-je...@users.noreply.github.com>
    Signed-off-by: Hyukjin Kwon <gurwls...@apache.org>
    (cherry picked from commit 5feab1072ba057da3811069c3eb8efec0de1044c)
    Signed-off-by: Hyukjin Kwon <gurwls...@apache.org>
---
 python/pyspark/pandas/typedef/typehints.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/pyspark/pandas/typedef/typehints.py 
b/python/pyspark/pandas/typedef/typehints.py
index 7bb54398fab..5d52635fac6 100644
--- a/python/pyspark/pandas/typedef/typehints.py
+++ b/python/pyspark/pandas/typedef/typehints.py
@@ -214,7 +214,7 @@ def as_spark_type(
         return types.DayTimeIntervalType()
 
     # categorical types
-    elif isinstance(tpe, CategoricalDtype) or (isinstance(tpe, str) and type 
== "category"):
+    elif isinstance(tpe, CategoricalDtype) or (isinstance(tpe, str) and tpe == 
"category"):
         return types.LongType()
 
     # extension types


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to