Skip to content

Conversation

@wangyum
Copy link
Member

@wangyum wangyum commented May 13, 2019

What changes were proposed in this pull request?

We should remove materialized view first otherwise(note that Hive 3.1 could reproduce this issue):

Cause: org.apache.derby.shared.common.error.DerbySQLIntegrityConstraintViolationException: DELETE on table 'TBLS' caused a violation of foreign key constraint 'MV_TABLES_USED_FK2' for key (4).  The statement has been rolled back.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeBatchElement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeLargeBatch(Unknown Source)

How was this patch tested?

Existing test

@SparkQA
Copy link

SparkQA commented May 13, 2019

Test build #105361 has finished for PR 24592 at commit 6ee5b7a.

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

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-27690][SQL] Refactor HiveClientImpl#reset() to remove materialized view first [SPARK-27690][SQL] Remove materialized view first in HiveClientImpl.reset May 13, 2019
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-27690][SQL] Remove materialized view first in HiveClientImpl.reset [SPARK-27690][SQL] Remove materialized views first in HiveClientImpl.reset May 13, 2019
@dongjoon-hyun
Copy link
Member

Thank you for updating, @wangyum !

@SparkQA
Copy link

SparkQA commented May 13, 2019

Test build #105368 has finished for PR 24592 at commit 953194d.

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

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM. Merged to master. Thank you, @wangyum .
cc @gatorsmile .

val (mvs, others) = allTables.asScala.map(t => client.getTable("default", t))
.partition(_.getTableType.toString.equals("MATERIALIZED_VIEW"))

// Remove materialized view first, otherwise caused a violation of foreign key constraint.
Copy link
Member

Choose a reason for hiding this comment

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

Do we have the same issue for Hive indexes? Also, we normally also added a test case in the Version Suite. You can do it by using the method runSqlHive(sql: String) to create materialized views.

Copy link
Member Author

Choose a reason for hiding this comment

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

Test in another PR: #23992

Copy link
Member Author

Choose a reason for hiding this comment

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

This issue only occurs with materialized views in Hive 3.1.
I have tested the index and the view.

@wangyum wangyum deleted the SPARK-27690 branch May 16, 2019 13:01
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.

4 participants