Skip to content

Commit

Permalink
[CALCITE-6100] The equalsDeep of SqlRowTypeNameSpec returns wrong result
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Sysolyatin committed Nov 9, 2023
1 parent 4c9011c commit f78a224
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public int getArity() {
litmus.withMessageArgs("{} != {}", this, node))) {
return litmus.fail("{} != {}", this, node);
}
if (!this.fieldTypes.equals(that.fieldTypes)) {
if (!SqlNode.equalDeep(this.fieldTypes, that.fieldTypes,
litmus.withMessageArgs("{} != {}", this, node))) {
return litmus.fail("{} != {}", this, node);
}
return litmus.succeed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,31 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-4402">[CALCITE-4402]
* SqlCall#equalsDeep does not take into account the function quantifier</a>.
* Containing unit tests for {@link SqlNode#equalsDeep(SqlNode, Litmus)}.
*/
class SqlEqualsDeepTest {

/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-4402">[CALCITE-4402]
* SqlCall#equalsDeep does not take into account the function quantifier</a>.
*/
@Test void testCountEqualsDeep() throws SqlParseException {
assertEqualsDeep("count(a)", "count(a)", true);
assertEqualsDeep("count(distinct a)", "count(distinct a)", true);
assertEqualsDeep("count(distinct a)", "count(a)", false);
}

/**
* Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6100">[CALCITE-6100]
* The equalsDeep of SqlRowTypeNameSpec returns wrong result</a>.
*/
@Test void testRowEqualsDeep() throws SqlParseException {
assertEqualsDeep("CAST(a AS ROW(field INTEGER))",
"CAST(a AS ROW(field INTEGER))", true);
}

private void assertEqualsDeep(String expr0, String expr1, boolean expected)
throws SqlParseException {

Expand Down

0 comments on commit f78a224

Please sign in to comment.