-
Notifications
You must be signed in to change notification settings - Fork 287
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
avro: Add name strategy option for schema registry #3936
Closed
Closed
Commits on Dec 17, 2021
-
avro: Add name strategy option for schema registry
This is for issue pingcap#1147 When creating a changefeed with `--opts nameStrategy=topic` this now uses the topic name as basis for the schema registry. Before this PR the schema registry always used `{schema}_{table}` as basis. This solves the case where KSQL expect the topic name to be used as basis for the schema registry. == Example Setup a test environment and create the changefeed ``` tiup playground --without-monitor --tiflash 0 v5.3.0 confluent local services start ./bin/cdc server ./bin/cdc cli changefeed create --no-confirm \ --changefeed-id="simple-replication-task" \ --sort-engine="unified" \ --sink-uri="kafka://127.0.0.1:9092/cdctest?protocol=avro&kafka-version=2.8.0" \ --opts registry="http://127.0.0.1:8081" \ --opts nameStrategy=topic ``` To verify the `nameStrategy`: ``` $ ./bin/cdc cli changefeed query -c simple-replication-task | jq '.info.opts.nameStrategy' "topic" ``` Now let's create a table that uses this changefeed: ``` CREATE TABLE t1 (id INT PRIMARY KEY, n VARCHAR(200) NOT NULL, ts TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)); INSERT INTO t1(id, n) VALUES (1, 'test'); ``` This now shows up in KSQL like this: ``` ksql> SHOW TOPICS; Kafka Topic | Partitions | Partition Replicas --------------------------------------------------------------- cdctest | 3 | 1 default_ksql_processing_log | 1 | 1 --------------------------------------------------------------- ksql> PRINT cdctest FROM BEGINNING; Key format: AVRO or KAFKA_STRING Value format: AVRO rowtime: 2021/12/17 07:06:07.227 Z, key: {"id": 1}, value: {"id": 1, "n": "test", "ts": 1639724765242}, partition: 0 ^CTopic printing ceased ``` And in the schema registry: ``` $ curl -s http://127.0.0.1:8081/subjects | jq [ "cdctest-key", "cdctest-value" ] ``` This now allows us to do this: ``` ksql> CREATE STREAM t1str WITH (KAFKA_TOPIC='cdctest', VALUE_FORMAT='avro'); Message ---------------- Stream created ---------------- ksql> DESCRIBE t1str; Name : T1STR Field | Type ------------------------- ID | INTEGER N | VARCHAR(STRING) TS | TIMESTAMP ------------------------- For runtime statistics and query details run: DESCRIBE <Stream,Table> EXTENDED; ``` Note that we didnt' have to specify the columns in the `CREATE STREAM` comman as these were fetched from the schema registry. See also: - https://docs.ksqldb.io/en/latest/operate-and-deploy/schema-registry-integration/#schema-inference
Configuration menu - View commit details
-
Copy full SHA for e56fbaf - Browse repository at this point
Copy the full SHA e56fbafView commit details -
Configuration menu - View commit details
-
Copy full SHA for 15290e0 - Browse repository at this point
Copy the full SHA 15290e0View commit details
Commits on Dec 20, 2021
-
Configuration menu - View commit details
-
Copy full SHA for ac39db1 - Browse repository at this point
Copy the full SHA ac39db1View commit details -
Configuration menu - View commit details
-
Copy full SHA for b488245 - Browse repository at this point
Copy the full SHA b488245View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2186a29 - Browse repository at this point
Copy the full SHA 2186a29View commit details -
Configuration menu - View commit details
-
Copy full SHA for e222a61 - Browse repository at this point
Copy the full SHA e222a61View commit details -
Configuration menu - View commit details
-
Copy full SHA for 037e837 - Browse repository at this point
Copy the full SHA 037e837View commit details
Commits on Dec 30, 2021
-
Configuration menu - View commit details
-
Copy full SHA for ce3cae0 - Browse repository at this point
Copy the full SHA ce3cae0View commit details
Commits on Jan 5, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 20e9978 - Browse repository at this point
Copy the full SHA 20e9978View commit details
Commits on Jan 11, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 6292b80 - Browse repository at this point
Copy the full SHA 6292b80View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.