Ejemplo n.º 1
0
 public static void loadTpchTopic(
     EmbeddedKafka embeddedKafka,
     TestingPrestoClient prestoClient,
     String topicName,
     QualifiedTableName tpchTableName) {
   try (CloseableProducer<Long, Object> producer = embeddedKafka.createProducer();
       KafkaLoader tpchLoader =
           new KafkaLoader(
               producer, topicName, prestoClient.getServer(), prestoClient.getDefaultSession())) {
     tpchLoader.execute(format("SELECT * from %s", tpchTableName));
   }
 }
Ejemplo n.º 2
0
  public static void installKafkaPlugin(
      EmbeddedKafka embeddedKafka,
      QueryRunner queryRunner,
      Map<SchemaTableName, KafkaTopicDescription> topicDescriptions) {
    KafkaPlugin kafkaPlugin = new KafkaPlugin();
    kafkaPlugin.setTableDescriptionSupplier(() -> topicDescriptions);
    queryRunner.installPlugin(kafkaPlugin);

    Map<String, String> kafkaConfig =
        ImmutableMap.of(
            "kafka.nodes",
            embeddedKafka.getConnectString(),
            "kafka.table-names",
            Joiner.on(",").join(topicDescriptions.keySet()),
            "kafka.connect-timeout",
            "120s",
            "kafka.default-schema",
            "default");
    queryRunner.createCatalog("kafka", "kafka", kafkaConfig);
  }