2

I am trying to create a table in KAFKA using Confluent's KSQLDB. I have easily use the UX provided by Confluent but I am trying to automate this process and hence I need a command line scipting capability to execute this task.

I have been able to use Confluent's KSQLDB REST interface to execute curl for simple commands ("LIST STREAMS") but more complicated statements, such as creating a table, seem to be unavailable, or there are no examples available to clone/use.

Does anyone have a command line script or a know of a console command to create a KSQLDB table (in Confluent's version of Kafka)?

Eric Broda
  • 6,701
  • 6
  • 48
  • 72

1 Answers1

3

You can use the /ksql endpoint. For example:

curl -s -X "POST" "http://localhost:8088/ksql" \
     -H "Content-Type: application/vnd.ksql.v1+json; charset=utf-8" \
     -d '{"ksql":"CREATE TABLE MOVEMENTS (PERSON VARCHAR KEY, LOCATION VARCHAR) WITH (VALUE_FORMAT='\''JSON'\'', KAFKA_TOPIC='\''movements'\'');"}'
Robin Moffatt
  • 30,382
  • 3
  • 65
  • 92