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/02/05 14:05:00 UTC

[GitHub] [hive] abstractdog opened a new pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

abstractdog opened a new pull request #1950:
URL: https://github.com/apache/hive/pull/1950


   …
   
   Change-Id: Id7c741b240e4ce862e29d0d21ecd257b909c6e02
   
   <!--
   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.

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] abstractdog commented on a change in pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

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



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestValueBoundaryScanner.java
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.udf.ptf;
+
+import java.time.ZoneId;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestValueBoundaryScanner {
+
+  @Test
+  public void testLongEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+
+    LongValueBoundaryScanner scanner =
+        new LongValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    LongWritable w1 = new LongWritable(1);
+    LongWritable w2 = new LongWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testHiveDecimalEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
+
+    HiveDecimalValueBoundaryScanner scanner =
+        new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    HiveDecimalWritable w1 = new HiveDecimalWritable(1);
+    HiveDecimalWritable w2 = new HiveDecimalWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testDateEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableDateObjectInspector);
+
+    DateValueBoundaryScanner scanner =
+        new DateValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Date date = new Date();
+    date.setTimeInMillis(1000);
+    DateWritableV2 w1 = new DateWritableV2(date);
+    DateWritableV2 w2 = new DateWritableV2(date);
+    DateWritableV2 w3 = new DateWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new DateWritableV2(new Date())));
+    // empty == another
+    Assert.assertTrue(scanner.isEqual(w1, w3));

Review comment:
       ok, I found that, in case of dates, 1000s increment results in the same day :) so testing issue, fixed in
   https://github.com/apache/hive/pull/1950/commits/589126936825ea6652787457dcff6ca038d37f6a




----------------------------------------------------------------
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] abstractdog commented on a change in pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

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



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestValueBoundaryScanner.java
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.udf.ptf;
+
+import java.time.ZoneId;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestValueBoundaryScanner {
+
+  @Test
+  public void testLongEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+
+    LongValueBoundaryScanner scanner =
+        new LongValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    LongWritable w1 = new LongWritable(1);
+    LongWritable w2 = new LongWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testHiveDecimalEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
+
+    HiveDecimalValueBoundaryScanner scanner =
+        new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    HiveDecimalWritable w1 = new HiveDecimalWritable(1);
+    HiveDecimalWritable w2 = new HiveDecimalWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testDateEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableDateObjectInspector);
+
+    DateValueBoundaryScanner scanner =
+        new DateValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Date date = new Date();
+    date.setTimeInMillis(1000);
+    DateWritableV2 w1 = new DateWritableV2(date);
+    DateWritableV2 w2 = new DateWritableV2(date);
+    DateWritableV2 w3 = new DateWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new DateWritableV2(new Date())));
+    // empty == another
+    Assert.assertTrue(scanner.isEqual(w1, w3));

Review comment:
       not sure at the moment, but this worked this way even without my patch




----------------------------------------------------------------
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] abstractdog commented on a change in pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

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



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestValueBoundaryScanner.java
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.udf.ptf;
+
+import java.time.ZoneId;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestValueBoundaryScanner {
+
+  @Test
+  public void testLongEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+
+    LongValueBoundaryScanner scanner =
+        new LongValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    LongWritable w1 = new LongWritable(1);
+    LongWritable w2 = new LongWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testHiveDecimalEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
+
+    HiveDecimalValueBoundaryScanner scanner =
+        new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    HiveDecimalWritable w1 = new HiveDecimalWritable(1);
+    HiveDecimalWritable w2 = new HiveDecimalWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testDateEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableDateObjectInspector);
+
+    DateValueBoundaryScanner scanner =
+        new DateValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Date date = new Date();
+    date.setTimeInMillis(1000);
+    DateWritableV2 w1 = new DateWritableV2(date);
+    DateWritableV2 w2 = new DateWritableV2(date);
+    DateWritableV2 w3 = new DateWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new DateWritableV2(new Date())));
+    // empty == another
+    Assert.assertTrue(scanner.isEqual(w1, w3));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testTimestampEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
+
+    TimestampValueBoundaryScanner scanner =
+        new TimestampValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Timestamp ts = new Timestamp();
+    ts.setTimeInMillis(1000);
+
+    TimestampWritableV2 w1 = new TimestampWritableV2(ts);
+    TimestampWritableV2 w2 = new TimestampWritableV2(ts);
+    TimestampWritableV2 w3 = new TimestampWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new TimestampWritableV2(new Timestamp())));
+    // empty == another
+    Assert.assertFalse(scanner.isEqual(w1, w3));

Review comment:
       this is correct, but comment was incorrect, fixed in:
   https://github.com/apache/hive/pull/1950/commits/589126936825ea6652787457dcff6ca038d37f6a




----------------------------------------------------------------
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] rbalamohan commented on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
rbalamohan commented on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-817392189


   LGTM. +1.  
   
   2 test failures are unrelated to this patch.


-- 
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] abstractdog commented on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
abstractdog commented on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-816542489


   @rbalamohan : just squashed the commits together, can we merge this?
   you can see perf jmh benchmark results above
   


-- 
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] abstractdog edited a comment on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
abstractdog edited a comment on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-775826706


   > Hey @abstractdog change makes sense to me -- question is how often do we really call the TsBoundary Scanner during range computation? Is the test representative of the scanario?
   > 
   > Would the optimization make sense to other types as well e.g., TimestampLocalTZ or Date?
   
   this could be heavy code path yes, as in case range based windows, every row needs to be checked:
   ```
   at org.apache.hadoop.hive.common.type.Timestamp.setTimeInSeconds(Timestamp.java:133)
   	at org.apache.hadoop.hive.serde2.io.TimestampWritableV2.populateTimestamp(TimestampWritableV2.java:401)
   	at org.apache.hadoop.hive.serde2.io.TimestampWritableV2.getTimestamp(TimestampWritableV2.java:210)
   	at org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(PrimitiveObjectInspectorUtils.java:1239)
   	at org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(PrimitiveObjectInspectorUtils.java:1181)
   	at org.apache.hadoop.hive.ql.udf.ptf.TimestampValueBoundaryScanner.isEqual(ValueBoundaryScanner.java:848)
   	at org.apache.hadoop.hive.ql.udf.ptf.SingleValueBoundaryScanner.computeEndCurrentRow(ValueBoundaryScanner.java:593)
   	at org.apache.hadoop.hive.ql.udf.ptf.SingleValueBoundaryScanner.computeEnd(ValueBoundaryScanner.java:530)
   	at org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator.getRange(BasePartitionEvaluator.java:273)
   	at org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator.iterate(BasePartitionEvaluator.java:219)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.evaluateWindowFunction(WindowingTableFunction.java:147)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.access$100(WindowingTableFunction.java:61)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction$WindowingIterator.next(WindowingTableFunction.java:755)
   	at org.apache.hadoop.hive.ql.exec.PTFOperator$PTFInvocation.finishPartition(PTFOperator.java:373)
   	at org.apache.hadoop.hive.ql.exec.PTFOperator.closeOp(PTFOperator.java:104)
   	at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:732)
   	at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:756)
   	at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordProcessor.close(ReduceRecordProcessor.java:383)
   	at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:284)
   	at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:250)
   ```
   
   TimestampLocalTZWritable doesn't seem to be subject to the same optimization as its compareTo will do heavy operations anyway (getTimestampTZ -> populateTimestampTZ)
   ```
     @Override
     public int compareTo(TimestampLocalTZWritable o) {
       return getTimestampTZ().compareTo(o.getTimestampTZ());
     }
   ```
    we'll have to find out if this can be simplified in the same way, so compareTo should use bytes if bytes are present, similarly to TimestampWritableV2:
    ```
      public int compareTo(TimestampWritableV2 t) {
       checkBytes();
       long s1 = this.getSeconds();
       ...
    ```


----------------------------------------------------------------
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] abstractdog commented on a change in pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

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



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestValueBoundaryScanner.java
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.udf.ptf;
+
+import java.time.ZoneId;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestValueBoundaryScanner {
+
+  @Test
+  public void testLongEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+
+    LongValueBoundaryScanner scanner =
+        new LongValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    LongWritable w1 = new LongWritable(1);
+    LongWritable w2 = new LongWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testHiveDecimalEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
+
+    HiveDecimalValueBoundaryScanner scanner =
+        new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    HiveDecimalWritable w1 = new HiveDecimalWritable(1);
+    HiveDecimalWritable w2 = new HiveDecimalWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testDateEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableDateObjectInspector);
+
+    DateValueBoundaryScanner scanner =
+        new DateValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Date date = new Date();
+    date.setTimeInMillis(1000);
+    DateWritableV2 w1 = new DateWritableV2(date);
+    DateWritableV2 w2 = new DateWritableV2(date);
+    DateWritableV2 w3 = new DateWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new DateWritableV2(new Date())));
+    // empty == another
+    Assert.assertTrue(scanner.isEqual(w1, w3));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testTimestampEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
+
+    TimestampValueBoundaryScanner scanner =
+        new TimestampValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Timestamp ts = new Timestamp();
+    ts.setTimeInMillis(1000);
+
+    TimestampWritableV2 w1 = new TimestampWritableV2(ts);
+    TimestampWritableV2 w2 = new TimestampWritableV2(ts);
+    TimestampWritableV2 w3 = new TimestampWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new TimestampWritableV2(new Timestamp())));
+    // empty == another
+    Assert.assertFalse(scanner.isEqual(w1, w3));

Review comment:
       hm, good catch let me double check




----------------------------------------------------------------
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] pgaref commented on a change in pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

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



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestValueBoundaryScanner.java
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.udf.ptf;
+
+import java.time.ZoneId;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestValueBoundaryScanner {
+
+  @Test
+  public void testLongEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+
+    LongValueBoundaryScanner scanner =
+        new LongValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    LongWritable w1 = new LongWritable(1);
+    LongWritable w2 = new LongWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testHiveDecimalEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
+
+    HiveDecimalValueBoundaryScanner scanner =
+        new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    HiveDecimalWritable w1 = new HiveDecimalWritable(1);
+    HiveDecimalWritable w2 = new HiveDecimalWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testDateEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableDateObjectInspector);
+
+    DateValueBoundaryScanner scanner =
+        new DateValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Date date = new Date();
+    date.setTimeInMillis(1000);
+    DateWritableV2 w1 = new DateWritableV2(date);
+    DateWritableV2 w2 = new DateWritableV2(date);
+    DateWritableV2 w3 = new DateWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new DateWritableV2(new Date())));
+    // empty == another
+    Assert.assertTrue(scanner.isEqual(w1, w3));

Review comment:
       Is this expected?

##########
File path: ql/src/test/org/apache/hadoop/hive/ql/udf/ptf/TestValueBoundaryScanner.java
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.udf.ptf;
+
+import java.time.ZoneId;
+
+import org.apache.hadoop.hive.common.type.Date;
+import org.apache.hadoop.hive.common.type.Timestamp;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.ql.plan.ptf.OrderExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.serde2.io.DateWritableV2;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
+import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.Text;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestValueBoundaryScanner {
+
+  @Test
+  public void testLongEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
+
+    LongValueBoundaryScanner scanner =
+        new LongValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    LongWritable w1 = new LongWritable(1);
+    LongWritable w2 = new LongWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testHiveDecimalEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableHiveDecimalObjectInspector);
+
+    HiveDecimalValueBoundaryScanner scanner =
+        new HiveDecimalValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    HiveDecimalWritable w1 = new HiveDecimalWritable(1);
+    HiveDecimalWritable w2 = new HiveDecimalWritable(2);
+
+    Assert.assertTrue(scanner.isEqual(w1, w1));
+
+    Assert.assertFalse(scanner.isEqual(w1, w2));
+    Assert.assertFalse(scanner.isEqual(w2, w1));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testDateEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableDateObjectInspector);
+
+    DateValueBoundaryScanner scanner =
+        new DateValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Date date = new Date();
+    date.setTimeInMillis(1000);
+    DateWritableV2 w1 = new DateWritableV2(date);
+    DateWritableV2 w2 = new DateWritableV2(date);
+    DateWritableV2 w3 = new DateWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new DateWritableV2(new Date())));
+    // empty == another
+    Assert.assertTrue(scanner.isEqual(w1, w3));
+
+    Assert.assertFalse(scanner.isEqual(null, w2));
+    Assert.assertFalse(scanner.isEqual(w1, null));
+
+    Assert.assertTrue(scanner.isEqual(null, null));
+  }
+
+  @Test
+  public void testTimestampEquals() {
+    PTFExpressionDef argDef = new PTFExpressionDef();
+    argDef.setOI(PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
+
+    TimestampValueBoundaryScanner scanner =
+        new TimestampValueBoundaryScanner(null, null, new OrderExpressionDef(argDef), false);
+    Timestamp ts = new Timestamp();
+    ts.setTimeInMillis(1000);
+
+    TimestampWritableV2 w1 = new TimestampWritableV2(ts);
+    TimestampWritableV2 w2 = new TimestampWritableV2(ts);
+    TimestampWritableV2 w3 = new TimestampWritableV2(); // empty
+
+    Assert.assertTrue(scanner.isEqual(w1, w2));
+    Assert.assertTrue(scanner.isEqual(w2, w1));
+
+    // empty == epoch
+    Assert.assertTrue(scanner.isEqual(w3, new TimestampWritableV2(new Timestamp())));
+    // empty == another
+    Assert.assertFalse(scanner.isEqual(w1, w3));

Review comment:
       This is the opposite behaviour of Date?




----------------------------------------------------------------
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] abstractdog commented on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
abstractdog commented on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-775826706


   > Hey @abstractdog change makes sense to me -- question is how often do we really call the TsBoundary Scanner during range computation? Is the test representative of the scanario?
   > 
   > Would the optimization make sense to other types as well e.g., TimestampLocalTZ or Date?
   
   this could be heavy code path yes, as in case range based windows, every row needs to be checked:
   ```
   at org.apache.hadoop.hive.common.type.Timestamp.setTimeInSeconds(Timestamp.java:133)
   	at org.apache.hadoop.hive.serde2.io.TimestampWritableV2.populateTimestamp(TimestampWritableV2.java:401)
   	at org.apache.hadoop.hive.serde2.io.TimestampWritableV2.getTimestamp(TimestampWritableV2.java:210)
   	at org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(PrimitiveObjectInspectorUtils.java:1239)
   	at org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(PrimitiveObjectInspectorUtils.java:1181)
   	at org.apache.hadoop.hive.ql.udf.ptf.TimestampValueBoundaryScanner.isEqual(ValueBoundaryScanner.java:848)
   	at org.apache.hadoop.hive.ql.udf.ptf.SingleValueBoundaryScanner.computeEndCurrentRow(ValueBoundaryScanner.java:593)
   	at org.apache.hadoop.hive.ql.udf.ptf.SingleValueBoundaryScanner.computeEnd(ValueBoundaryScanner.java:530)
   	at org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator.getRange(BasePartitionEvaluator.java:273)
   	at org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator.iterate(BasePartitionEvaluator.java:219)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.evaluateWindowFunction(WindowingTableFunction.java:147)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.access$100(WindowingTableFunction.java:61)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction$WindowingIterator.next(WindowingTableFunction.java:755)
   	at org.apache.hadoop.hive.ql.exec.PTFOperator$PTFInvocation.finishPartition(PTFOperator.java:373)
   	at org.apache.hadoop.hive.ql.exec.PTFOperator.closeOp(PTFOperator.java:104)
   	at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:732)
   	at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:756)
   	at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordProcessor.close(ReduceRecordProcessor.java:383)
   	at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:284)
   	at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:250)
   ```


----------------------------------------------------------------
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] abstractdog merged pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

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


   


-- 
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] abstractdog edited a comment on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
abstractdog edited a comment on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-775826706


   > Hey @abstractdog change makes sense to me -- question is how often do we really call the TsBoundary Scanner during range computation? Is the test representative of the scanario?
   > 
   > Would the optimization make sense to other types as well e.g., TimestampLocalTZ or Date?
   
   this could be heavy code path yes, as in case range based windows, every row needs to be checked:
   ```
   at org.apache.hadoop.hive.common.type.Timestamp.setTimeInSeconds(Timestamp.java:133)
   	at org.apache.hadoop.hive.serde2.io.TimestampWritableV2.populateTimestamp(TimestampWritableV2.java:401)
   	at org.apache.hadoop.hive.serde2.io.TimestampWritableV2.getTimestamp(TimestampWritableV2.java:210)
   	at org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(PrimitiveObjectInspectorUtils.java:1239)
   	at org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorUtils.getTimestamp(PrimitiveObjectInspectorUtils.java:1181)
   	at org.apache.hadoop.hive.ql.udf.ptf.TimestampValueBoundaryScanner.isEqual(ValueBoundaryScanner.java:848)
   	at org.apache.hadoop.hive.ql.udf.ptf.SingleValueBoundaryScanner.computeEndCurrentRow(ValueBoundaryScanner.java:593)
   	at org.apache.hadoop.hive.ql.udf.ptf.SingleValueBoundaryScanner.computeEnd(ValueBoundaryScanner.java:530)
   	at org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator.getRange(BasePartitionEvaluator.java:273)
   	at org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator.iterate(BasePartitionEvaluator.java:219)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.evaluateWindowFunction(WindowingTableFunction.java:147)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction.access$100(WindowingTableFunction.java:61)
   	at org.apache.hadoop.hive.ql.udf.ptf.WindowingTableFunction$WindowingIterator.next(WindowingTableFunction.java:755)
   	at org.apache.hadoop.hive.ql.exec.PTFOperator$PTFInvocation.finishPartition(PTFOperator.java:373)
   	at org.apache.hadoop.hive.ql.exec.PTFOperator.closeOp(PTFOperator.java:104)
   	at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:732)
   	at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:756)
   	at org.apache.hadoop.hive.ql.exec.tez.ReduceRecordProcessor.close(ReduceRecordProcessor.java:383)
   	at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.initializeAndRunProcessor(TezProcessor.java:284)
   	at org.apache.hadoop.hive.ql.exec.tez.TezProcessor.run(TezProcessor.java:250)
   ```
   looks like a good idea to check other types' compareTo shortcuts
   
   TimestampLocalTZWritable doesn't seem to be subject to the same optimization as its compareTo will do heavy operations anyway (getTimestampTZ -> populateTimestampTZ)
   ```
     @Override
     public int compareTo(TimestampLocalTZWritable o) {
       return getTimestampTZ().compareTo(o.getTimestampTZ());
     }
   ```
   we'll have to find out if this can be simplified in the same way (maybe another jira, fyi: @rbalamohan if you're aware of this), so compareTo should use bytes if bytes are present, similarly to TimestampWritableV2:
    ```
      public int compareTo(TimestampWritableV2 t) {
       checkBytes();
       long s1 = this.getSeconds();
       ...
    ```


----------------------------------------------------------------
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] abstractdog commented on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
abstractdog commented on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-817520837


   > LGTM. +1.
   > 
   > 2 test failures are unrelated to this patch.
   
   thanks, I'm merging this (failures have been fixed in HIVE-25000)


-- 
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] abstractdog commented on pull request #1950: HIVE-24746: PTF: TimestampValueBoundaryScanner can be optimised during range computation

Posted by GitBox <gi...@apache.org>.
abstractdog commented on pull request #1950:
URL: https://github.com/apache/hive/pull/1950#issuecomment-775030048


   @rbalamohan 
   ```
   Benchmark                                                                             Mode  Cnt  Score   Error  Units
   ValueBoundaryScannerBench.BaseBench.testTimestampEqualsWithInspector                  avgt    5  3.439 ± 0.638  ms/op
   ValueBoundaryScannerBench.BaseBench.testTimestampEqualsWithoutInspector               avgt    5  0.015 ± 0.001  ms/op
   ValueBoundaryScannerBench.BaseBench.testTimestampEqualsWithoutInspectorWithTypeCheck  avgt    5  0.015 ± 0.004  ms/op
   ```


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