Skip to content

[SPARK-28178][SQL] DataSourceV2: DataFrameWriter.insertInfo - #24980

Closed
jzhuge wants to merge 2 commits into
apache:masterfrom
jzhuge:SPARK-28178-pr
Closed

[SPARK-28178][SQL] DataSourceV2: DataFrameWriter.insertInfo#24980
jzhuge wants to merge 2 commits into
apache:masterfrom
jzhuge:SPARK-28178-pr

Conversation

@jzhuge

@jzhugejzhuge commented Jun 27, 2019

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Support multiple catalogs in the following InsertInto use cases:

  • DataFrameWriter.insertInto("catalog.db.tbl")

Support matrix:

SaveModePartitioned TablePartition Overwrite ModeAction
Append**AppendData
Overwriteno*OverwriteByExpression(true)
OverwriteyesSTATICOverwriteByExpression(true)
OverwriteyesDYNAMICOverwritePartitionsDynamic

How was this patch tested?

New tests.
All existing catalyst and sql/core tests.

@SparkQA

Copy link
Copy Markdown

Test build #106958 has finished for PR 24980 at commit 9de941e.

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

@SparkQA

Copy link
Copy Markdown

Test build #106971 has finished for PR 24980 at commit 34cd710.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #106972 has finished for PR 24980 at commit eaf2336.

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

@SparkQA

Copy link
Copy Markdown

Test build #107140 has finished for PR 24980 at commit fb45cb1.

  • This patch fails SparkR unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • class KafkaTable extends Table with SupportsRead with SupportsWrite
  • public final class ColumnarBatch implements AutoCloseable
  • case class DummyExpressionHolder(exprs: Seq[Expression]) extends LeafNode
  • abstract class QuaternaryExpression extends Expression
  • case class CheckOverflow(
  • case class Overlay(input: Expression, replace: Expression, pos: Expression, len: Expression)
  • case class MapPartitionsInPandas(
  • class ColumnarRule
  • case class ColumnarToRowExec(child: SparkPlan)
  • case class RowToColumnarExec(child: SparkPlan) extends UnaryExecNode
  • case class ApplyColumnarRulesAndInsertTransitions(conf: SQLConf, columnarRules: Seq[ColumnarRule])
  • case class InputAdapter(child: SparkPlan, isChildColumnar: Boolean)
  • case class MapPartitionsInPandasExec(

@SparkQA

Copy link
Copy Markdown

Test build #107143 has finished for PR 24980 at commit 3c3aa04.

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

@dongjoon-hyun

Copy link
Copy Markdown
Member

Retest this please.

@SparkQA

Copy link
Copy Markdown

Test build #107313 has finished for PR 24980 at commit 3c3aa04.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA

Copy link
Copy Markdown

Test build #108235 has finished for PR 24980 at commit 65a0d43.

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

@jzhuge

Copy link
Copy Markdown
MemberAuthor

@dongjoon-hyun@brkyvz@cloud-fan@rdblue This PR is ready for review. It is a follow-up to DSv2 INSERT INTO.


assertNotBucketed("insertInto")

if (partitioningColumns.isDefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shall we move these 2 checks to the public insertTo method, instead of duplicating it in the 2 private methods?

}
}

test("insertInto: append partitioned table - dynamic clause") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what do you mean by dynamic clause?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

This is a copy-paste issue. I will remove " - dynamic clause" from the title. insertInto does not have anything similar to INSERT INTO's PARTITION clause.

@SparkQA

Copy link
Copy Markdown

Test build #108338 has finished for PR 24980 at commit c4eeee5.

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

@cloud-fan

Copy link
Copy Markdown
Contributor

thanks, merging to master!

@jzhuge

Copy link
Copy Markdown
MemberAuthor

Thanks @cloud-fan !


val command = modeForDSV2 match {
case SaveMode.Append =>
AppendData.byName(table, df.logicalPlan)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I missed it. If you look at the doc of insertInto, it says

 * Inserts the content of the `DataFrame` to the specified table. It requires that
* the schema of the `DataFrame` is the same as the schema of the table.
*
* @note Unlike `saveAsTable`, `insertInto` ignores the column names and just uses position-based
* resolution. For example:

We should use byPosition here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed. This is an oversight and should be by position.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Thanks @cloud-fan@rdblue. I will submit a hotfix.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I can create a follow-up PR to introduce an option matchByName, default to false. If true, insertInto uses byName; otherwise, byPosition.

Maybe even included in this PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we are going to create a new dataframe writer API in the future, I'd like to keep it as it is, and always do by-position in this insertInto.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we are going to create a new dataframe writer API in the future, I'd like to keep it as it is, and always do by-position in this insertInto.

Sounds good to me. I'll submit a PR for the new API.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jzhuge@SparkQA@dongjoon-hyun@cloud-fan@rdblue