You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2023/06/23 00:09:32 UTC

[spark] branch branch-3.4 updated: [SPARK-44142][PYTHON] Replace type with tpe in utility to convert python types to spark types

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

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


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

commit 9fe29ac9c538e60d6c7be2d95ce0bd2f025dd2cd
Author: Ted <77...@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 <77...@users.noreply.github.com>
    Signed-off-by: Hyukjin Kwon <gu...@apache.org>
    (cherry picked from commit 5feab1072ba057da3811069c3eb8efec0de1044c)
    Signed-off-by: Hyukjin Kwon <gu...@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 dfb1bc6f9ba..54f6c71988c 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-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org