use of io.confluent.ksql.parser.DefaultKsqlParser in project ksql by confluentinc.
the class ExpressionParseTestUtil method parseExpression.
public static Expression parseExpression(final String asText, final MetaStore metaStore) {
final KsqlParser parser = new DefaultKsqlParser();
final String ksql = String.format("SELECT %s FROM test1;", asText);
final ParsedStatement parsedStatement = parser.parse(ksql).get(0);
final PreparedStatement preparedStatement = parser.prepare(parsedStatement, metaStore);
final SingleColumn singleColumn = (SingleColumn) ((Query) preparedStatement.getStatement()).getSelect().getSelectItems().get(0);
return singleColumn.getExpression();
}
use of io.confluent.ksql.parser.DefaultKsqlParser in project ksql by confluentinc.
the class TopicCreateInjectorTest method setUp.
@Before
public void setUp() {
parser = new DefaultKsqlParser();
metaStore = new MetaStoreImpl(new InternalFunctionRegistry());
overrides = new HashMap<>();
config = new KsqlConfig(new HashMap<>());
injector = new TopicCreateInjector(topicClient, metaStore);
final KsqlTopic sourceTopic = new KsqlTopic("source", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
final KsqlStream<?> source = new KsqlStream<>("", SourceName.of("SOURCE"), SCHEMA, Optional.empty(), false, sourceTopic, false);
metaStore.putSource(source, false);
final KsqlTopic joinTopic = new KsqlTopic("jSource", KeyFormat.nonWindowed(FormatInfo.of(FormatFactory.KAFKA.name()), SerdeFeatures.of()), ValueFormat.of(FormatInfo.of(FormatFactory.JSON.name()), SerdeFeatures.of()));
final KsqlStream<?> joinSource = new KsqlStream<>("", SourceName.of("J_SOURCE"), SCHEMA, Optional.empty(), false, joinTopic, false);
metaStore.putSource(joinSource, false);
when(topicClient.describeTopic("source")).thenReturn(sourceDescription);
when(topicClient.isTopicExists("source")).thenReturn(true);
when(builder.withName(any())).thenReturn(builder);
when(builder.withWithClause(any(), any(), any())).thenReturn(builder);
when(builder.withSource(any())).thenReturn(builder);
when(builder.build()).thenReturn(new TopicProperties("name", 1, (short) 1));
}
Aggregations