2

Is there a way to drop the topic from KSQL? According to github it is possible, and I tried

DROP TOPIC my-topic
DROP TOPIC "my-topic"
DROP TOPIC 'my-topic'
DROP TOPIC `my-topic`

But neither of this commands works. I get message

 Message
-------------------------------------------------------------------------------
 io.confluent.ksql.util.KsqlException: No topic with name true was registered.
Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137
Lanayx
  • 2,731
  • 1
  • 23
  • 35

3 Answers3

8

KSQL topic is different concept than Kafka topic. KSQL topic is an internal concept for KSQL that represents a kafka topic along with metadata about that topic including the topic format. Since we do not expose KSQL topic externally you should not use it in KSQL statements. If you wanna delete a kafka topic, you should delete it from kafka. In future we plan to add topic management capability to KSQL.

Hojjat
  • 684
  • 4
  • 4
  • Hi @Hojjat as you stated that ksql topic is different from kafka topic , so can we create topic in ksql also. – aniketpant Dec 03 '22 at 13:29
2

You can delete the topic when you delete the stream/table with the command: drop stream my_stream delete topic or drop table my_table delete topic;

Emerzonic
  • 21
  • 1
  • 4
1

When you create stream or table using a TOPIC then the topic gets registered in KSQL As shown below.

ksql> SHOW TOPICS;

Kafka Topic| Registered| Partitions | Partition Replicas | Consumers | Consumer Groups` 

---------------------------------------------------------------------------------------

 __confluent.support.metric| false      | 1          | 1                  | 0         | 0

_confluent-ksql-default__command_topic | true       | 1          | 1                  | 0         | 0

_schemas                               | false      | 1          | 1                  | 0         | 0

connect-configs                        | false      | 1          | 1                  | 0         | 0

connect-offsets                        | false      | 25         | 1                  | 0         | 0

connect-statuses                       | false      | 5          | 1                  | 0         | 0

email-filters                          | false      | 4          | 1                  | 0         | 0

Please observe the email-filters topics is saying Registered is false because there is no corresponding stream and table.

So when you try to drop it. like this :

ksql> DROP TOPIC "email-filters";

 Message
-----------------------------------------
 No topic with name true was registered.
-----------------------------------------
ksql>

So the answer is correct by @Hojjat is correct.

This is the explanation.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Zamir Arif
  • 341
  • 2
  • 13