Search in sources :

Example 16 with JoinedSource

use of io.confluent.ksql.parser.tree.JoinedSource in project ksql by confluentinc.

the class SqlFormatterTest method shouldFormatOuterJoinWithoutJoinWindow.

@Test
public void shouldFormatOuterJoinWithoutJoinWindow() {
    final Join join = new Join(leftAlias, ImmutableList.of(new JoinedSource(Optional.empty(), rightAlias, JoinedSource.Type.OUTER, criteria, Optional.empty())));
    final String expected = "`left` L\nFULL OUTER JOIN `right` R ON (('left.col0' = 'right.col0'))";
    assertEquals(expected, SqlFormatter.formatSql(join));
}
Also used : JoinedSource(io.confluent.ksql.parser.tree.JoinedSource) Join(io.confluent.ksql.parser.tree.Join) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 17 with JoinedSource

use of io.confluent.ksql.parser.tree.JoinedSource in project ksql by confluentinc.

the class SqlFormatterTest method shouldFormatOuterJoin.

@Test
public void shouldFormatOuterJoin() {
    final Join join = new Join(leftAlias, ImmutableList.of(new JoinedSource(Optional.empty(), rightAlias, JoinedSource.Type.OUTER, criteria, Optional.of(new WithinExpression(10, TimeUnit.SECONDS)))));
    final String expected = "`left` L\nFULL OUTER JOIN `right` R WITHIN 10 SECONDS ON" + " (('left.col0' = 'right.col0'))";
    assertEquals(expected, SqlFormatter.formatSql(join));
}
Also used : JoinedSource(io.confluent.ksql.parser.tree.JoinedSource) Join(io.confluent.ksql.parser.tree.Join) WithinExpression(io.confluent.ksql.parser.tree.WithinExpression) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 18 with JoinedSource

use of io.confluent.ksql.parser.tree.JoinedSource in project ksql by confluentinc.

the class SqlFormatterTest method shouldFormatLeftJoinWithoutJoinWindow.

@Test
public void shouldFormatLeftJoinWithoutJoinWindow() {
    final Join join = new Join(leftAlias, ImmutableList.of(new JoinedSource(Optional.empty(), rightAlias, JoinedSource.Type.LEFT, criteria, Optional.empty())));
    final String result = SqlFormatter.formatSql(join);
    final String expected = "`left` L\nLEFT OUTER JOIN `right` R ON (('left.col0' = 'right.col0'))";
    assertEquals(expected, result);
}
Also used : JoinedSource(io.confluent.ksql.parser.tree.JoinedSource) Join(io.confluent.ksql.parser.tree.Join) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 19 with JoinedSource

use of io.confluent.ksql.parser.tree.JoinedSource in project ksql by confluentinc.

the class SqlFormatterTest method shouldFormatMultipleLeftJoinWithWithin.

@Test
public void shouldFormatMultipleLeftJoinWithWithin() {
    final List<JoinedSource> rights = ImmutableList.of(new JoinedSource(Optional.empty(), rightAlias, JoinedSource.Type.LEFT, criteria, Optional.of(new WithinExpression(10, TimeUnit.SECONDS))), new JoinedSource(Optional.empty(), right2Alias, JoinedSource.Type.LEFT, criteria2, Optional.of(new WithinExpression(10, TimeUnit.SECONDS))));
    final Join join = new Join(leftAlias, rights);
    final String expected = "`left` L" + "\nLEFT OUTER JOIN `right` R WITHIN 10 SECONDS ON (('left.col0' = 'right.col0'))" + "\nLEFT OUTER JOIN `right2` R2 WITHIN 10 SECONDS ON (('left.col0' = 'right2.col0'))";
    assertEquals(expected, SqlFormatter.formatSql(join));
}
Also used : JoinedSource(io.confluent.ksql.parser.tree.JoinedSource) WithinExpression(io.confluent.ksql.parser.tree.WithinExpression) Join(io.confluent.ksql.parser.tree.Join) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 20 with JoinedSource

use of io.confluent.ksql.parser.tree.JoinedSource in project ksql by confluentinc.

the class SqlFormatterTest method shouldFormatInnerJoinWithoutJoinWindow.

@Test
public void shouldFormatInnerJoinWithoutJoinWindow() {
    final Join join = new Join(leftAlias, ImmutableList.of(new JoinedSource(Optional.empty(), rightAlias, JoinedSource.Type.INNER, criteria, Optional.empty())));
    final String expected = "`left` L\nINNER JOIN `right` R ON (('left.col0' = 'right.col0'))";
    assertEquals(expected, SqlFormatter.formatSql(join));
}
Also used : JoinedSource(io.confluent.ksql.parser.tree.JoinedSource) Join(io.confluent.ksql.parser.tree.Join) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

Join (io.confluent.ksql.parser.tree.Join)20 JoinedSource (io.confluent.ksql.parser.tree.JoinedSource)20 Test (org.junit.Test)20 WithinExpression (io.confluent.ksql.parser.tree.WithinExpression)10 PreparedStatement (io.confluent.ksql.parser.KsqlParser.PreparedStatement)9 CreateStreamAsSelect (io.confluent.ksql.parser.tree.CreateStreamAsSelect)9 Query (io.confluent.ksql.parser.tree.Query)9 Statement (io.confluent.ksql.parser.tree.Statement)9 TerminateQuery (io.confluent.ksql.parser.tree.TerminateQuery)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 StringContains.containsString (org.hamcrest.core.StringContains.containsString)9 WindowTimeClause (io.confluent.ksql.execution.windows.WindowTimeClause)2 AstNode (io.confluent.ksql.parser.tree.AstNode)2