confluentinc / kafka-tutorials

Tutorials and Recipes for Apache Kafka
https://developer.confluent.io/tutorials
Apache License 2.0
16 stars 90 forks source link

Replace `latest_by_offset` with `CREATE SOURCE TABLE` #1041

Open ybyzek opened 2 years ago

ybyzek commented 2 years ago

Porting https://github.com/confluentinc/ksqldb-recipes/issues/158 here

From @mjsax

Using latest_by_offset is outdated. We should use the new CREATE SOURCE TABLE instead.

See discussion in https://github.com/confluentinc/ksqldb-recipes/pull/144#discussion_r789872110

Just to add more color: there are for sure cases when latest_by_offset might still make sense. We should decide on a case-by-case basis.

Note to self: this is how one recipe was updated to use CREATE SOURCE TABLE: https://github.com/confluentinc/ksqldb-recipes/commit/a051ebdc1785bf8344f30161b7d9bd6689b4a25a

ybyzek commented 2 years ago

Note, cannot use INSERT INTO when using CREATE SOURCE TABLE.

Better create the table for the topic and a second table as CT t2 AS SELECT * FROM t1

https://github.com/confluentinc/ksqldb-recipes/pull/144#discussion_r789872110