Search code examples
apache-kafka-streamsksqldb

How to properly create KsqlDB stream based on Kafka topic?


I'm attempting to create a KsqlDB stream (using KSQL CLI) in the following way:

CREATE STREAM orders_stream (
    OrderId BIGINT,
    Description VARCHAR
  ) WITH (
    KAFKA_TOPIC = ‘orders’,
    VALUE_FORMAT = 'JSON'
  );

I get this error:

line 5:19: mismatched input '‘' expecting {'NULL', 'TRUE', 'FALSE', '-', STRING, INTEGER_VALUE, DECIMAL_VALUE, FLOATING_POINT_VALUE, VARIABLE}
Statement: CREATE STREAM orders_stream (
    Ordered BIGINT,
    Description VARCHAR
  ) WITH (
    KAFKA_TOPIC = ‘orders’,
    VALUE_FORMAT = 'JSON'
  );
Caused by: line 5:19: mismatched input '‘' expecting {'NULL', 'TRUE', 'FALSE',
    '-', STRING, INTEGER_VALUE, DECIMAL_VALUE, FLOATING_POINT_VALUE, VARIABLE}
Caused by: org.antlr.v4.runtime.InputMismatchException

I can't seem to find the issue here. Any help is appreciated


Solution

  • Just change ‘orders’ to 'orders' , it works.

    ksql> CREATE STREAM orders_stream (

    OrderId BIGINT, Description VARCHAR ) WITH ( KAFKA_TOPIC = 'orders', PARTITIONS=1, REPLICAS=1, VALUE_FORMAT = 'JSON' );

    Message

    Stream created

    ksql>