use of org.apache.flink.table.operations.command.SetOperation in project flink by apache.
the class SetOperationParseStrategy method convert.
@Override
public Operation convert(String statement) {
Matcher matcher = pattern.matcher(statement.trim());
final List<String> operands = new ArrayList<>();
if (matcher.find()) {
if (matcher.group("key") != null) {
operands.add(matcher.group("key"));
operands.add(matcher.group("quotedVal") != null ? matcher.group("quotedVal") : matcher.group("val"));
}
}
// only capture SET
if (operands.isEmpty()) {
return new SetOperation();
} else if (operands.size() == 2) {
return new SetOperation(operands.get(0), operands.get(1));
} else {
// impossible
throw new TableException(String.format("Failed to convert the statement to SET operation: %s.", statement));
}
}
use of org.apache.flink.table.operations.command.SetOperation in project flink by apache.
the class SqlToOperationConverterTest method testSet.
@Test
public void testSet() {
Operation operation1 = parse("SET", SqlDialect.DEFAULT);
assertThat(operation1).isInstanceOf(SetOperation.class);
SetOperation setOperation1 = (SetOperation) operation1;
assertThat(setOperation1.getKey()).isNotPresent();
assertThat(setOperation1.getValue()).isNotPresent();
Operation operation2 = parse("SET 'test-key' = 'test-value'", SqlDialect.DEFAULT);
assertThat(operation2).isInstanceOf(SetOperation.class);
SetOperation setOperation2 = (SetOperation) operation2;
assertThat(setOperation2.getKey()).hasValue("test-key");
assertThat(setOperation2.getValue()).hasValue("test-value");
}
Aggregations