Skip to content

Commit

Permalink
Fix Unnest.equals() by comparing field withOrdinality
Browse files Browse the repository at this point in the history
  • Loading branch information
caithagoras authored and caithagoras0 committed Aug 21, 2017
1 parent f4b9693 commit fbc26e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -80,7 +80,7 @@ public String toString()
@Override
public int hashCode()
{
return Objects.hash(expressions);
return Objects.hash(expressions, withOrdinality);
}

@Override
Expand All @@ -93,6 +93,6 @@ public boolean equals(Object obj)
return false;
}
Unnest other = (Unnest) obj;
return Objects.equals(this.expressions, other.expressions);
return Objects.equals(expressions, other.expressions) && withOrdinality == other.withOrdinality;
}
}
Expand Up @@ -1738,21 +1738,21 @@ public void testUnnest()
new Table(QualifiedName.of("t")),
new Unnest(ImmutableList.of(new Identifier("a")), false),
Optional.empty())));
assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a) WITH ORDINALITY",
assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a, b) WITH ORDINALITY",
simpleQuery(
selectList(new AllColumns()),
new Join(
Join.Type.CROSS,
new Table(QualifiedName.of("t")),
new Unnest(ImmutableList.of(new Identifier("a")), true),
new Unnest(ImmutableList.of(new Identifier("a"), new Identifier("b")), true),
Optional.empty())));
assertStatement("SELECT * FROM t FULL JOIN UNNEST(a) ON true",
assertStatement("SELECT * FROM t FULL JOIN UNNEST(a) AS tmp (c) ON true",
simpleQuery(
selectList(new AllColumns()),
new Join(
Join.Type.FULL,
new Table(QualifiedName.of("t")),
new Unnest(ImmutableList.of(new Identifier("a")), true),
new AliasedRelation(new Unnest(ImmutableList.of(new Identifier("a")), false), new Identifier("tmp"), ImmutableList.of(new Identifier("c"))),
Optional.of(new JoinOn(BooleanLiteral.TRUE_LITERAL)))));
}

Expand Down

0 comments on commit fbc26e5

Please sign in to comment.