avro-resolution-less-columns.td 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. $ set-arg-default single-replica-cluster=quickstart
  10. #
  11. # Allow a writer schema that has a smaller number of columns if the reader schema has specified a default
  12. #
  13. $ set 2columns={"type": "record", "name": "schema_less_columns", "fields": [ {"name": "f1", "type": "string", "default": "default_f1"} , {"name": "f2", "type": "string", "default": "default_f2"}] }
  14. $ set 1column={"type": "record", "name": "schema_less_columns", "fields": [ {"name": "f1", "type": "string"} ] }
  15. $ kafka-create-topic topic=resolution-2to1
  16. $ kafka-ingest format=avro topic=resolution-2to1 schema=${2columns} timestamp=1
  17. {"f1": "val_f1a", "f2": "val_f2a"}
  18. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  19. URL '${testdrive.schema-registry-url}'
  20. );
  21. > CREATE CONNECTION kafka_conn
  22. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  23. > CREATE SOURCE resolution_2to1
  24. IN CLUSTER ${arg.single-replica-cluster}
  25. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-resolution-2to1-${testdrive.seed}')
  26. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  27. ENVELOPE NONE
  28. $ kafka-ingest format=avro topic=resolution-2to1 schema=${1column} timestamp=2
  29. {"f1": "val_f1b"}
  30. > SELECT * FROM resolution_2to1
  31. f1 f2
  32. ---
  33. val_f1a val_f2a
  34. val_f1b default_f2