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

    https://github.com/apache/spark/pull/2291#discussion_r17278691
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DataTypeSuite.scala 
---
    @@ -55,4 +55,38 @@ class DataTypeSuite extends FunSuite {
           struct(Set("b", "d", "e", "f"))
         }
       }
    +
    +  test("StructField.toString") {
    +    def structFieldWithName(name: String) = StructField(name, StringType, 
nullable = true)
    +
    +    assertResult("""StructField("a",StringType,true)""") {
    +      structFieldWithName("a").toString
    +    }
    +
    +    assertResult("""StructField("(a)",StringType,true)""") {
    +      structFieldWithName("(a)").toString
    +    }
    +
    +    assertResult("""StructField("a\\b\"",StringType,true)""") {
    +      structFieldWithName("""a\b"""").toString
    +    }
    +  }
    +
    +  test("parsing StructField string") {
    +    val expected = StructType(
    +      StructField("a", StringType, true) ::
    +      StructField("\"b\"", StringType, true) ::
    +      StructField("\"c\\", StringType, true) ::
    +      Nil)
    +
    +    val structTypeString = Seq(
    +      """StructType(List(""",
    +      """StructField("a",StringType,true),""",
    +      """StructField("\"b\"",StringType,true),""",
    +      """StructField("\"c\\",StringType,true)""",
    +      """))"""
    +    ).mkString
    +
    +    assert(catalyst.types.DataType(structTypeString) === expected)
    --- End diff --
    
    This is kind of a Nit, but I think I'd prefer tests that just roundtrip 
StructFields that have various weird characters instead of those that are 
dependent on the exact output.  That would test for the desired behavior but 
would not have to be rewritten if we ever change the format. (I mostly say this 
because I just spent the last hour rewriting brittle parquet tests :) )


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