zhengruifeng opened a new pull request, #40582:
URL: https://github.com/apache/spark/pull/40582
### What changes were proposed in this pull request?
Add `YearMonthIntervalType` to PySpark and Spark Connect Python Client
### Why are the changes needed?
function parity
**Note**
the added `YearMonthIntervalType` is not support in
`collect`/`createDataFrame`, since I don't find a python built-in type for
`YearMonthIntervalType` (like `datetime.timedelta` for `DayTimeIntervalType`),
we need further discussion.
### Does this PR introduce _any_ user-facing change?
yes, new data type in python
before this PR
```
In [1]: spark.sql("SELECT INTERVAL '10-8' YEAR TO MONTH AS interval")
Out[1]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/Dev/spark/python/pyspark/sql/dataframe.py:570, in
DataFrame.schema(self)
568 try:
569 self._schema = cast(
--> 570 StructType,
_parse_datatype_json_string(self._jdf.schema().json())
571 )
572 except Exception as e:
...
ValueError: Unable to parse datatype from schema. Could not parse datatype:
interval year to month
```
after this PR
```
In [3]: spark.sql("SELECT INTERVAL '10-8' YEAR TO MONTH AS interval")
Out[3]: DataFrame[interval: interval year to month]
```
### How was this patch tested?
added UT
--
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]