use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlInsertValues in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertNullValuesStatement.
@Test
public void shouldParseInsertNullValuesStatement() {
// When:
List<SqlCommand> commands = parse("INSERT INTO FOO VALUES (NULL);");
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`FOO`"));
assertThat(insertValues.getColumns(), is(Collections.emptyList()));
assertThat(insertValues.getValues().size(), is(1));
assertNull(toFieldType(insertValues.getValues().get(0)));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlInsertValues in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertValuesStatementWithExplicitFields.
@Test
public void shouldParseInsertValuesStatementWithExplicitFields() {
// When:
List<SqlCommand> commands = parse("INSERT INTO `foo` (col1, col2) VALUES (55, '40');");
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`foo`"));
assertThat(insertValues.getColumns(), is(ImmutableList.of("COL1", "COL2")));
assertThat(insertValues.getValues().size(), is(2));
assertThat(toFieldType(insertValues.getValues().get(0)), is(55));
assertThat(toFieldType(insertValues.getValues().get(1)), is("40"));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlInsertValues in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertValuesStatementWithVariables.
@Test
public void shouldParseInsertValuesStatementWithVariables() {
// When:
List<SqlCommand> commands = parse("INSERT INTO ${stream} VALUES (${num});", ImmutableMap.of("stream", "FOO", "num", "55"));
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`FOO`"));
assertThat(insertValues.getColumns().size(), is(0));
assertThat(insertValues.getValues().size(), is(1));
assertThat(toFieldType(insertValues.getValues().get(0)), is(55));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlInsertValues in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertValuesStatementWithExplicitQuoting.
@Test
public void shouldParseInsertValuesStatementWithExplicitQuoting() {
// When:
List<SqlCommand> commands = parse("INSERT INTO `foo` (`col1`) VALUES (55);");
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`foo`"));
assertThat(insertValues.getColumns(), is(ImmutableList.of("col1")));
assertThat(insertValues.getValues().size(), is(1));
assertThat(toFieldType(insertValues.getValues().get(0)), is(55));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlInsertValues in project ksql by confluentinc.
the class CommandParserTest method shouldParseInsertValuesStatement.
@Test
public void shouldParseInsertValuesStatement() {
// When:
List<SqlCommand> commands = parse("INSERT INTO FOO VALUES (55);");
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlInsertValues.class));
final SqlInsertValues insertValues = (SqlInsertValues) commands.get(0);
assertThat(insertValues.getSourceName(), is("`FOO`"));
assertThat(insertValues.getColumns(), is(Collections.emptyList()));
assertThat(insertValues.getValues().size(), is(1));
assertThat(toFieldType(insertValues.getValues().get(0)), is(55));
}
Aggregations