protected Node visitCreateStreamAsSelect(final CreateStreamAsSelect node, final Object context) { return new CreateStreamAsSelect( node.getLocation(), node.getName(), (Query) process(node.getQuery(), context), node.isNotExists(), node.getProperties().entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, e -> (Expression) process(e.getValue(), context) )), node.getPartitionByColumn().isPresent() ? Optional.ofNullable( (Expression) process(node.getPartitionByColumn().get(), context)) : Optional.empty() ); }
@Test public void shouldRunCsasStatements() { // Given: final PreparedStatement<CreateStreamAsSelect> csas = new PreparedStatement<>("CSAS1", new CreateStreamAsSelect(SOME_NAME, query, false, emptyMap(), Optional.empty())); when(engine.parseStatements(anyString())).thenReturn(ImmutableList.of(csas)); // When: standaloneExecutor.start(); // Then: verify(engine).execute(csas, ksqlConfig, emptyMap()); }
@Override public Node visitCreateStreamAs(final SqlBaseParser.CreateStreamAsContext context) { Optional<Expression> partitionByColumn = Optional.empty(); if (context.identifier() != null) { partitionByColumn = Optional.of(new QualifiedNameReference( QualifiedName.of(getIdentifierText(context.identifier())))); } return new CreateStreamAsSelect( Optional.of(getLocation(context)), getQualifiedName(context.qualifiedName()), (Query) visitQuery(context.query()), context.EXISTS() != null, processTableProperties(context.tableProperties()), partitionByColumn ); }