Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ case class StructField(
/**
* Returns a string containing a schema in DDL format. For example, the following value:
* `StructField("eventId", IntegerType)` will be converted to `eventId` INT.
*
* @since 2.4.0
*/
def toDDL: String = {
val comment = getComment()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ case class StructType(fields: Array[StructField]) extends DataType with Seq[Stru
* `StructType(Seq(StructField("eventId", IntegerType), StructField("s", StringType)))`
* will be converted to `eventId` INT, `s` STRING.
* The returned DDL schema can be used in a table creation.
*
* @since 2.4.0
*/
def toDDL: String = fields.map(_.toDDL).mkString(",")

Expand Down Expand Up @@ -441,6 +443,8 @@ object StructType extends AbstractDataType {
/**
* Creates StructType for a given DDL-formatted string, which is a comma separated list of field
* definitions, e.g., a INT, b STRING.
*
* @since 2.2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gatorsmile, shouldn't it be a followup for SPARK-20009? Not a big deal anyway.

*/
def fromDDL(ddl: String): StructType = CatalystSqlParser.parseTableSchema(ddl)

Expand Down