Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17406#discussion_r107969140
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala ---
    @@ -169,30 +169,43 @@ class DataTypeSuite extends SparkFunSuite {
         assert(!arrayType.existsRecursively(_.isInstanceOf[IntegerType]))
       }
     
    -  def checkDataTypeJsonRepr(dataType: DataType): Unit = {
    -    test(s"JSON - $dataType") {
    +  // Test json formats only for the types that DDL formats do not support
    +  def checkDataTypeFromJson(dataType: DataType): Unit = {
    +    test(s"from json - $dataType") {
           assert(DataType.fromJson(dataType.json) === dataType)
         }
       }
     
    -  checkDataTypeJsonRepr(NullType)
    -  checkDataTypeJsonRepr(BooleanType)
    -  checkDataTypeJsonRepr(ByteType)
    -  checkDataTypeJsonRepr(ShortType)
    -  checkDataTypeJsonRepr(IntegerType)
    -  checkDataTypeJsonRepr(LongType)
    -  checkDataTypeJsonRepr(FloatType)
    -  checkDataTypeJsonRepr(DoubleType)
    -  checkDataTypeJsonRepr(DecimalType(10, 5))
    -  checkDataTypeJsonRepr(DecimalType.SYSTEM_DEFAULT)
    -  checkDataTypeJsonRepr(DateType)
    -  checkDataTypeJsonRepr(TimestampType)
    -  checkDataTypeJsonRepr(StringType)
    -  checkDataTypeJsonRepr(BinaryType)
    -  checkDataTypeJsonRepr(ArrayType(DoubleType, true))
    -  checkDataTypeJsonRepr(ArrayType(StringType, false))
    -  checkDataTypeJsonRepr(MapType(IntegerType, StringType, true))
    -  checkDataTypeJsonRepr(MapType(IntegerType, ArrayType(DoubleType), false))
    +  def checkDataTypeFromText(dataType: DataType): Unit = {
    +    checkDataTypeFromJson(dataType)
    +
    +    // Test DDL formats
    +    test(s"from ddl - $dataType") {
    +      assert(DataType.fromDdl(s"a ${dataType.sql}") === new 
StructType().add("a", dataType))
    +    }
    --- End diff --
    
    How about defining a function like `checkDataTypeFromJson `? It looks more 
consistent, if so.


---
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]

Reply via email to