kafka-envelope-none.td 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 default-storage-size=1
  10. $ kafka-create-topic topic=missing_keys_or_values partitions=1
  11. > CREATE CONNECTION kafka_conn
  12. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  13. > CREATE CLUSTER missing_keys_or_values_cluster SIZE '${arg.default-storage-size}';
  14. > CREATE SOURCE missing_keys_or_values
  15. IN CLUSTER missing_keys_or_values_cluster
  16. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-missing_keys_or_values-${testdrive.seed}')
  17. KEY FORMAT TEXT
  18. VALUE FORMAT TEXT
  19. INCLUDE KEY
  20. ENVELOPE NONE
  21. # make sure a record with both key and value goes through
  22. $ kafka-ingest topic=missing_keys_or_values format=bytes key-format=bytes key-terminator=:
  23. hello:world
  24. > SELECT * FROM missing_keys_or_values
  25. key text
  26. -----------
  27. hello world
  28. # send a value without a key. key columns should be null
  29. $ kafka-ingest topic=missing_keys_or_values format=bytes omit-key=true
  30. foo
  31. > SELECT * FROM missing_keys_or_values
  32. key text
  33. -------------
  34. hello world
  35. <null> foo
  36. # send an empty record with neither key nor value, should be skipped
  37. $ kafka-ingest topic=missing_keys_or_values format=bytes omit-value=true omit-key=true
  38. > SELECT * FROM missing_keys_or_values
  39. key text
  40. -------------
  41. hello world
  42. <null> foo
  43. # send a key without a value, should error
  44. $ kafka-ingest topic=missing_keys_or_values key-format=bytes format=bytes omit-value=true
  45. bar
  46. ! SELECT * FROM missing_keys_or_values
  47. contains: Envelope error: Flat: Value not present for message