You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2018/09/10 11:18:10 UTC
spark git commit: [SPARK-24849][SPARK-24911][SQL][FOLLOW-UP]
Converting a value of StructType to a DDL string
Repository: spark
Updated Branches:
refs/heads/master e7853dc10 -> 6f6517837
[SPARK-24849][SPARK-24911][SQL][FOLLOW-UP] Converting a value of StructType to a DDL string
## What changes were proposed in this pull request?
Add the version number for the new APIs.
## How was this patch tested?
N/A
Closes #22377 from gatorsmile/followup24849.
Authored-by: gatorsmile <ga...@gmail.com>
Signed-off-by: Wenchen Fan <we...@databricks.com>
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/6f651783
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/6f651783
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/6f651783
Branch: refs/heads/master
Commit: 6f6517837ba9934a280b11aba9d9be58bc131f25
Parents: e7853dc
Author: gatorsmile <ga...@gmail.com>
Authored: Mon Sep 10 19:18:00 2018 +0800
Committer: Wenchen Fan <we...@databricks.com>
Committed: Mon Sep 10 19:18:00 2018 +0800
----------------------------------------------------------------------
.../src/main/scala/org/apache/spark/sql/types/StructField.scala | 2 ++
.../src/main/scala/org/apache/spark/sql/types/StructType.scala | 4 ++++
2 files changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/6f651783/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructField.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructField.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructField.scala
index 902cae9..35f9970 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructField.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructField.scala
@@ -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()
http://git-wip-us.apache.org/repos/asf/spark/blob/6f651783/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
index c5ca169..06289b1 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/types/StructType.scala
@@ -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(",")
@@ -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
*/
def fromDDL(ddl: String): StructType = CatalystSqlParser.parseTableSchema(ddl)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org