3

I am trying to test ksql in headless mode. I added the Create Table query in query file and started the server,

$path-to-ksql/bin/ksql-server-start \
  $path-to-ksql/etc/ksql/ksql-server.properties \
  --queries-file /tmp/ksql-queries/queries.sql \
  >path-to-logdirectory/ksql-server-1_`date '+%Y%m%d_%H_%M_%S'`.log 2>&1 &

The query file has following query.

create table TABLE_NAME  as
  select a, min(b)
  from STREAM_NAME
  WINDOW TUMBLING (size 1 minute)
  group by a;

However, I am getting following exception in logs.

Exception in thread "main" io.confluent.ksql.parser.exception.ParseFailedException: Parsing failed on KsqlEngine msg: STREAM_NAME does not exist.
        at io.confluent.ksql.KsqlEngine.parseQueries(KsqlEngine.java:278)
        at io.confluent.ksql.KsqlEngine.createQueries(KsqlEngine.java:593)

However, when I run the same query in interactive mode, it executes nicely. NOTE: Stream already exists in ksql. I am running 4.1.0 CLI verision.

Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137

1 Answers1

1

You must define the input stream (here: STREAM_NAME) in your /tmp/ksql-queries/queries.sql prior to running the CREATE TABLE statement.

That's because the headless KSQL cluster/deployment is not aware of the streams/tables you defined in your other, interactive KSQL cluster.

miguno
  • 14,498
  • 3
  • 47
  • 63