Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/17435#discussion_r108103801
--- Diff: python/pyspark/sql/types.py ---
@@ -57,7 +57,25 @@ def __ne__(self, other):
@classmethod
def typeName(cls):
- return cls.__name__[:-4].lower()
+ typeTypeNameMap = {"DataType": "data",
+ "NullType": "null",
+ "StringType": "string",
+ "BinaryType": "binary",
+ "BooleanType": "boolean",
+ "DateType": "date",
+ "TimestampType": "timestamp",
+ "DecimalType": "decimal",
+ "DoubleType": "double",
+ "FloatType": "float",
+ "ByteType": "byte",
+ "IntegerType": "integer",
+ "LongType": "long",
+ "ShortType": "short",
+ "ArrayType": "array",
+ "MapType": "map",
+ "StructField": "struct",
--- End diff --
It is valid call for `DataType`s but I don't think it is against
`StructField`. If you look at the Scala-side codes, `StructField` is not a
`DataType` but it seems the parent became `DataType` in Python for some reason
in the PR I pointed out. In any way, It seems ["`A field inside a
StructType`"](https://github.com/apache/spark/blob/3694ba48f0db0f47baea4b005cdeef3f454b7329/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructField.scala#L26).
If you want to know the schema, you could simply
```python
>>> spark.range(1).schema[0].simpleString()
'id:bigint'
>>> spark.range(1).schema.simpleString()
'struct<id:bigint>'
```
Could you elaborate your use-case and why `simpleString` is not enough?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]