protobuf-defaults.td 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # Test that proto2 custom defaults are respected.
  11. $ file-append path=defaults.proto
  12. syntax = "proto2";
  13. message Defaults {
  14. enum Enum {
  15. ENUM0 = 0;
  16. ENUM1 = 1;
  17. }
  18. optional bool bool = 1 [default = true];
  19. optional int32 int32 = 2 [default = 42];
  20. optional int64 int64 = 3 [default = 42];
  21. optional float float = 4 [default = 42.0];
  22. optional double double = 5 [default = 42.0];
  23. optional bytes bytes = 6 [default = "aaa"];
  24. optional string string = 7 [default = "bbb"];
  25. optional Enum enum = 8 [default = ENUM1];
  26. }
  27. $ protobuf-compile-descriptors inputs=defaults.proto output=defaults.pb set-var=defaults-schema
  28. $ kafka-create-topic topic=defaults partitions=1
  29. $ kafka-ingest topic=defaults format=protobuf descriptor-file=defaults.pb message=Defaults
  30. {}
  31. > CREATE CONNECTION kafka_conn
  32. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  33. > CREATE SOURCE defaults
  34. IN CLUSTER ${arg.single-replica-cluster}
  35. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-defaults-${testdrive.seed}')
  36. > CREATE TABLE defaults_tbl FROM SOURCE defaults (REFERENCE "testdrive-defaults-${testdrive.seed}")
  37. FORMAT PROTOBUF MESSAGE '.Defaults' USING SCHEMA '${defaults-schema}'
  38. > SELECT * FROM defaults_tbl
  39. bool int32 int64 float double bytes string enum
  40. ----
  41. true 42 42 42 42 aaa bbb ENUM1