itholic commented on code in PR #37234:
URL: https://github.com/apache/spark/pull/37234#discussion_r925397234
##########
python/pyspark/pandas/typedef/typehints.py:
##########
@@ -357,7 +359,18 @@ def infer_pd_series_spark_type(
elif hasattr(pser.iloc[0], "__UDT__"):
return pser.iloc[0].__UDT__
else:
- return from_arrow_type(pa.Array.from_pandas(pser).type,
prefer_timestamp_ntz)
+ try:
+ internal_frame = pa.Array.from_pandas(pser)
+ except (pa.lib.ArrowInvalid, pa.lib.ArrowTypeError):
+ raise SparkPandasNotImplementedError(
+ description="Pyspark doesn't support multiple type in a
single index,"
Review Comment:
nit: Pyspark -> "PySpark" or "pandas API on Spark" ?
##########
python/pyspark/pandas/typedef/typehints.py:
##########
@@ -357,7 +359,18 @@ def infer_pd_series_spark_type(
elif hasattr(pser.iloc[0], "__UDT__"):
return pser.iloc[0].__UDT__
else:
- return from_arrow_type(pa.Array.from_pandas(pser).type,
prefer_timestamp_ntz)
+ try:
+ internal_frame = pa.Array.from_pandas(pser)
+ except (pa.lib.ArrowInvalid, pa.lib.ArrowTypeError):
+ raise SparkPandasNotImplementedError(
+ description="Pyspark doesn't support multiple type in a
single index,"
+ " such as .Index([typeA, typeB]) or
MultipleIndex "
+ ".Index([[TypeA, TypeB],[TypeA, TypeB]]) in
pandas doesn't "
+ "support in pyspark, you need to keep the
values as the same "
+ "type in pyspark. Got {} and dtype
({}).".format(
Review Comment:
ditto, let's change "pyspark" to something else.
##########
python/pyspark/pandas/typedef/typehints.py:
##########
@@ -357,7 +359,18 @@ def infer_pd_series_spark_type(
elif hasattr(pser.iloc[0], "__UDT__"):
return pser.iloc[0].__UDT__
else:
- return from_arrow_type(pa.Array.from_pandas(pser).type,
prefer_timestamp_ntz)
+ try:
+ internal_frame = pa.Array.from_pandas(pser)
+ except (pa.lib.ArrowInvalid, pa.lib.ArrowTypeError):
+ raise SparkPandasNotImplementedError(
+ description="Pyspark doesn't support multiple type in a
single index,"
+ " such as .Index([typeA, typeB]) or
MultipleIndex "
Review Comment:
MultipleIndex -> MultiIndex ??
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]