Search in sources :

Example 1 with ReservedInternalTopics

use of io.confluent.ksql.util.ReservedInternalTopics in project ksql by confluentinc.

the class InsertValuesExecutor method getDataSource.

private static DataSource getDataSource(final KsqlConfig ksqlConfig, final MetaStore metaStore, final InsertValues insertValues) {
    final DataSource dataSource = metaStore.getSource(insertValues.getTarget());
    if (dataSource == null) {
        throw new KsqlException("Cannot insert values into an unknown stream/table: " + insertValues.getTarget());
    }
    if (dataSource.getKsqlTopic().getKeyFormat().isWindowed()) {
        throw new KsqlException("Cannot insert values into windowed stream/table!");
    }
    final ReservedInternalTopics internalTopics = new ReservedInternalTopics(ksqlConfig);
    if (internalTopics.isReadOnly(dataSource.getKafkaTopicName())) {
        throw new KsqlException("Cannot insert values into read-only topic: " + dataSource.getKafkaTopicName());
    }
    if (dataSource.isSource()) {
        throw new KsqlException(String.format("Cannot insert values into read-only %s: %s", dataSource.getDataSourceType().getKsqlType().toLowerCase(), dataSource.getName().text()));
    }
    return dataSource;
}
Also used : ReservedInternalTopics(io.confluent.ksql.util.ReservedInternalTopics) KsqlException(io.confluent.ksql.util.KsqlException) DataSource(io.confluent.ksql.metastore.model.DataSource)

Example 2 with ReservedInternalTopics

use of io.confluent.ksql.util.ReservedInternalTopics in project ksql by confluentinc.

the class ListTopicsExecutor method listTopics.

private static Map<String, TopicDescription> listTopics(final KafkaTopicClient topicClient, final ConfiguredStatement<ListTopics> statement) {
    final ReservedInternalTopics internalTopics = new ReservedInternalTopics(statement.getSessionConfig().getConfig(false));
    final Set<String> topics = statement.getStatement().getShowAll() ? topicClient.listTopicNames() : internalTopics.removeHiddenTopics(topicClient.listTopicNames());
    // TreeMap is used to keep elements sorted
    return new TreeMap<>(topicClient.describeTopics(topics));
}
Also used : ReservedInternalTopics(io.confluent.ksql.util.ReservedInternalTopics) TreeMap(java.util.TreeMap)

Aggregations

ReservedInternalTopics (io.confluent.ksql.util.ReservedInternalTopics)2 DataSource (io.confluent.ksql.metastore.model.DataSource)1 KsqlException (io.confluent.ksql.util.KsqlException)1 TreeMap (java.util.TreeMap)1