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 2021/03/02 13:00:37 UTC

[GitHub] [hive] ujc714 opened a new pull request #2034: HIVE-24839: SubStrStatEstimator.estimate throws NullPointerException

ujc714 opened a new pull request #2034:
URL: https://github.com/apache/hive/pull/2034


   ### What changes were proposed in this pull request?
   It fixes a bug in UDFSubstr.SubStrStatEstimator. 
   
   ### Why are the changes needed?
   The method getRangeWidth didn't check if range is null before it references the properties of range. When Hive estimates the stats on a substr function with a child UDF, the compilation might fail due to NullPointerException.
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Start MiniHS2Cluster then run the following queries manually:
   ```
   create table t0 (s string);
   create table t1 (s string, i int);
   insert into t0 select "abc";
   insert into t1 select "abc", 4;
   select substr(t0.s, t1.i-1) from t0 join t1 on t0.s=t1.s;
   ```
   


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

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] kgyrtkirk commented on a change in pull request #2034: HIVE-24839: SubStrStatEstimator.estimate throws NullPointerException

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java
##########
@@ -174,8 +174,10 @@ public StatEstimator getStatEstimator() {
     }
 
     private Optional<Double> getRangeWidth(Range range) {
-      if (range.minValue != null && range.maxValue != null) {
-        return Optional.of(range.maxValue.doubleValue() - range.minValue.doubleValue());
+      if (range != null) {

Review comment:
       could you please also add the testcase from the jira?




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

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] kgyrtkirk merged pull request #2034: HIVE-24839: SubStrStatEstimator.estimate throws NullPointerException

Posted by GitBox <gi...@apache.org>.
kgyrtkirk merged pull request #2034:
URL: https://github.com/apache/hive/pull/2034


   


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

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] ujc714 commented on a change in pull request #2034: HIVE-24839: SubStrStatEstimator.estimate throws NullPointerException

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java
##########
@@ -174,8 +174,10 @@ public StatEstimator getStatEstimator() {
     }
 
     private Optional<Double> getRangeWidth(Range range) {
-      if (range.minValue != null && range.maxValue != null) {
-        return Optional.of(range.maxValue.doubleValue() - range.minValue.doubleValue());
+      if (range != null) {

Review comment:
       Thanks for your suggestion. Added test case substr_estimate_range.q.




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

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