Skip to content

HIVE-28352: Schematool fails to upgradeSchema on dbType=hive - #5324

Merged
deniskuzZ merged 2 commits into
apache:masterfrom
okumin:HIVE-28352-schema
Jun 28, 2024
Merged

HIVE-28352: Schematool fails to upgradeSchema on dbType=hive#5324
deniskuzZ merged 2 commits into
apache:masterfrom
okumin:HIVE-28352-schema

Conversation

@okumin

@okumin okumin commented Jun 27, 2024

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Make it possible to migrate the tables schemas in hive.sys.

https://issues.apache.org/jira/browse/HIVE-28352

Why are the changes needed?

The migration script doesn't succeed.

Does this PR introduce any user-facing change?

No. It is a bug fix and the current scripts never succeed for users.

Is the change a dependency upgrade?

No.

How was this patch tested?

I tested the migration from 3.0.0 to the 4.1.0.

schematool -metaDbType derby -dbType hive -initSchemaTo 3.0.0 -url jdbc:hive2://hive-hiveserver2:10000/default -driver org.apache.hive.jdbc.HiveDriver
schematool -metaDbType derby -dbType hive -upgradeSchema -url jdbc:hive2://hive-hiveserver2:10000/default -driver org.apache.hive.jdbc.HiveDriver

@@ -160,20 +160,20 @@ CREATE OR REPLACE VIEW `COMPACTIONS`
`C_TBLPROPERTIES`
) AS
SELECT

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The original DDL was invalid. I copied the non-upgrade DDL.

Error: Error while compiling statement: FAILED: SemanticException Schema of both sides of union should match. (state=42000,code=40000)
2024-06-27T02:42:12,201 ERROR [main] schematool.MetastoreSchemaTool: Upgrade FAILED! Metastore state would be inconsistent !!
Upgrade FAILED! Metastore state would be inconsistent !!
2024-06-27T02:42:12,201 ERROR [main] schematool.MetastoreSchemaTool: Underlying cause: java.io.IOException : Schema script failed, errorcode 2
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
2024-06-27T02:42:12,201 ERROR [main] schematool.MetastoreSchemaTool: Use --verbose for detailed stacktrace.
Use --verbose for detailed stacktrace.
2024-06-27T02:42:12,201 ERROR [main] schematool.MetastoreSchemaTool: *** schemaTool failed ***
*** schemaTool failed ***

DROP TABLE IF EXISTS `VERSION`;

CREATE OR REPLACE VIEW `VERSION` AS SELECT 1 AS `VER_ID`, '4.1.0' AS `SCHEMA_VERSION`,
'Hive release version 4.1.0' AS `VERSION_COMMENT`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to upgrade this definition. Otherwise, the final validation fails.

Completed upgrade-4.0.0-to-4.1.0.hive.sql
2024-06-27T03:05:43,358 ERROR [main] schematool.MetastoreSchemaTool: Metastore schema version is not compatible. Hive Version: 4.1.0, Database Schema Version: 4.0.0-alpha-1
Metastore schema version is not compatible. Hive Version: 4.1.0, Database Schema Version: 4.0.0-alpha-1
2024-06-27T03:05:43,358 ERROR [main] schematool.MetastoreSchemaTool: Use --verbose for detailed stacktrace.
Use --verbose for detailed stacktrace.
2024-06-27T03:05:43,358 ERROR [main] schematool.MetastoreSchemaTool: *** schemaTool failed ***

@deniskuzZ deniskuzZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, thanks @okumin!

@sonarqubecloud

Copy link
Copy Markdown

@deniskuzZ
deniskuzZ merged commit 7f6367e into apache:master Jun 28, 2024
@okumin
okumin deleted the HIVE-28352-schema branch June 28, 2024 11:40
@okumin

okumin commented Jun 28, 2024

Copy link
Copy Markdown
Contributor Author

Thank you, both, for your reviews

dengzhhu653 pushed a commit to dengzhhu653/hive that referenced this pull request Jul 18, 2024
…Okumiya, reviewed by Zhihua Deng, Denys Kuzmenko)

Closes apache#5324
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