protobuf-name.td 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. > CREATE TABLE qualified_absolute_path_tbl FROM SOURCE qualified_absolute_path (REFERENCE "testdrive-name-${testdrive.seed}")
  28. FORMAT PROTOBUF MESSAGE '.some.where.Name' USING SCHEMA '${name-schema}'
  29. > SELECT i FROM qualified_absolute_path_tbl
  30. i
  31. ---
  32. 42
  33. # Ingesting with the absolute path should work without the leading dot.
  34. > CREATE SOURCE absolute_path
  35. IN CLUSTER ${arg.single-replica-cluster}
  36. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-name-${testdrive.seed}')
  37. > CREATE TABLE absolute_path_tbl FROM SOURCE absolute_path (REFERENCE "testdrive-name-${testdrive.seed}")
  38. FORMAT PROTOBUF MESSAGE 'some.where.Name' USING SCHEMA '${name-schema}'
  39. > SELECT i FROM absolute_path_tbl
  40. i
  41. ---
  42. 42
  43. # Ingesting without the package prefix should fail.
  44. ! CREATE TABLE absolute_path_tbl FROM SOURCE absolute_path (REFERENCE "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 TABLE absolute_path_tbl FROM SOURCE absolute_path (REFERENCE "testdrive-name-${testdrive.seed}")
  48. FORMAT PROTOBUF MESSAGE '.Name' USING SCHEMA '${name-schema}'
  49. contains:protobuf message ".Name" not found in file descriptor set