kafka-envelope-none.td 2.0 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-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. > CREATE TABLE missing_keys_or_values_tbl FROM SOURCE missing_keys_or_values (REFERENCE "testdrive-missing_keys_or_values-${testdrive.seed}")
  18. KEY FORMAT TEXT
  19. VALUE FORMAT TEXT
  20. INCLUDE KEY
  21. ENVELOPE NONE
  22. # make sure a record with both key and value goes through
  23. $ kafka-ingest topic=missing_keys_or_values format=bytes key-format=bytes key-terminator=:
  24. hello:world
  25. > SELECT * FROM missing_keys_or_values_tbl
  26. key text
  27. -----------
  28. hello world
  29. # send a value without a key. key columns should be null
  30. $ kafka-ingest topic=missing_keys_or_values format=bytes omit-key=true
  31. foo
  32. > SELECT * FROM missing_keys_or_values_tbl
  33. key text
  34. -------------
  35. hello world
  36. <null> foo
  37. # send an empty record with neither key nor value, should be skipped
  38. $ kafka-ingest topic=missing_keys_or_values format=bytes omit-value=true omit-key=true
  39. > SELECT * FROM missing_keys_or_values_tbl
  40. key text
  41. -------------
  42. hello world
  43. <null> foo
  44. # send a key without a value, should error
  45. $ kafka-ingest topic=missing_keys_or_values key-format=bytes format=bytes omit-value=true
  46. bar
  47. ! SELECT * FROM missing_keys_or_values_tbl
  48. contains: Envelope error: Flat: Value not present for message