bytes.td 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. # Test ingestion of and selection from a simple bytes-formatted topic.
  11. $ kafka-create-topic topic=bytes partitions=1
  12. $ kafka-ingest format=bytes topic=bytes timestamp=1
  13. ©1
  14. ©2
  15. > CREATE CONNECTION kafka_conn
  16. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  17. > CREATE CLUSTER data_cluster SIZE '${arg.default-storage-size}';
  18. > CREATE SOURCE data
  19. IN CLUSTER data_cluster
  20. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-bytes-${testdrive.seed}')
  21. FORMAT BYTES
  22. INCLUDE OFFSET
  23. > SHOW COLUMNS FROM data
  24. name nullable type comment
  25. ------------------------------------
  26. data false bytea ""
  27. offset false uint8 ""
  28. > SELECT * FROM data
  29. data offset
  30. ------------------------
  31. "\\xc2\\xa91" 0
  32. "\\xc2\\xa92" 1
  33. # Test that CREATE SOURCE can specify a custom name for the column.
  34. > CREATE CLUSTER data_named_col_cluster SIZE '${arg.default-storage-size}';
  35. > CREATE SOURCE data_named_col (named_col)
  36. IN CLUSTER data_named_col_cluster
  37. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-bytes-${testdrive.seed}')
  38. FORMAT BYTES
  39. > SHOW COLUMNS FROM data_named_col
  40. name nullable type comment
  41. -----------------------------------
  42. named_col false bytea ""
  43. > CREATE CLUSTER data_offset_cluster SIZE '${arg.default-storage-size}';
  44. > CREATE SOURCE data_offset
  45. IN CLUSTER data_offset_cluster
  46. FROM KAFKA CONNECTION kafka_conn (START OFFSET=[1], TOPIC 'testdrive-bytes-${testdrive.seed}')
  47. FORMAT BYTES
  48. INCLUDE OFFSET
  49. > SELECT * FROM data_offset
  50. data offset
  51. ------------------------
  52. "\\xc2\\xa92" 1
  53. $ kafka-create-topic topic=bytes-partitions partitions=2
  54. $ kafka-ingest format=bytes topic=bytes-partitions timestamp=1 partition=0
  55. ©1
  56. $ kafka-ingest format=bytes topic=bytes-partitions timestamp=1 partition=1
  57. ©2
  58. > CREATE CLUSTER data_offset_2_cluster SIZE '${arg.default-storage-size}';
  59. > CREATE SOURCE data_offset_2
  60. IN CLUSTER data_offset_2_cluster
  61. FROM KAFKA CONNECTION kafka_conn (START OFFSET=[0,1], TOPIC 'testdrive-bytes-partitions-${testdrive.seed}')
  62. FORMAT BYTES
  63. INCLUDE OFFSET
  64. > SELECT * FROM data_offset_2
  65. data offset
  66. ------------------------
  67. "\\xc2\\xa91" 0