[GitHub] spark pull request #14709: [SPARK-17150][SQL] Support SQL generation for inl...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/14709 --- 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. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14709: [SPARK-17150][SQL] Support SQL generation for inl...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14709#discussion_r75440152 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LocalRelation.scala --- @@ -75,4 +76,16 @@ case class LocalRelation(output: Seq[Attribute], data: Seq[InternalRow] = Nil) override lazy val statistics = Statistics(sizeInBytes = output.map(_.dataType.defaultSize).sum * data.length) + + def toSQL(inlineTableName: String): String = { +require(data.nonEmpty) +val types = schema.fields.map(_.dataType) +val rows = data.map { row => + val cells = row.toSeq(types).zip(types).map { case (v, tpe) => Literal(v, tpe).sql } + cells.mkString("(", ", ", ")") +} +"VALUES " + rows.mkString(", ") + + " AS " + inlineTableName + + schema.fields.map(_.name).mkString("(", ", ", ")") --- End diff -- nit: `output.map(_.name)` --- 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. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14709: [SPARK-17150][SQL] Support SQL generation for inl...
Github user cloud-fan commented on a diff in the pull request: https://github.com/apache/spark/pull/14709#discussion_r75440135 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LocalRelation.scala --- @@ -75,4 +76,16 @@ case class LocalRelation(output: Seq[Attribute], data: Seq[InternalRow] = Nil) override lazy val statistics = Statistics(sizeInBytes = output.map(_.dataType.defaultSize).sum * data.length) + + def toSQL(inlineTableName: String): String = { +require(data.nonEmpty) +val types = schema.fields.map(_.dataType) --- End diff -- nit: `output.map(_.dataType)` --- 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. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #14709: [SPARK-17150][SQL] Support SQL generation for inl...
GitHub user petermaxlee opened a pull request: https://github.com/apache/spark/pull/14709 [SPARK-17150][SQL] Support SQL generation for inline tables ## What changes were proposed in this pull request? This patch adds support for SQL generation for inline tables. With this, it would be possible to create a view that depends on inline tables. ## How was this patch tested? Added a test case in LogicalPlanToSQLSuite. You can merge this pull request into a Git repository by running: $ git pull https://github.com/petermaxlee/spark SPARK-17150 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/14709.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #14709 commit a32cbc2eb418cd320978c4c8bce9e8240e1b165f Author: petermaxleeDate: 2016-08-19T04:10:17Z [SPARK-17150][SQL] Support SQL generation for inline tables --- 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. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org