use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand 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.SqlCommand in project ksql by confluentinc.
the class CommandParserTest method shouldDefineStatementWithVariable.
@Test
public void shouldDefineStatementWithVariable() {
// Given:
final String defineVar = "DEFiNe word = 'walk${suffix}';";
// When:
List<SqlCommand> commands = parse(defineVar, ImmutableMap.of("suffix", "ing"));
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0), instanceOf(SqlDefineVariableCommand.class));
assertThat(((SqlDefineVariableCommand) commands.get(0)).getVariable(), is("word"));
assertThat(((SqlDefineVariableCommand) commands.get(0)).getValue(), is("walking"));
}
use of io.confluent.ksql.tools.migrations.util.CommandParser.SqlCommand 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.SqlCommand 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.SqlCommand in project ksql by confluentinc.
the class CommandParserTest method shouldParseDropConnectorStatement.
@Test
public void shouldParseDropConnectorStatement() {
// Given:
// The space at the end is to make sure that the regex doesn't capture it as a part of the name
final String dropConnector = "DRoP CONNEcTOR `jdbc-connector` ;";
// When:
List<SqlCommand> commands = parse(dropConnector);
// Then:
assertThat(commands.size(), is(1));
assertThat(commands.get(0).getCommand(), is(dropConnector));
assertThat(commands.get(0), instanceOf(SqlDropConnectorStatement.class));
assertThat(commands.get(0).getCommand(), is(dropConnector));
assertThat(((SqlDropConnectorStatement) commands.get(0)).getName(), is("`jdbc-connector`"));
}
Aggregations