[ 
https://issues.apache.org/jira/browse/HIVE-30278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Denys Kuzmenko updated HIVE-30278:
----------------------------------
    Component/s: Vectorization

> Vectorization: MurmurHash expressions leave stale NULL flags in their output, 
> so a multi-column semijoin drops matching rows under LLAP IO
> ------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-30278
>                 URL: https://issues.apache.org/jira/browse/HIVE-30278
>             Project: Hive
>          Issue Type: Bug
>          Components: Vectorization
>            Reporter: Denys Kuzmenko
>            Priority: Major
>              Labels: correctness
>
> HIVE-23976 vectorized the multi-column semijoin key, hash(hash(a, b), c), 
> with MurmurHashExpression and its three                                       
>                                                        
>   subclasses. Two defects in them (HIVE-28598 later rewrote the hash methods 
> and kept the second):                                                         
>                                                       
>   - MurmurHashExpression.evaluate writes a hash for every row but leaves its 
> output column's noNulls/isNull as it found                                    
>                                                       
>     them (only the repeating case clears isNull[0]). The output is a scratch 
> column: when an earlier operator of the                                       
>                                                       
>     same vertex wrote NULLs into it in an earlier batch, those rows still 
> read as NULL.                                                                 
>                                                          
>   - MurmurHash{IntColIntCol,StringColIntCol,StringColStringCol}.hash read 
> isNull without checking noNulls. isNull only                                  
>                                                          
>     holds information while noNulls is false (ColumnVector), so a column 
> without NULLs but with stale isNull entries                                   
>                                                           
>     hashes as NULL.                                                           
>                                                                               
>                                                      
>   VectorInBloomFilterColDynamicValue drops a NULL row without probing the 
> bloom filter, so both defects turn true matches                               
>                                                          
>   into dropped rows. On the build side VectorUDAFBloomFilter skips NULL 
> inputs, so the same stale flags leave keys out of                             
>                                                            
>   the bloom filter.                                                           
>                                                                               
>                                                      
>                                                                               
>                                                                               
>                                                      
>   The non-LLAP readers hide it: they reset every non-partition column, 
> scratch columns included, before each batch                                   
>                                                             
>   (VectorizedBatchUtil.resetNonPartitionColumns). LlapRecordReader.next swaps 
> in the data columns only, so a scratch                                        
>                                                      
>   column keeps the flags of the previous batch.                               
>                                                                               
>                                                      
>                                                                               
>                                                                               
>                                                      
>   Seen on TPC-DS q50 (10 TB, external Parquet, LLAP IO, 
> hive.tez.dynamic.semijoin.reduction.for.mapjoin=true): the                    
>                                                                            
>   store_sales vertex filters on in_bloom_filter(hash(hash(ss_item_sk, 
> ss_customer_sk), ss_ticket_number), ...), and the                             
>                                                              
>   vectorizer gives the outer hash's output column to the store map join's 
> nullable s_company_id later in the same                                       
>                                                          
>   vertex. q50 returned counts 1-3 too low in 92 of its 100 rows (2,210 of 
> 24.36M joined rows lost), the same in every                                   
>                                                          
>   run. Each of these gives the right rows: semijoin reduction off, 
> multi-column semijoins off, LLAP IO off, or a plan in                         
>                                                                 
>   which that scratch column holds a non-null value.                
>   Fix                                                                         
>                                                                               
>                                                      
>   - MurmurHashExpression.evaluate marks every row it writes as not null 
> (isNull[i] = false for a selected row; isNull                                 
>                                                            
>     cleared and noNulls set without a selection), as the vector expression 
> templates do.                                                                 
>                                                         
>   - The hash methods read isNull only when noNulls is false.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to