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

    https://github.com/apache/spark/pull/999#discussion_r13518263
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/package.scala 
---
    @@ -17,8 +17,56 @@
     
     package org.apache.spark.sql.catalyst
     
    +import org.apache.spark.sql.catalyst.expressions.Attribute
    +import org.apache.spark.sql.catalyst.types.{StructField, DataType, 
ArrayType, StructType}
    +
     /**
      * A a collection of common abstractions for query plans as well as
      * a base logical plan representation.
      */
    -package object plans
    +package object plans {
    +  def generateSchemaTreeString(schema: Seq[Attribute]): String = {
    +    val builder = new StringBuilder
    +    builder.append("root\n")
    +    val prefix = " |"
    +    schema.foreach {
    +      attribute => {
    +        val name = attribute.name
    +        val dataType = attribute.dataType
    +        dataType match {
    +          case fields: StructType =>
    +            builder.append(s"$prefix-- $name: $StructType\n")
    +            generateSchemaTreeString(fields, s"$prefix    |", builder)
    +          case ArrayType(fields: StructType) =>
    +            builder.append(s"$prefix-- $name: $ArrayType[$StructType]\n")
    +            generateSchemaTreeString(fields, s"$prefix    |", builder)
    +          case ArrayType(elementType: DataType) =>
    +            builder.append(s"$prefix-- $name: $ArrayType[$elementType]\n")
    +          case _ => builder.append(s"$prefix-- $name: $dataType\n")
    +        }
    +      }
    +    }
    +
    +    builder.toString()
    +  }
    +
    +  def generateSchemaTreeString(
    --- End diff --
    
    mark this private?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to