[ 
https://issues.apache.org/jira/browse/CALCITE-3021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16845475#comment-16845475
 ] 

Julian Hyde commented on CALCITE-3021:
--------------------------------------

If we now do the same as PostgreSQL, that's good enough for me. Change the 
title to something that talks about comparing ROW nested inside ROW for 
equality, and +1 from me.

> ArrayEqualityComparer should use Arrays#deepEquals/deepHashCode instead of 
> Arrays#equals/hashCode
> -------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3021
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3021
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.19.0
>            Reporter: Ruben Quesada Lopez
>            Assignee: Ruben Quesada Lopez
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.20.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Currently, ArrayEqualityComparer (which is used as comparer for 
> JavaRowFormat.ARRAY) performs the array comparison based on Arrays#equals and 
> Arrays#hashCode (see Functions.java):
> {code:java}
>   private static class ArrayEqualityComparer implements 
> EqualityComparer<Object[]> {
>     public boolean equal(Object[] v1, Object[] v2) {
>       return Arrays.equals(v1, v2);
>     }
>     public int hashCode(Object[] t) {
>       return Arrays.hashCode(t);
>     }
>   }
> {code}
> This will lead to incorrect comparisons in case of multidimensional arrays, 
> e.g. a row (array) with a struct field (another array) inside. To fix the 
> issue, Arrays#deepEquals / Arrays#deepHashCode should be used:
> {code:java}
>   private static class ArrayEqualityComparer implements 
> EqualityComparer<Object[]> {
>     public boolean equal(Object[] v1, Object[] v2) {
>       return Arrays.deepEquals(v1, v2);
>     }
>     public int hashCode(Object[] t) {
>       return Arrays.deepHashCode(t);
>     }
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to