Skip to content

Conversation

@huaxingao
Copy link
Contributor

@huaxingao huaxingao commented Sep 21, 2021

What changes were proposed in this pull request?

Migrate CreateTableStatement to v2 command framework

Why are the changes needed?

Migrate to the standard V2 framework

Does this PR introduce any user-facing change?

no

How was this patch tested?

existing tests

@SparkQA
Copy link

SparkQA commented Sep 21, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47988/

@SparkQA
Copy link

SparkQA commented Sep 21, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47988/

@SparkQA
Copy link

SparkQA commented Sep 21, 2021

Test build #143477 has finished for PR 34060 at commit 1965f77.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only temporary and will be removed after CreateTableAsSelect, ReplaceTable and ReplaceTableAsSelect are migrated to v2 command framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

V2CreateTablePlan can't be deleted yet because it is also extended by CreateTableAsSelect, ReplaceTable and ReplaceTableAsSelect. I use V2CreateTablePlanX for this new trait for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to add this? Can we let the new CreateTable extends V2CreateTablePlan and implement tableName?

def tableName = {
  assert(name.isResolved)
  name.asInstanceOf[ResolvedDBObjectName].nameParts.asIdentifier
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original case create: V2CreateTablePlan will be removed and this will be changed to
case create: V2CreateTablePlan after the migration of CreateTableAsSelect, ReplaceTable and ReplaceTableAsSelect is done.

@huaxingao huaxingao changed the title [WIP] Migrate CreateTableStatement to v2 command framework [SPARK-36850][SQL][WIP] Migrate CreateTableStatement to v2 command framework Sep 25, 2021
@huaxingao huaxingao marked this pull request as ready for review September 28, 2021 02:44
@huaxingao huaxingao changed the title [SPARK-36850][SQL][WIP] Migrate CreateTableStatement to v2 command framework [SPARK-36850][SQL] Migrate CreateTableStatement to v2 command framework Sep 28, 2021
@SparkQA
Copy link

SparkQA commented Sep 28, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48179/

@SparkQA
Copy link

SparkQA commented Sep 28, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48179/

@SparkQA
Copy link

SparkQA commented Sep 28, 2021

Test build #143667 has finished for PR 34060 at commit 9e42d67.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@huaxingao huaxingao marked this pull request as draft September 29, 2021 00:21
@SparkQA
Copy link

SparkQA commented Oct 6, 2021

Test build #143889 has started for PR 34060 at commit 0af17cd.

@SparkQA
Copy link

SparkQA commented Oct 6, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48401/

@SparkQA
Copy link

SparkQA commented Oct 6, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48401/

@huaxingao huaxingao marked this pull request as ready for review October 6, 2021 23:22
@SparkQA
Copy link

SparkQA commented Oct 15, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48759/

@SparkQA
Copy link

SparkQA commented Oct 15, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48759/

@SparkQA
Copy link

SparkQA commented Oct 15, 2021

Test build #144280 has finished for PR 34060 at commit e146c17.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dchvn
Copy link
Contributor

dchvn commented Nov 16, 2021

Hi @huaxingao , any update? I am trying to migrate ReplaceTableStatement and CreateTableAsSelectStatement by learn from your PR

@huaxingao
Copy link
Contributor Author

@dchvn Sorry for the late reply. I will work on this now.

@SparkQA
Copy link

SparkQA commented Nov 17, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49817/

@SparkQA
Copy link

SparkQA commented Nov 17, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49817/

@SparkQA
Copy link

SparkQA commented Nov 26, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50131/

@SparkQA
Copy link

SparkQA commented Nov 26, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50131/

@SparkQA
Copy link

SparkQA commented Nov 26, 2021

Test build #145661 has finished for PR 34060 at commit 39320f4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

redactMapString(map, maxFields)
case t: TableSpec =>
redactMapString(t.options, maxFields)
redactMapString(t.properties, maxFields)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to return a copy of TableSpec with options and properties redacted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I didn't get this right. Fixed.

import org.apache.spark.sql.catalyst.expressions.objects.StaticInvoke
import org.apache.spark.sql.catalyst.parser.{CatalystSqlParser, ParseException}
import org.apache.spark.sql.catalyst.plans.logical.{AlterColumn, AnalysisOnlyCommand, AppendData, Assignment, CreateTableAsSelect, CreateTableStatement, CreateV2Table, DeleteAction, DeleteFromTable, DescribeRelation, DropTable, InsertAction, LocalRelation, LogicalPlan, MergeIntoTable, OneRowRelation, Project, SetTableLocation, SetTableProperties, ShowTableProperties, SubqueryAlias, UnsetTableProperties, UpdateAction, UpdateTable}
import org.apache.spark.sql.catalyst.plans.logical.{AlterColumn, AnalysisOnlyCommand, AppendData, Assignment, CreateTable => CatalystCreateTable, CreateTableAsSelect, DeleteAction, DeleteFromTable, DescribeRelation, DropTable, InsertAction, LocalRelation, LogicalPlan, MergeIntoTable, OneRowRelation, Project, SetTableLocation, SetTableProperties, ShowTableProperties, SubqueryAlias, UnsetTableProperties, UpdateAction, UpdateTable}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we change import org.apache.spark.sql.execution.datasources.CreateTable to import org.apache.spark.sql.execution.datasources.CreateTableV1 and keep the CreateTable here unchanged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@SparkQA
Copy link

SparkQA commented Nov 29, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50203/

@SparkQA
Copy link

SparkQA commented Nov 30, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/50203/

@SparkQA
Copy link

SparkQA commented Nov 30, 2021

Test build #145733 has finished for PR 34060 at commit 8fdf059.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 98b0c80 Nov 30, 2021
@huaxingao
Copy link
Contributor Author

Thanks!

originalMultipartIdentifier,
df.schema.asNullable,
partitioningColumns.getOrElse(Nil).asTransforms.toSeq,
val tableProperties = TableSpec(
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: this should be tableSpec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will have a follow up to fix this.

cloud-fan pushed a commit that referenced this pull request Dec 13, 2021
…ndition for CTAS and RTAS

### What changes were proposed in this pull request?
fixed a few problems:
1. addressed this [comment](#34060 (comment))
2. combined several `xxxOnlySupportedWithV2TableError`
3. in CTAS and RTAS, the `if isSessionCatalog(catalog)` should not be on the pattern, it should be `if (isSessionCatalog(catalog) && !isV2Provider(provider))`. Otherwise, `c.partitioning ++ c.tableSpec.bucketSpec.map(_.asTransform)` is not done for non SessionCatalog case.
I tried this  `c.partitioning ++ c.tableSpec.bucketSpec.map(_.asTransform)` inside `AstBuilder` but it failed [here]( https://github.com/apache/spark/blob/master/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala#L850) so I kept this in `ResolveSessionCatalog`

### Why are the changes needed?
code cleaning up and bug fixing

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Existing tests

Closes #34857 from huaxingao/followup.

Lead-authored-by: Huaxin Gao <[email protected]>
Co-authored-by: Huaxin Gao <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants