avro-resolution-logical-type-default.td 1.5 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. # Attempt to resolve schemas with a logical type involving a default
  12. #
  13. $ set writer={"type": "record", "name": "row", "fields": [ ] }
  14. $ set reader={"type": "record", "name": "row", "fields": [ {"name": "f1", "default": 0, "type": { "logicalType": "timestamp-micros", "type": "long" } } ] }
  15. $ kafka-create-topic topic=resolution
  16. $ kafka-ingest format=avro topic=resolution schema=${writer} timestamp=1
  17. {}
  18. $ kafka-ingest format=avro topic=resolution schema=${reader} timestamp=2
  19. {"f1": 123 }
  20. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  21. URL '${testdrive.schema-registry-url}'
  22. );
  23. > CREATE CONNECTION kafka_conn
  24. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  25. > CREATE SOURCE resolution
  26. IN CLUSTER ${arg.single-replica-cluster}
  27. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-resolution-${testdrive.seed}')
  28. > CREATE TABLE resolution_tbl FROM SOURCE resolution (REFERENCE "testdrive-resolution-${testdrive.seed}")
  29. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  30. ENVELOPE NONE
  31. > SELECT f1 FROM resolution_tbl
  32. "1970-01-01 00:00:00"
  33. "1970-01-01 00:00:00.000123"