Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: improve KEY and TIMESTAMP descriptions for CREATE STREAM and CREATE TABLE #1094

Merged
merged 1 commit into from
Mar 31, 2018

Conversation

miguno
Copy link
Contributor

@miguno miguno commented Mar 29, 2018

No description provided.

@miguno miguno requested a review from a team March 29, 2018 13:05
@miguno miguno force-pushed the 4.1.x-create-table-key-requirement branch from f1ff4bc to 5f80b78 Compare March 29, 2018 13:07
@miguno miguno requested a review from joel-hamill March 29, 2018 14:00
@@ -4,23 +4,27 @@
Message Keys
============

The `CREATE STREAM` and `CREATE TABLE` statements allow the user to specify the column that corresponds to the Kafka message key by setting the `KEY` property of the `WITH` clause. For example:
The ``CREATE STREAM`` and ``CREATE TABLE`` statements, which read data from a Kafka topic into a stream or table, allow you to specify a field/column in the Kafka message value that corresponds to the Kafka message key by setting the ``KEY`` property of the ``WITH`` clause.
Copy link
Contributor

@big-andy-coates big-andy-coates Mar 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't sound right to me. I thought the KEY property allowed a user to map the key of the message in Kafka to a column in the KSQL stream's/table's schema.

Have I got the wrong end of the stick?

The KEY is described in the syntax-reference.rst as:

Associates the message key in the Kafka topic with a column in the KSQL table. You must be
sure that the record key corresponds to the value in the key column and is in the right
format. For more information, see :ref:ksql_key_constraints

Which, if I'm honest, just doesn't make sense to me. When I read this I think that, by supplying WITH( KEY = "foo" ) then the value within each records key will be stored in the column called foo. But if that is true, then:

You must be sure that the record key corresponds to the value in the key column

Makes no sense, as they will always be the same, because KSQL is loading the record key into the key column.

I'm confused ! ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the KEY property allowed a user to map the key of the message in Kafka to a column in the KSQL stream's/table's schema.

Alas no. It would be great if it did, see #804. The key must currently be present in BOTH the message key and "somewhere" in the message value as well (= "duplicate key" requirement).

Copy link
Contributor

@rodesai rodesai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @miguno I think the second example will be very helpful to readers.

@miguno miguno merged commit 65bd01e into 4.1.x Mar 31, 2018
@miguno miguno deleted the 4.1.x-create-table-key-requirement branch April 4, 2018 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants