[ https://issues.apache.org/jira/browse/HIVE-24245?focusedWorklogId=515635&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-515635 ]
ASF GitHub Bot logged work on HIVE-24245: ----------------------------------------- Author: ASF GitHub Bot Created on: 23/Nov/20 16:09 Start Date: 23/Nov/20 16:09 Worklog Time Spent: 10m Work Description: pgaref commented on a change in pull request #1649: URL: https://github.com/apache/hive/pull/1649#discussion_r528820635 ########## File path: ql/src/java/org/apache/hadoop/hive/ql/exec/vector/ptf/VectorPTFEvaluatorBytesCountDistinct.java ########## @@ -0,0 +1,42 @@ +/* + * 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.exec.vector.ptf; + +import org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector; +import org.apache.hadoop.hive.ql.exec.vector.ColumnVector; +import org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression; +import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef; +import org.apache.hive.common.util.Murmur3; + +/** + * Bytes (String) implementation for VectorPTFEvaluatorCountDistinct. + */ +public class VectorPTFEvaluatorBytesCountDistinct extends VectorPTFEvaluatorCountDistinct { + + public VectorPTFEvaluatorBytesCountDistinct(WindowFrameDef windowFrameDef, + VectorExpression inputVecExpr, int outputColumnNum) { + super(windowFrameDef, inputVecExpr, outputColumnNum); + resetEvaluator(); + } + + protected Object getValue(ColumnVector colVector, int i) { + BytesColumnVector inV = (BytesColumnVector) colVector; + return Murmur3.hash32(inV.vector[i], inV.start[i], inV.length[i], Murmur3.DEFAULT_SEED); Review comment: What is the benefit of returning Murmur hash directly here? Adding a String to the HashSet will also hash the input (so essentially we are hashing twice) ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 515635) Time Spent: 0.5h (was: 20m) > Vectorized PTF with count and distinct over partition producing incorrect > results. > ---------------------------------------------------------------------------------- > > Key: HIVE-24245 > URL: https://issues.apache.org/jira/browse/HIVE-24245 > Project: Hive > Issue Type: Bug > Components: Hive, PTF-Windowing, Vectorization > Affects Versions: 3.1.0, 3.1.2 > Reporter: Chiran Ravani > Assignee: László Bodor > Priority: Critical > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > > Vectorized PTF for count and distinct over partition is broken. It produces > incorrect results. > Below is the test case. > {code} > CREATE TABLE bigd781b_new ( > id int, > txt1 string, > txt2 string, > cda_date int, > cda_job_name varchar(12)); > INSERT INTO bigd781b_new VALUES > (1,'2010005759','7164335675012038',20200528,'load1'), > (2,'2010005759','7164335675012038',20200528,'load2'); > {code} > Running below query produces incorrect results > {code} > SELECT > txt1, > txt2, > count(distinct txt1) over(partition by txt1) as n, > count(distinct txt2) over(partition by txt2) as m > FROM bigd781b_new > {code} > as below. > {code} > +-------------+-------------------+----+----+ > | txt1 | txt2 | n | m | > +-------------+-------------------+----+----+ > | 2010005759 | 7164335675012038 | 2 | 2 | > | 2010005759 | 7164335675012038 | 2 | 2 | > +-------------+-------------------+----+----+ > {code} > While the correct output would be > {code} > +-------------+-------------------+----+----+ > | txt1 | txt2 | n | m | > +-------------+-------------------+----+----+ > | 2010005759 | 7164335675012038 | 1 | 1 | > | 2010005759 | 7164335675012038 | 1 | 1 | > +-------------+-------------------+----+----+ > {code} > The problem does not appear after setting below property > set hive.vectorized.execution.ptf.enabled=false; -- This message was sent by Atlassian Jira (v8.3.4#803005)