Skip to content

Conversation

@yhuai
Copy link
Contributor

@yhuai yhuai commented Jun 19, 2016

What changes were proposed in this pull request?

This PR adds the static partition support to INSERT statement when the target table is a data source table.

How was this patch tested?

New tests in InsertIntoHiveTableSuite and DataSourceAnalysisSuite.

Note: This PR is based on #13766. The last commit is the actual change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can have another PR to change other exceptions in this node from SparkException to AnalysisException.

@yhuai
Copy link
Contributor Author

yhuai commented Jun 19, 2016

5315b80 is the actual change. Other commits are from #13766.

@SparkQA
Copy link

SparkQA commented Jun 19, 2016

Test build #60805 has finished for PR 13769 at commit 5315b80.

  • This patch fails Spark unit 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.

These are new tests.

@SparkQA
Copy link

SparkQA commented Jun 19, 2016

Test build #60812 has finished for PR 13769 at commit 7dc04af.

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

}
}

partitionList.sliding(2).foreach { v =>
Copy link
Contributor

Choose a reason for hiding this comment

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

sliding(2) can be dangerous for single-element collections:

scala> Seq(1).sliding(2).foreach(println)
List(1)

Copy link
Contributor

Choose a reason for hiding this comment

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

We can use the following check instead:

partitionList.dropWhile(_.isDefined).collectFirst {
  case Some(_) =>
    throw new AnalysisException("...")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!


// The sum of the number of static partition columns and columns provided in the SELECT
// clause needs to match the number of columns of the target table.
if (staticPartitions.size + sourceAttributes.size != targetAttributes.size) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we already have this check somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

in PreprocessTableInsertion

@SparkQA
Copy link

SparkQA commented Jun 20, 2016

Test build #60831 has finished for PR 13769 at commit 6bd7b6f.

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

class DataSourceAnalysisSuite extends SparkFunSuite with BeforeAndAfterAll {

private var targetAttributes: Seq[Attribute] = _
private var targetPartitionSchema: StructType = _
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these vars? Seems that they are immutable throughout this test suite.

@SparkQA
Copy link

SparkQA commented Jun 20, 2016

Test build #60833 has finished for PR 13769 at commit ba9c04c.

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

@liancheng
Copy link
Contributor

LGTM except for minor issues. I'm merging this to master and branch-2.0 first since this is an critical issue. We can address the comments later.

asfgit pushed a commit that referenced this pull request Jun 20, 2016
…to data source tables

## What changes were proposed in this pull request?
This PR adds the static partition support to INSERT statement when the target table is a data source table.

## How was this patch tested?
New tests in InsertIntoHiveTableSuite and DataSourceAnalysisSuite.

**Note: This PR is based on #13766. The last commit is the actual change.**

Author: Yin Huai <[email protected]>

Closes #13769 from yhuai/SPARK-16030-1.

(cherry picked from commit 905f774)
Signed-off-by: Cheng Lian <[email protected]>
@asfgit asfgit closed this in 905f774 Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants