protobuf-name.td 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 the various ways to specify the path to a Protobuf message.
  11. $ file-append path=name.proto
  12. syntax = "proto3";
  13. package some.where;
  14. message Name {
  15. int32 i = 1;
  16. }
  17. $ protobuf-compile-descriptors inputs=name.proto output=name.pb set-var=name-schema
  18. $ kafka-create-topic topic=name partitions=1
  19. $ kafka-ingest topic=name format=protobuf descriptor-file=name.pb message=some.where.Name
  20. {"i": 42}
  21. > CREATE CONNECTION kafka_conn
  22. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  23. # Ingesting with the fully-qualified absolute path should work.
  24. > CREATE SOURCE qualified_absolute_path
  25. IN CLUSTER ${arg.single-replica-cluster}
  26. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-name-${testdrive.seed}')
  27. FORMAT PROTOBUF MESSAGE '.some.where.Name' USING SCHEMA '${name-schema}'
  28. > SELECT i FROM qualified_absolute_path
  29. i
  30. ---
  31. 42
  32. # Ingesting with the absolute path should work without the leading dot.
  33. > CREATE SOURCE absolute_path
  34. IN CLUSTER ${arg.single-replica-cluster}
  35. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-name-${testdrive.seed}')
  36. FORMAT PROTOBUF MESSAGE 'some.where.Name' USING SCHEMA '${name-schema}'
  37. > SELECT i FROM absolute_path
  38. i
  39. ---
  40. 42
  41. # Ingesting without the package prefix should fail.
  42. ! CREATE SOURCE absolute_path
  43. IN CLUSTER ${arg.single-replica-cluster}
  44. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-name-${testdrive.seed}')
  45. FORMAT PROTOBUF MESSAGE 'Name' USING SCHEMA '${name-schema}'
  46. contains:protobuf message "Name" not found in file descriptor set
  47. ! CREATE SOURCE absolute_path
  48. IN CLUSTER ${arg.single-replica-cluster}
  49. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-name-${testdrive.seed}')
  50. FORMAT PROTOBUF MESSAGE '.Name' USING SCHEMA '${name-schema}'
  51. contains:protobuf message ".Name" not found in file descriptor set