avro-resolution-types.td 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. # Make sure that we reject changes of basic column types even if the schema registry reports that the two
  12. # schemas are compatible. It is up to Materialize to reject the value
  13. #
  14. $ set int-col={"type": "record", "name": "schema_int_double", "fields": [ {"name": "f1", "type": "int"} ] }
  15. $ set double-col={"type": "record", "name": "schema_int_double", "fields": [ {"name": "f1", "type": "double"} ] }
  16. $ kafka-create-topic topic=resolution-int2double
  17. $ kafka-ingest format=avro topic=resolution-int2double schema=${int-col} timestamp=1
  18. {"f1": 123}
  19. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  20. URL '${testdrive.schema-registry-url}'
  21. );
  22. > CREATE CONNECTION kafka_conn
  23. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  24. > CREATE SOURCE resolution_int2double
  25. IN CLUSTER ${arg.single-replica-cluster}
  26. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-resolution-int2double-${testdrive.seed}')
  27. > CREATE TABLE resolution_int2double_tbl FROM SOURCE resolution_int2double (REFERENCE "testdrive-resolution-int2double-${testdrive.seed}")
  28. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  29. ENVELOPE NONE
  30. $ kafka-ingest format=avro topic=resolution-int2double schema=${double-col} timestamp=2
  31. {"f1": 234.456}
  32. ! SELECT * FROM resolution_int2double_tbl
  33. contains:Writer schema has type `Double`, but reader schema has type `Int` for field `schema_int_double.f1`
  34. ! SELECT * FROM resolution_int2double_tbl
  35. contains:failed to resolve Avro schema (id =