You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/01/27 11:39:59 UTC

[GitHub] [hive] asolimando opened a new pull request #2979: HIVE-25905 nulls last property ignored

asolimando opened a new pull request #2979:
URL: https://github.com/apache/hive/pull/2979


   <!--
   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.
   -->
   
   
   ### 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.
   -->
   
   
   ### 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'.
   -->
   
   
   ### 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.
   -->
   


-- 
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


[GitHub] [hive] asolimando commented on a change in pull request #2979: HIVE-25909 add test for nulls last property in windows

Posted by GitBox <gi...@apache.org>.
asolimando commented on a change in pull request #2979:
URL: https://github.com/apache/hive/pull/2979#discussion_r795879275



##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);
+
+-- hive.default.nulls.last is true by default, it sets NULLS_FIRST for DESC
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;

Review comment:
       To verify the final behaviour yes, the explains are mostly useful to see immediately if the problem happens in the parser (`EXPLAIN AST`) or later on during query planning or at translation time (`EXPLAIN`).
   
   Finally, also execution time could break the property, in that case you would have both explains as expected but wrong results.
   
   I think it will save a lot of investigation time to keep all of them, if something will break, but I am good with removing some if you think it's best.




-- 
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


[GitHub] [hive] zabetak closed pull request #2979: HIVE-25909 add test for nulls last property in windows

Posted by GitBox <gi...@apache.org>.
zabetak closed pull request #2979:
URL: https://github.com/apache/hive/pull/2979


   


-- 
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


[GitHub] [hive] zabetak commented on a change in pull request #2979: HIVE-25909 add test for nulls last property in windows

Posted by GitBox <gi...@apache.org>.
zabetak commented on a change in pull request #2979:
URL: https://github.com/apache/hive/pull/2979#discussion_r795840746



##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);

Review comment:
       I suppose the example can be simplified a bit by: 
   
   1. picking more user-friendly names/types; 
   2. using fewer rows; 
   
   ```
   create table person (name string, country string, age int);
   insert into person values 
   ('John Doe', 'France', 20),
   ('Alex Dum', 'France', 24),
   ('Victor Hug', 'France', null);
   ```

##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);
+
+-- hive.default.nulls.last is true by default, it sets NULLS_FIRST for DESC
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+-- we set hive.default.nulls.last=false, it sets NULLS_LAST for DESC
+set hive.default.nulls.last=false;
+
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+-- we set hive.default.nulls.last=false but we have explicit NULLS_LAST, we expect NULLS_LAST
+set hive.default.nulls.last=false;

Review comment:
       Do we need to reset the property if it is already done above?

##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);
+
+-- hive.default.nulls.last is true by default, it sets NULLS_FIRST for DESC
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;

Review comment:
       Do we need the explain statements? Aren't the results enough to guarantee that the behavior is the expected one?
   If we need the explains do we need multiple?

##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);
+
+-- hive.default.nulls.last is true by default, it sets NULLS_FIRST for DESC

Review comment:
       Better set the property explicitly and not rely on defaults. We mostly want to test the behavior of the property not the defaults which I guess are covered by other places.

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
##########
@@ -863,7 +863,7 @@ import org.apache.hadoop.hive.conf.HiveConf;
   }
   protected boolean nullsLast() {
     if(hiveConf == null){
-      return false;
+      return HiveConf.ConfVars.HIVE_DEFAULT_NULLS_LAST.defaultBoolVal;

Review comment:
       Good idea, on keeping this change as separate commit but let's also give it a unique JIRA id since I don't see any change landing in Hive without a JIRA reference. 




-- 
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


[GitHub] [hive] asolimando commented on a change in pull request #2979: HIVE-25909 add test for nulls last property in windows

Posted by GitBox <gi...@apache.org>.
asolimando commented on a change in pull request #2979:
URL: https://github.com/apache/hive/pull/2979#discussion_r795880229



##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);
+
+-- hive.default.nulls.last is true by default, it sets NULLS_FIRST for DESC
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+-- we set hive.default.nulls.last=false, it sets NULLS_LAST for DESC
+set hive.default.nulls.last=false;
+
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+-- we set hive.default.nulls.last=false but we have explicit NULLS_LAST, we expect NULLS_LAST
+set hive.default.nulls.last=false;

Review comment:
       It's mostly for clarity since there is a bit of text in between, it will also be useful in case they get re-ordered or modified, but I am fine with removing it if you prefer.




-- 
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


[GitHub] [hive] asolimando commented on a change in pull request #2979: HIVE-25909 add test for nulls last property in windows

Posted by GitBox <gi...@apache.org>.
asolimando commented on a change in pull request #2979:
URL: https://github.com/apache/hive/pull/2979#discussion_r795875749



##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
##########
@@ -863,7 +863,7 @@ import org.apache.hadoop.hive.conf.HiveConf;
   }
   protected boolean nullsLast() {
     if(hiveConf == null){
-      return false;
+      return HiveConf.ConfVars.HIVE_DEFAULT_NULLS_LAST.defaultBoolVal;

Review comment:
       Sure, I have opened a separate PR with a new JIRA ticket: https://github.com/apache/hive/pull/2990




-- 
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


[GitHub] [hive] zabetak commented on a change in pull request #2979: HIVE-25909 add test for nulls last property in windows

Posted by GitBox <gi...@apache.org>.
zabetak commented on a change in pull request #2979:
URL: https://github.com/apache/hive/pull/2979#discussion_r796076167



##########
File path: ql/src/test/queries/clientpositive/order_null2.q
##########
@@ -0,0 +1,70 @@
+create table test1
+(
+  a string,
+  b timestamp,
+  c timestamp
+);
+
+INSERT INTO TABLE test1 VALUES
+('John Doe', '1990-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1990-05-10 00:00:00.0', '2021-09-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2022-01-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-12-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-11-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', '2021-10-10 00:00:00.0'),
+('John Doe', '1987-05-10 00:00:00.0', null);
+
+-- hive.default.nulls.last is true by default, it sets NULLS_FIRST for DESC
+EXPLAIN AST
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+EXPLAIN
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;
+
+SELECT a, b, c, row_number() OVER (PARTITION BY a, b ORDER BY b DESC, c DESC)
+FROM test1;

Review comment:
       I trust your judgement let's leave it as is.




-- 
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