Skip to content

Instantly share code, notes, and snippets.

@apurvam
Created April 24, 2018 22:15
Show Gist options
  • Save apurvam/2dbb55602e3e4f83bfc879929934802a to your computer and use it in GitHub Desktop.
Save apurvam/2dbb55602e3e4f83bfc879929934802a to your computer and use it in GitHub Desktop.
Example of how KSQL protects against dropping tables and streams which are in use.
ksql> show queries;
Query ID | Kafka Topic | Query String
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CSAS_PAGEVIEWS_ENRICHED | PAGEVIEWS_ENRICHED | CREATE STREAM pageviews_enriched AS SELECT users_original.userid AS userid, pageid, regionid, gender FROM pageviews_original LEFT JOIN users_original ON pageviews_original.userid = users_original.userid;
CSAS_PAGEVIEWS_FEMALE | PAGEVIEWS_FEMALE | CREATE STREAM pageviews_female AS SELECT * FROM pageviews_enriched WHERE gender = 'FEMALE';
CSAS_PAGEVIEWS_FEMALE_LIKE_89 | pageviews_enriched_r8_r9 | CREATE STREAM pageviews_female_like_89 WITH (kafka_topic='pageviews_enriched_r8_r9', value_format='DELIMITED') AS SELECT * FROM pageviews_female WHERE regionid LIKE '%_8' OR regionid LIKE '%_9';
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
For detailed information on a Query run: EXPLAIN <Query ID>;
ksql> drop stream PAGEVIEWS_ENRICHED;
Cannot drop the data source. The following queries read from this source: [CSAS_PAGEVIEWS_FEMALE] and the following queries write into this source: [CSAS_PAGEVIEWS_ENRICHED]. You need to terminate them before dropping this source.
ksql>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment