managed-cluster.td 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 keyschema={
  10. "type": "record",
  11. "name": "Key",
  12. "fields": [
  13. {"name": "key", "type": "string"}
  14. ]
  15. }
  16. $ set schema={
  17. "type" : "record",
  18. "name" : "test",
  19. "fields" : [
  20. {"name":"f1", "type":"string"},
  21. {"name":"f2", "type":"long"}
  22. ]
  23. }
  24. $ kafka-create-topic topic=upsert
  25. $ kafka-ingest format=avro topic=upsert key-format=avro key-schema=${keyschema} schema=${schema}
  26. {"key": "fish"} {"f1": "fish", "f2": 1000}
  27. {"key": "bird1"} {"f1":"goose", "f2": 1}
  28. {"key": "birdmore"} {"f1":"geese", "f2": 2}
  29. {"key": "mammal1"} {"f1": "moose", "f2": 1}
  30. {"key": "bird1"}
  31. {"key": "birdmore"} {"f1":"geese", "f2": 56}
  32. {"key": "mammalmore"} {"f1": "moose", "f2": 42}
  33. {"key": "mammal1"}
  34. {"key": "mammalmore"} {"f1":"moose", "f2": 2}
  35. > CREATE CONNECTION conn
  36. FOR KAFKA BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT
  37. > CREATE CONNECTION c_conn
  38. FOR CONFLUENT SCHEMA REGISTRY URL '${testdrive.schema-registry-url}'
  39. > DROP CLUSTER IF EXISTS storage_cluster CASCADE;
  40. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  41. ALTER SYSTEM SET enable_disk_cluster_replicas = true
  42. > CREATE CLUSTER storage_cluster SIZE '2-2', REPLICATION FACTOR 1, DISK = true
  43. > CREATE SOURCE upsert
  44. IN CLUSTER storage_cluster
  45. FROM KAFKA CONNECTION conn (TOPIC
  46. 'testdrive-upsert-${testdrive.seed}'
  47. )
  48. > CREATE TABLE upsert_tbl FROM SOURCE upsert (REFERENCE "testdrive-upsert-${testdrive.seed}")
  49. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION c_conn
  50. ENVELOPE UPSERT
  51. > SELECT * from upsert_tbl
  52. key f1 f2
  53. ---------------------------
  54. fish fish 1000
  55. birdmore geese 56
  56. mammalmore moose 2