You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2024/04/20 18:34:40 UTC

[PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

pan3793 opened a new pull request, #5204:
URL: https://github.com/apache/hive/pull/5204

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
     2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
     3. Ensure you have added or run the appropriate tests for your PR: 
     4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX:  Your PR title ...'.
     5. Be sure to keep the PR description updated to reflect all changes.
     6. Please write your PR title to summarize what this PR proposes.
     7. If possible, provide a concise example to reproduce the issue for a faster review.
   
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   Port https://github.com/apache/hive/pull/5129 to branch-2.3
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   This is a follow-up of HIVE-26882, including correctness fixes for some RDBMS.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducable example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### Is the change a dependency upgrade?
   <!--
   If yes, please attach a file with output from mvn dependency:tree to validate a complete upgrade of dependency.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   UT


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5204:
URL: https://github.com/apache/hive/pull/5204#discussion_r2054512975


##########
metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -1964,4 +1964,13 @@ public List<SQLPrimaryKey> getPrimaryKeys(String db_name, String tbl_name) throw
     }
     return ret;
   }
+
+  long updateTableParam(Table table, String key, String expectedValue, String newValue) {
+    String queryText = String.format("UPDATE \"TABLE_PARAMS\" SET \"PARAM_VALUE\" = ? " +
+            "WHERE \"PARAM_KEY\" = ? AND \"PARAM_VALUE\" = ? AND \"TBL_ID\" IN " +

Review Comment:
   Just for reference, we hit performance issues in our production environment on executing this SQL. Changing the `IN` to `=` would solve this issue, at least for MySQL 5.7
   
   <img width="1204" alt="image" src="https://github.com/user-attachments/assets/642c8be4-18ec-457f-82fa-7aeaf93f421d" />
   <img width="1205" alt="image" src="https://github.com/user-attachments/assets/5c296295-1fdb-40aa-81d7-030ec2d148e6" />
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2073980462

   > that this is the current state of the tests on this branch
   
   Yes that's unfortunately the current state of branch-2.3. We do know a fixed set of tests are failing though and are using that as the baseline for testing against PRs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2073979665

   Thanks @pan3793 @lirui-apache and @pvary . It looks like this PR has more tests failing than the previous PR:
   
   <img width="473" alt="Screenshot 2024-04-23 at 8 57 41 PM" src="https://github.com/apache/hive/assets/506679/ddd8cf84-193c-4f7b-8b68-5e1248407972">
   
   In the previous PR: #4892, there were only 27 tests failing (normally there would only be 26 tests but 1 was flaky in that PR).
   
   Could you double check whether the test failures are related?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2074014828

   @sunchao based on the CI results of this PR branch, I think the failure tests should be flaky cases
   http://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/activity?branch=PR-5204


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5204:
URL: https://github.com/apache/hive/pull/5204#discussion_r1573368837


##########
metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -608,6 +608,33 @@ public boolean openTransaction(String isolationLevel) {
     return result;
   }
 
+  @Override
+  public long updateParameterWithExpectedValue(Table table, String key, String expectedValue, String newValue)
+      throws MetaException, NoSuchObjectException {
+    final Table _table = table;

Review Comment:
   this might be limitation of Java 7



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2094642723

   Sorry for the delay @pan3793 . I just sent out RC1.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2084405831

   @sunchao the failed tests are not caused by this patch, I opened another dummy PR based on the latest branch-2.3, and got the same failures https://github.com/apache/hive/pull/5225


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #5204:
URL: https://github.com/apache/hive/pull/5204#discussion_r2067739372


##########
metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -1964,4 +1964,13 @@ public List<SQLPrimaryKey> getPrimaryKeys(String db_name, String tbl_name) throw
     }
     return ret;
   }
+
+  long updateTableParam(Table table, String key, String expectedValue, String newValue) {
+    String queryText = String.format("UPDATE \"TABLE_PARAMS\" SET \"PARAM_VALUE\" = ? " +
+            "WHERE \"PARAM_KEY\" = ? AND \"PARAM_VALUE\" = ? AND \"TBL_ID\" IN " +

Review Comment:
   Yes, the Hive 4.0 doesn't have such an issue. This is just a tip for users who want to port this patch to their internal legacy Hive version (2.3 or 3.x)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2075428065

   OK, just re-triggered CI to confirm.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2081301602

   Hmm @pan3793 I tried the tests again for 2 times, and each time there were over 40 tests failing, which is quite more than the normal 26. Could you double-check whether there is anything we should fix here? Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2084420623

   oops, thanks @pan3793  - let me check the commits in branch-2.3 and see which commit caused the regression


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2071642313

   kindly ping @sunchao, are we good to go?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2084436105

   Merged, thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pvary (via GitHub)" <gi...@apache.org>.
pvary commented on code in PR #5204:
URL: https://github.com/apache/hive/pull/5204#discussion_r1574445728


##########
metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -608,6 +608,33 @@ public boolean openTransaction(String isolationLevel) {
     return result;
   }
 
+  @Override
+  public long updateParameterWithExpectedValue(Table table, String key, String expectedValue, String newValue)
+      throws MetaException, NoSuchObjectException {
+    final Table _table = table;

Review Comment:
   This is ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2094575223

   @sunchao can we have the next RC for 2.3.10?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "lirui-apache (via GitHub)" <gi...@apache.org>.
lirui-apache commented on code in PR #5204:
URL: https://github.com/apache/hive/pull/5204#discussion_r2065658158


##########
metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java:
##########
@@ -1964,4 +1964,13 @@ public List<SQLPrimaryKey> getPrimaryKeys(String db_name, String tbl_name) throw
     }
     return ret;
   }
+
+  long updateTableParam(Table table, String key, String expectedValue, String newValue) {
+    String queryText = String.format("UPDATE \"TABLE_PARAMS\" SET \"PARAM_VALUE\" = ? " +
+            "WHERE \"PARAM_KEY\" = ? AND \"PARAM_VALUE\" = ? AND \"TBL_ID\" IN " +

Review Comment:
   Thanks @pan3793 for reporting the issue. I agree it's better to use scalar subquery here. But since both 2.x and 3.x lines are EOL, and subquery is not used in 4.0, so I guess we won't have to do anything at the moment, right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #5204:
URL: https://github.com/apache/hive/pull/5204#issuecomment-2068803544

   @pvary Could you please take a look at this one? AFAIK it's the last one before the next RC for 2.3.10


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-28121. (2.3) Use direct SQL for transactional altering table parameter [hive]

Posted by "sunchao (via GitHub)" <gi...@apache.org>.
sunchao merged PR #5204:
URL: https://github.com/apache/hive/pull/5204


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org