-
Notifications
You must be signed in to change notification settings - Fork 28.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-48395][PYTHON] Fix
StructType.treeString
for parameterized t…
…ypes ### What changes were proposed in this pull request? this PR is a follow up of #46685. ### Why are the changes needed? `StructType.treeString` uses `DataType.typeName` to generate the tree string, however, the `typeName` in python is a class method and can not return the same string for parameterized types. ``` In [2]: schema = StructType().add("c", CharType(10), True).add("v", VarcharType(10), True).add("d", DecimalType(10, 2), True).add("ym00", YearM ...: onthIntervalType(0, 0)).add("ym01", YearMonthIntervalType(0, 1)).add("ym11", YearMonthIntervalType(1, 1)) In [3]: print(schema.treeString()) root |-- c: char (nullable = true) |-- v: varchar (nullable = true) |-- d: decimal (nullable = true) |-- ym00: yearmonthinterval (nullable = true) |-- ym01: yearmonthinterval (nullable = true) |-- ym11: yearmonthinterval (nullable = true) ``` it should be ``` In [4]: print(schema.treeString()) root |-- c: char(10) (nullable = true) |-- v: varchar(10) (nullable = true) |-- d: decimal(10,2) (nullable = true) |-- ym00: interval year (nullable = true) |-- ym01: interval year to month (nullable = true) |-- ym11: interval month (nullable = true) ``` ### Does this PR introduce _any_ user-facing change? no, this feature was just added and not release out yet. ### How was this patch tested? added tests ### Was this patch authored or co-authored using generative AI tooling? no Closes #46711 from zhengruifeng/tree_string_fix. Authored-by: Ruifeng Zheng <[email protected]> Signed-off-by: Ruifeng Zheng <[email protected]>
- Loading branch information
1 parent
e8f58a9
commit 14d3f44
Showing
2 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters