avro-nonnull-record.td 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # Regression test for database-issues#2237, in which non-nullable fields of nullable records
  11. # were not correctly handled.
  12. $ set writer-schema={
  13. "name": "row",
  14. "type": "record",
  15. "fields": [
  16. {
  17. "name": "a",
  18. "type": {
  19. "name": "b",
  20. "fields": [
  21. {"name": "b", "type": "int"},
  22. {"name": "c", "type": "int"}
  23. ],
  24. "type": "record"
  25. }
  26. }
  27. ]
  28. }
  29. $ kafka-create-topic topic=data
  30. $ kafka-ingest topic=data format=avro schema=${writer-schema}
  31. {"a": {"b": 1, "c": 1}}
  32. {"a": {"b": 2, "c": 1}}
  33. > CREATE CONNECTION kafka_conn
  34. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  35. > CREATE SOURCE basic
  36. IN CLUSTER ${arg.single-replica-cluster}
  37. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-data-${testdrive.seed}')
  38. FORMAT AVRO USING SCHEMA '${writer-schema}'
  39. > SELECT (b1.a).b, (b2.a).b FROM basic b1 LEFT JOIN basic b2 ON (b1.a).b = (b2.a).c
  40. 1 1
  41. 1 2
  42. 2 <null>