diff --git a/doc/user_guide/statements/merge.md b/doc/user_guide/statements/merge.md index d97669c9..51871660 100644 --- a/doc/user_guide/statements/merge.md +++ b/doc/user_guide/statements/merge.md @@ -5,9 +5,11 @@ You can construct [`MERGE`](https://docs.exasol.com/sql/merge.htm) SQL statement `Merge` supports a combination of `INSERT`, `UPDATE` and `DELETE` where source data is merged into a destination table. The merge strategy is configurable and depends on whether or not a row in source and destination are considered a match. Of course the criteria for that match is configurable too. +Note that while the individual merge strategies are optional parts of the `MERGE` statement, you need to pick *at least one* to get a valid statement. + ## Creating `MERGE` Commands -You can create a minimalistic `MERGE` like this: +You can create a basic `MERGE` like this: ```java final Merge merge = StatementFactory.getInstance() @@ -16,7 +18,9 @@ final Merge merge = StatementFactory.getInstance() .on(eq(column("source", "id"), column("destination", "id"); ``` -### Fine Tuning the `MERGE` Strategies +As mentioned before, this statement is not complete without selecting at least one [merge strategy](#merge-strategies). + +### `MERGE` Strategies If you need more control over what happens in case of matching rows, you can add `whenMatched()`. @@ -29,9 +33,12 @@ merge.whenMatched() .thenUpdate() // .setToDefault("c2") // .set("c3", "foo") // - .set("c4", 42); + .set("c4", 42) // + .set("c5", integerLiteral(9000)); ``` +The basic `set()` method expects a column and a value expression. For added convenience the set methods are overloaded to allow using literals directly. + And another example for `thenDelete()`. ```java diff --git a/pom.xml b/pom.xml index a0bd373a..d0bd643f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.exasol sql-statement-builder - 3.0.0 + 3.1.0 Exasol SQL Statement Builder This module provides a Builder for SQL statements that helps creating the correct structure and validates variable parts of the statements. https://github.com/exasol/sql-statement-builder diff --git a/src/main/java/com/exasol/sql/dml/merge/MatchedClause.java b/src/main/java/com/exasol/sql/dml/merge/MatchedClause.java index 8b042b5f..4fcc8516 100644 --- a/src/main/java/com/exasol/sql/dml/merge/MatchedClause.java +++ b/src/main/java/com/exasol/sql/dml/merge/MatchedClause.java @@ -32,6 +32,24 @@ public MergeUpdateClause thenUpdate() { return this.mergeUpdateClause; } + /** + * Check if the {@code THEN UPDATE} clause is present. + * + * @return {@code true} if the update clause is present + */ + public boolean hasUpdate() { + return this.mergeUpdateClause != null; + } + + /** + * Get the {@code THEN UPDATE} clause. + * + * @return {@code THEN UPDATE} clause + */ + public MergeUpdateClause getUpdate() { + return this.mergeUpdateClause; + } + /** * Select deleting as merge strategy for rows where that are considered matches between source and destination. * @@ -42,13 +60,31 @@ public MergeDeleteClause thenDelete() { return this.mergeDeleteClause; } + /** + * Check if the {@code THEN DELETE} clause is present. + * + * @return {@code true} if the delete clause is present. + */ + public boolean hasDelete() { + return this.mergeDeleteClause != null; + } + + /** + * Get the {@code THEN DELETE} clause. + * + * @return {@code THEN DELETE} clause + */ + public MergeDeleteClause getDelete() { + return this.mergeDeleteClause; + } + @Override public void accept(final MergeVisitor visitor) { visitor.visit(this); - if (this.mergeUpdateClause != null) { + if (hasUpdate()) { this.mergeUpdateClause.accept(visitor); } - if (this.mergeDeleteClause != null) { + if (hasDelete()) { this.mergeDeleteClause.accept(visitor); } } diff --git a/src/main/java/com/exasol/sql/dml/merge/Merge.java b/src/main/java/com/exasol/sql/dml/merge/Merge.java index 8c0616aa..6639242f 100644 --- a/src/main/java/com/exasol/sql/dml/merge/Merge.java +++ b/src/main/java/com/exasol/sql/dml/merge/Merge.java @@ -125,6 +125,15 @@ protected boolean hasMatched() { return this.matched != null; } + /** + * Get the {@code WHEN MATCHED} clause. + * + * @return {@code WHEN MATCHED} clause + */ + public MatchedClause getMatched() { + return this.matched; + } + /** * Define the merge strategy if the match criteria is not met. * @@ -144,6 +153,15 @@ protected boolean hasNotMatched() { return this.notMatched != null; } + /** + * Get the {@code WHEN NOT MATCHED} clause. + * + * @return {@code WHEN NOT MATCHED} clause + */ + public MatchedClause getNotMatched() { + return this.matched; + } + @Override public void accept(final MergeVisitor visitor) { visitor.visit(this); diff --git a/src/main/java/com/exasol/sql/dml/merge/MergeUpdateClause.java b/src/main/java/com/exasol/sql/dml/merge/MergeUpdateClause.java index e8df6f0a..ecc84820 100644 --- a/src/main/java/com/exasol/sql/dml/merge/MergeUpdateClause.java +++ b/src/main/java/com/exasol/sql/dml/merge/MergeUpdateClause.java @@ -22,19 +22,26 @@ public MergeUpdateClause(final Fragment root) { } /** - * Update a column with a string value. + * Update a column with a value expression. * * @param column column to be updated - * @param literal string literal + * @param expression value expression * @return {@code this} for fluent programming */ - public MergeUpdateClause set(final String column, final String literal) { - addColumnUpdate(column, StringLiteral.of(literal)); + public MergeUpdateClause set(final String column, final ValueExpression expression) { + this.columnUpdates.add(new MergeColumnUpdate(this.root, column, expression)); return this; } - protected void addColumnUpdate(final String column, final ValueExpression expression) { - this.columnUpdates.add(new MergeColumnUpdate(this.root, column, expression)); + /** + * Update a column with a string value. + * + * @param column column to be updated + * @param literal string literal + * @return {@code this} for fluent programming + */ + public MergeUpdateClause set(final String column, final String literal) { + return set(column, StringLiteral.of(literal)); } /** @@ -45,8 +52,7 @@ protected void addColumnUpdate(final String column, final ValueExpression expres * @return {@code this} for fluent programming */ public MergeUpdateClause set(final String column, final int literal) { - addColumnUpdate(column, IntegerLiteral.of(literal)); - return this; + return set(column, IntegerLiteral.of(literal)); } /** diff --git a/src/main/java/com/exasol/sql/dml/merge/NotMatchedClause.java b/src/main/java/com/exasol/sql/dml/merge/NotMatchedClause.java index c0963d05..f52caa70 100644 --- a/src/main/java/com/exasol/sql/dml/merge/NotMatchedClause.java +++ b/src/main/java/com/exasol/sql/dml/merge/NotMatchedClause.java @@ -28,10 +28,28 @@ public MergeInsertClause thenInsert() { return this.mergeInsertClause; } + /** + * Check if the {@code THEN INSERT} clause is present. + * + * @return {@code true} if the {@code THEN INSERT} clause is present + */ + public boolean hasInsert() { + return this.mergeInsertClause != null; + } + + /** + * Get the {@code THEN INSERT} clause. + * + * @return {@code THEN INSERT} clause + */ + public MergeInsertClause getInsert() { + return this.mergeInsertClause; + } + @Override public void accept(final MergeVisitor visitor) { visitor.visit(this); - if (this.mergeInsertClause != null) { + if (hasInsert()) { this.mergeInsertClause.accept(visitor); } } diff --git a/src/main/java/com/exasol/sql/expression/ExpressionTerm.java b/src/main/java/com/exasol/sql/expression/ExpressionTerm.java index 1398a0a7..54cb3ded 100644 --- a/src/main/java/com/exasol/sql/expression/ExpressionTerm.java +++ b/src/main/java/com/exasol/sql/expression/ExpressionTerm.java @@ -40,12 +40,12 @@ public static ColumnReference column(final String column) { /** * Create a reference to a column in a specific table. - * - * @param column column name * @param table table name + * @param column column name + * * @return column reference */ - public static ColumnReference column(final String column, final String table) { + public static ColumnReference column(final String table, final String column) { return ColumnReference.column(table, column); } } \ No newline at end of file diff --git a/src/main/java/com/exasol/sql/expression/ValueExpression.java b/src/main/java/com/exasol/sql/expression/ValueExpression.java index ff8f69d6..f01fa1da 100644 --- a/src/main/java/com/exasol/sql/expression/ValueExpression.java +++ b/src/main/java/com/exasol/sql/expression/ValueExpression.java @@ -12,4 +12,4 @@ public interface ValueExpression extends TreeNode { * @param visitor visitor to accept */ public void accept(ValueExpressionVisitor visitor); -} +} \ No newline at end of file diff --git a/src/test/java/com/exasol/sql/dml/merge/MatchedClauseTest.java b/src/test/java/com/exasol/sql/dml/merge/MatchedClauseTest.java new file mode 100644 index 00000000..0411100c --- /dev/null +++ b/src/test/java/com/exasol/sql/dml/merge/MatchedClauseTest.java @@ -0,0 +1,51 @@ +package com.exasol.sql.dml.merge; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.sameInstance; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class MatchedClauseTest { + private MatchedClause matched; + + @BeforeEach + void beforeEach() { + this.matched = new MatchedClause(null); + } + + @Test + void testHasUpdateFalseByDefault() { + assertThat(this.matched.hasUpdate(), equalTo(false)); + } + + @Test + void testHasUpdateTrue() { + this.matched.thenUpdate(); + assertThat(this.matched.hasUpdate(), equalTo(true)); + } + + @Test + void testGetUpdate() { + final MergeUpdateClause update = this.matched.thenUpdate(); + assertThat(this.matched.getUpdate(), sameInstance(update)); + } + + @Test + void testHasDeleteFalseByDefault() { + assertThat(this.matched.hasDelete(), equalTo(false)); + } + + @Test + void testHasDeleteTrue() { + this.matched.thenDelete(); + assertThat(this.matched.hasDelete(), equalTo(true)); + } + + @Test + void testGetDelete() { + final MergeDeleteClause delete = this.matched.thenDelete(); + assertThat(this.matched.getDelete(), sameInstance(delete)); + } +} \ No newline at end of file diff --git a/src/test/java/com/exasol/sql/dml/merge/MergeTest.java b/src/test/java/com/exasol/sql/dml/merge/MergeTest.java new file mode 100644 index 00000000..3ee486cd --- /dev/null +++ b/src/test/java/com/exasol/sql/dml/merge/MergeTest.java @@ -0,0 +1,38 @@ +package com.exasol.sql.dml.merge; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class MergeTest { + private Merge merge; + + @BeforeEach + void beforeEach() { + this.merge = new Merge("dst").using("src"); + } + + @Test + void testHasMatchedFalseByDefault() { + assertThat(this.merge.hasMatched(), equalTo(false)); + } + + @Test + void testHasMatchedTrue() { + this.merge.whenMatched(); + assertThat(this.merge.hasMatched(), equalTo(true)); + } + + @Test + void testHasNotMatchedFalseByDefault() { + assertThat(this.merge.hasNotMatched(), equalTo(false)); + } + + @Test + void testHasNotMatchedTrue() { + this.merge.whenNotMatched(); + assertThat(this.merge.hasNotMatched(), equalTo(true)); + } +} \ No newline at end of file diff --git a/src/test/java/com/exasol/sql/dml/merge/NotMatchedClauseTest.java b/src/test/java/com/exasol/sql/dml/merge/NotMatchedClauseTest.java new file mode 100644 index 00000000..d0a5fb0b --- /dev/null +++ b/src/test/java/com/exasol/sql/dml/merge/NotMatchedClauseTest.java @@ -0,0 +1,34 @@ +package com.exasol.sql.dml.merge; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.sameInstance; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class NotMatchedClauseTest { + private NotMatchedClause notMatched; + + @BeforeEach + void beforeEach() { + this.notMatched = new NotMatchedClause(null); + } + + @Test + void testHasInsertFalseByDefault() { + assertThat(this.notMatched.hasInsert(), equalTo(false)); + } + + @Test + void testHasInsertTrue() { + this.notMatched.thenInsert(); + assertThat(this.notMatched.hasInsert(), equalTo(true)); + } + + @Test + void testGetInsert() { + final MergeInsertClause insert = this.notMatched.thenInsert(); + assertThat(this.notMatched.getInsert(), sameInstance(insert)); + } +} \ No newline at end of file diff --git a/src/test/java/com/exasol/sql/dml/merge/rendering/TestMergeRendering.java b/src/test/java/com/exasol/sql/dml/merge/rendering/MergeRenderingTest.java similarity index 78% rename from src/test/java/com/exasol/sql/dml/merge/rendering/TestMergeRendering.java rename to src/test/java/com/exasol/sql/dml/merge/rendering/MergeRenderingTest.java index b8c5e120..2c69c4d1 100644 --- a/src/test/java/com/exasol/sql/dml/merge/rendering/TestMergeRendering.java +++ b/src/test/java/com/exasol/sql/dml/merge/rendering/MergeRenderingTest.java @@ -14,7 +14,7 @@ import com.exasol.sql.dml.merge.Merge; // [utest->dsn~rendering.sql.merge~1] -class TestMergeRendering { +class MergeRenderingTest { private Merge merge; @BeforeEach() @@ -31,7 +31,7 @@ void testMerge() { void testMergeIntoUsingOn() { assertThat(this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))), + .on(eq(column("src", "c1"), column("dst", "c1"))), rendersTo("MERGE INTO dst USING src ON src.c1 = dst.c1")); } @@ -39,7 +39,7 @@ void testMergeIntoUsingOn() { void testMergeWhenMatchedUpdate() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenMatched() // .thenUpdate() // .setToDefault("c2") // @@ -54,22 +54,34 @@ void testMergeWhenMatchedUpdate() { void testMergeWhenMatchedUpdateWhere() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenMatched() // .thenUpdate() // .setToDefault("c2") // .set("c3", "foo") // - .set("c4", 42).where(gt(column("c5", "src"), integerLiteral(1000))); + .set("c4", 42).where(gt(column("src", "c5"), integerLiteral(1000))); assertThat(this.merge, rendersTo("MERGE INTO dst USING src ON src.c1 = dst.c1" // + " WHEN MATCHED THEN UPDATE SET c2 = DEFAULT, c3 = 'foo', c4 = 42" // + " WHERE src.c5 > 1000")); } + @Test + void testMergeWhenMatchedUpdateWithExpression() { + this.merge // + .using("src") // + .on(eq(column("src", "id"), column("dst", "id"))) // + .whenMatched() // + .thenUpdate() // + .set("amount", integerLiteral(2000)); + assertThat(this.merge, rendersTo("MERGE INTO dst USING src ON src.id = dst.id" // + + " WHEN MATCHED THEN UPDATE SET amount = 2000")); + } + @Test void testMergeWhenMatchedDelete() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenMatched() // .thenDelete(); assertThat(this.merge, rendersTo("MERGE INTO dst USING src ON src.c1 = dst.c1" // @@ -81,10 +93,10 @@ void testMergeWhenMatchedDelete() { void testMergeWhenMatchedDeleteWhere() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenMatched() // .thenDelete() // - .where(gt(column("c5", "src"), integerLiteral(1000))); + .where(gt(column("src", "c5"), integerLiteral(1000))); assertThat(this.merge, rendersTo("MERGE INTO dst USING src ON src.c1 = dst.c1" // + " WHEN MATCHED THEN DELETE WHERE src.c5 > 1000")); @@ -94,7 +106,7 @@ void testMergeWhenMatchedDeleteWhere() { void testMergeWhenNotMatchedInsertValues() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenNotMatched() // .thenInsert() // .values("foo", "bar"); @@ -106,11 +118,11 @@ void testMergeWhenNotMatchedInsertValues() { void testMergeWhenNotMatchedInsertValuesWhere() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenNotMatched() // .thenInsert() // .values("foo", "bar") // - .where(gt(column("c5", "src"), integerLiteral(1000))); + .where(gt(column("src", "c5"), integerLiteral(1000))); assertThat(this.merge, rendersTo("MERGE INTO dst USING src ON src.c1 = dst.c1" // + " WHEN NOT MATCHED THEN INSERT VALUES ('foo', 'bar') WHERE src.c5 > 1000")); } @@ -119,7 +131,7 @@ void testMergeWhenNotMatchedInsertValuesWhere() { void testMergeWhenNotMatchedInsertFieldValues() { this.merge // .using("src") // - .on(eq(column("c1", "src"), column("c1", "dst"))) // + .on(eq(column("src", "c1"), column("dst", "c1"))) // .whenNotMatched() // .thenInsert() // .field("c3", "c4") // @@ -131,7 +143,7 @@ void testMergeWhenNotMatchedInsertFieldValues() { @Test void testComplexMerge() { final Merge complexMerge = StatementFactory.getInstance().mergeInto("dst", "t1").using("src", "t2") // - .on(eq(column("c1", "t1"), column("c1", "t2"))); + .on(eq(column("t1", "c1"), column("t2", "c1"))); complexMerge.whenMatched() // .thenUpdate() // .setToDefault("c2") // diff --git a/src/test/java/com/exasol/sql/dql/select/rendering/TestGroupByRendering.java b/src/test/java/com/exasol/sql/dql/select/rendering/TestGroupByRendering.java index 4def2cbf..adbbf2dd 100644 --- a/src/test/java/com/exasol/sql/dql/select/rendering/TestGroupByRendering.java +++ b/src/test/java/com/exasol/sql/dql/select/rendering/TestGroupByRendering.java @@ -27,20 +27,20 @@ void testGroupByClause() { @Test void testGroupByClause2() { - assertThat(this.select.groupBy(column("city", "t")), rendersTo("SELECT * FROM t GROUP BY t.city")); + assertThat(this.select.groupBy(column("t", "city")), rendersTo("SELECT * FROM t GROUP BY t.city")); } @Test void testGroupByClauseMultipleColumns() { - assertThat(this.select.groupBy(column("city", "t"), column("order", "t"), column("price", "t")), + assertThat(this.select.groupBy(column("t", "city"), column("t", "order"), column("t", "price")), rendersTo("SELECT * FROM t GROUP BY t.city, t.order, t.price")); } @Test void testGroupByClauseMultipleColumnsWithHaving() { assertThat( - this.select.groupBy(column("city", "t"), column("order", "t"), column("price", "t")) - .having(lt(column("price", "t"), integerLiteral(10))), + this.select.groupBy(column("t", "city"), column("t", "order"), column("t", "price")) + .having(lt(column("t", "price"), integerLiteral(10))), rendersTo("SELECT * FROM t GROUP BY t.city, t.order, t.price HAVING t.price < 10")); } @@ -48,7 +48,7 @@ void testGroupByClauseMultipleColumnsWithHaving() { void testGroupByClauseMultipleColumnsWithMultipleHaving() { assertThat( this.select.groupBy(column("city"), column("order"), column("price")).having( - and(le(column("price", "t"), integerLiteral(10)), ne(column("price", "t"), integerLiteral(5)))), + and(le(column("t", "price"), integerLiteral(10)), ne(column("t", "price"), integerLiteral(5)))), rendersTo("SELECT * FROM t GROUP BY city, order, price HAVING (t.price <= 10) AND (t.price <> 5)")); } @@ -56,8 +56,8 @@ void testGroupByClauseMultipleColumnsWithMultipleHaving() { void testGroupByClauseMultipleColumnsWithMultipleHaving2() { assertThat( this.select.groupBy(column("city"), column("order"), column("price")) - .having(or(eq(column("city", "t"), stringLiteral("NEW YORK")), - eq(column("city", "t"), stringLiteral("MOSCOW")))), + .having(or(eq(column("t", "city"), stringLiteral("NEW YORK")), + eq(column("t", "city"), stringLiteral("MOSCOW")))), rendersTo( "SELECT * FROM t GROUP BY city, order, price HAVING (t.city = 'NEW YORK') OR (t.city = 'MOSCOW')")); } diff --git a/src/test/java/com/exasol/sql/dql/select/rendering/TestOrderByRendering.java b/src/test/java/com/exasol/sql/dql/select/rendering/TestOrderByRendering.java index 5d4ca492..3e93f2e0 100644 --- a/src/test/java/com/exasol/sql/dql/select/rendering/TestOrderByRendering.java +++ b/src/test/java/com/exasol/sql/dql/select/rendering/TestOrderByRendering.java @@ -21,49 +21,49 @@ void beforeEach() { @Test void testOrderByClause() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")), rendersTo("SELECT * FROM t ORDER BY t.city, t.price")); } @Test void testOrderByClauseDesc() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).desc(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).desc(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price DESC")); } @Test void testOrderByClauseAsc() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).asc(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).asc(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price ASC")); } @Test void testOrderByClauseAscAndDesc() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).asc().desc(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).asc().desc(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price DESC")); } @Test void testOrderByClauseDescAndAsc() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).desc().asc(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).desc().asc(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price ASC")); } @Test void testOrderByClauseNullsFirst() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).nullsFirst(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).nullsFirst(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price NULLS FIRST")); } @Test void testOrderByClauseNullsLast() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).nullsLast(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).nullsLast(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price NULLS LAST")); } @Test void testOrderByClauseNullsFirstAndLast() { - assertThat(this.select.orderBy(column("city", "t"), column("price", "t")).nullsFirst().nullsLast(), + assertThat(this.select.orderBy(column("t", "city"), column("t", "price")).nullsFirst().nullsLast(), rendersTo("SELECT * FROM t ORDER BY t.city, t.price NULLS LAST")); } } diff --git a/src/test/java/com/exasol/sql/expression/rendering/TestBooleanExpressionRenderer.java b/src/test/java/com/exasol/sql/expression/rendering/TestBooleanExpressionRenderer.java index 40e91f3c..c573e211 100644 --- a/src/test/java/com/exasol/sql/expression/rendering/TestBooleanExpressionRenderer.java +++ b/src/test/java/com/exasol/sql/expression/rendering/TestBooleanExpressionRenderer.java @@ -142,10 +142,10 @@ void testComparisonOperatorsWithColumnReference() { () -> assertThat("not equal", ne(column("city"), integerLiteral(2)), rendersTo("city <> 2")), // () -> assertThat("not equal", lt(column("city"), stringLiteral("Moscow")), rendersTo("city < 'Moscow'")), // - () -> assertThat("not equal", gt(column("city", "t"), stringLiteral("Moscow")), + () -> assertThat("not equal", gt(column("t", "city"), stringLiteral("Moscow")), rendersTo("t.city > 'Moscow'")), // - () -> assertThat("not equal", le(column("city", "t"), column("machi")), rendersTo("t.city <= machi")), // - () -> assertThat("not equal", ge(column("city", "t"), column("machi", "t")), + () -> assertThat("not equal", le(column("t", "city"), column("machi")), rendersTo("t.city <= machi")), // + () -> assertThat("not equal", ge(column("t", "city"), column("t", "machi")), rendersTo("t.city >= t.machi")) // ); }