Github user maropu commented on a diff in the pull request: https://github.com/apache/spark/pull/21803#discussion_r203584039 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala --- @@ -436,6 +436,14 @@ object StructType extends AbstractDataType { */ def fromDDL(ddl: String): StructType = CatalystSqlParser.parseTableSchema(ddl) + /** + * Converts a value of StructType to a string in DDL format. For example: + * `StructType(Seq(StructField("a", IntegerType)))` should be converted to `a int` + */ + def toDDL(struct: StructType): String = { + struct.map(field => s"${quoteIdentifier(field.name)} ${field.dataType.sql}").mkString(",") --- End diff -- Can this also handle the special character ('\n', '\t', '\', ...) that needs an escape?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org