upsert-include-key-before.td 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #
  10. # Ingest records before restart and then delete some of them post-restart
  11. #
  12. $ set keyschema={
  13. "type": "record",
  14. "name": "Key",
  15. "fields": [
  16. {"name": "f1", "type": "long"},
  17. {"name": "key2", "type": "long"}
  18. ]
  19. }
  20. $ set schema={
  21. "type" : "record",
  22. "name" : "test",
  23. "fields" : [
  24. {"name":"f2", "type":"long"}
  25. ]
  26. }
  27. $ kafka-create-topic topic=include-key
  28. $ kafka-ingest format=avro topic=include-key key-format=avro key-schema=${keyschema} schema=${schema} repeat=10000
  29. {"f1": ${kafka-ingest.iteration}, "key2": 1} {"f2": ${kafka-ingest.iteration}}
  30. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  31. URL '${testdrive.schema-registry-url}'
  32. );
  33. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  34. > CREATE SOURCE include_key
  35. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-include-key-${testdrive.seed}')
  36. > CREATE TABLE include_key_tbl FROM SOURCE include_key (REFERENCE "testdrive-include-key-${testdrive.seed}")
  37. KEY FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  38. VALUE FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  39. INCLUDE KEY AS named
  40. ENVELOPE UPSERT
  41. > SELECT COUNT(*) FROM include_key_tbl;
  42. 10000