[ https://issues.apache.org/jira/browse/CALCITE-3021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16826228#comment-16826228 ]
Haisheng Yuan commented on CALCITE-3021: ---------------------------------------- Sorry, I just notice the discussion in JIRA after I merged the pull request. I can revert it if needed. :( > 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: 20m > 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)