-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-27108][SQL] Add parsed SQL plans for create, CTAS. #24029
Closed
rdblue
wants to merge
12
commits into
apache:master
from
rdblue:SPARK-27108-add-parsed-create-logical-plans
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aedce48
SPARK-27108: Add parsed SQL plans for create, CTAS.
rdblue 4a89dd7
Update for review comments.
rdblue 69f9a29
Move new DataSource resolution rules into DataSourceResolution.
rdblue e676095
Fix CreateTableAsSelect conversion to CatalogTable.
rdblue 32551be
Apply the v1 source writer list.
rdblue 64c1f01
Fix V1WriteProvider extraction for Hive sources.
rdblue f3fab1c
Fix v1 override check to handle case sensitivity.
rdblue 62ccd4d
Fix DDLParserSuite.
rdblue e3444d8
Fix password redaction tests.
rdblue 0594a82
Move another test into catalyst DDLParserSuite.
rdblue e0eebd0
Fix redaction matcher for type erasure.
rdblue 6c9b9dc
Add Statement suffix to new parsed plans.
rdblue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/CreateTableStatement.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.catalyst.plans.logical.sql | ||
|
||
import org.apache.spark.sql.catalyst.TableIdentifier | ||
import org.apache.spark.sql.catalyst.catalog.BucketSpec | ||
import org.apache.spark.sql.catalyst.expressions.Attribute | ||
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
import org.apache.spark.sql.types.StructType | ||
|
||
/** | ||
* A CREATE TABLE command, as parsed from SQL. | ||
* | ||
* This is a metadata-only command and is not used to write data to the created table. | ||
*/ | ||
case class CreateTableStatement( | ||
table: TableIdentifier, | ||
tableSchema: StructType, | ||
partitioning: Seq[String], | ||
bucketSpec: Option[BucketSpec], | ||
properties: Map[String, String], | ||
provider: String, | ||
options: Map[String, String], | ||
location: Option[String], | ||
comment: Option[String], | ||
ifNotExists: Boolean) extends ParsedStatement { | ||
|
||
override def output: Seq[Attribute] = Seq.empty | ||
|
||
override def children: Seq[LogicalPlan] = Seq.empty | ||
} | ||
|
||
/** | ||
* A CREATE TABLE AS SELECT command, as parsed from SQL. | ||
*/ | ||
case class CreateTableAsSelectStatement( | ||
table: TableIdentifier, | ||
asSelect: LogicalPlan, | ||
partitioning: Seq[String], | ||
bucketSpec: Option[BucketSpec], | ||
properties: Map[String, String], | ||
provider: String, | ||
options: Map[String, String], | ||
location: Option[String], | ||
comment: Option[String], | ||
ifNotExists: Boolean) extends ParsedStatement { | ||
|
||
override def output: Seq[Attribute] = Seq.empty | ||
|
||
override def children: Seq[LogicalPlan] = Seq(asSelect) | ||
} |
44 changes: 44 additions & 0 deletions
44
...lyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/ParsedStatement.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.sql.catalyst.plans.logical.sql | ||
|
||
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
|
||
/** | ||
* A logical plan node that contains exactly what was parsed from SQL. | ||
* | ||
* This is used to hold information parsed from SQL when there are multiple implementations of a | ||
* query or command. For example, CREATE TABLE may be implemented by different nodes for v1 and v2. | ||
* Instead of parsing directly to a v1 CreateTable that keeps metadata in CatalogTable, and then | ||
* converting that v1 metadata to the v2 equivalent, the sql [[CreateTableStatement]] plan is | ||
* produced by the parser and converted once into both implementations. | ||
* | ||
* Parsed logical plans are not resolved because they must be converted to concrete logical plans. | ||
* | ||
* Parsed logical plans are located in Catalyst so that as much SQL parsing logic as possible is be | ||
* kept in a [[org.apache.spark.sql.catalyst.parser.AbstractSqlParser]]. | ||
*/ | ||
private[sql] abstract class ParsedStatement extends LogicalPlan { | ||
// Redact properties and options when parsed nodes are used by generic methods like toString | ||
override def productIterator: Iterator[Any] = super.productIterator.map { | ||
case mapArg: Map[_, _] => conf.redactOptions(mapArg.asInstanceOf[Map[String, String]]) | ||
case other => other | ||
} | ||
|
||
final override lazy val resolved = false | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't review this file carefully, assuming it's just copy-paste code from
SparkSqlAstBuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is moving what is needed from
SparkSqlAstBuilder
. The only real changes are in thevisitCreateTable
method.These rules should have already been in the abstract class. I'm not sure why they were in
SparkSqlAstBuilder
other than that was the easiest place to put them when they were added.