bytes.td 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. > CREATE TABLE data_tbl FROM SOURCE data (REFERENCE "testdrive-bytes-${testdrive.seed}")
  22. FORMAT BYTES
  23. INCLUDE OFFSET
  24. > SHOW COLUMNS FROM data_tbl
  25. name nullable type comment
  26. ------------------------------------
  27. data false bytea ""
  28. offset false uint8 ""
  29. > SELECT * FROM data_tbl
  30. data offset
  31. ------------------------
  32. "\\xc2\\xa91" 0
  33. "\\xc2\\xa92" 1
  34. # Test that CREATE SOURCE can specify a custom name for the column.
  35. > CREATE CLUSTER data_named_col_cluster SIZE '${arg.default-storage-size}';
  36. > CREATE SOURCE data_named_col
  37. IN CLUSTER data_named_col_cluster
  38. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-bytes-${testdrive.seed}')
  39. > CREATE TABLE data_named_col_tbl (named_col) FROM SOURCE data_named_col (REFERENCE "testdrive-bytes-${testdrive.seed}")
  40. FORMAT BYTES
  41. > SHOW COLUMNS FROM data_named_col_tbl
  42. name nullable type comment
  43. -----------------------------------
  44. named_col false bytea ""
  45. > CREATE CLUSTER data_offset_cluster SIZE '${arg.default-storage-size}';
  46. > CREATE SOURCE data_offset
  47. IN CLUSTER data_offset_cluster
  48. FROM KAFKA CONNECTION kafka_conn (START OFFSET=[1], TOPIC 'testdrive-bytes-${testdrive.seed}')
  49. > CREATE TABLE data_offset_tbl FROM SOURCE data_offset (REFERENCE "testdrive-bytes-${testdrive.seed}")
  50. FORMAT BYTES
  51. INCLUDE OFFSET
  52. > SELECT * FROM data_offset_tbl
  53. data offset
  54. ------------------------
  55. "\\xc2\\xa92" 1
  56. $ kafka-create-topic topic=bytes-partitions partitions=2
  57. $ kafka-ingest format=bytes topic=bytes-partitions timestamp=1 partition=0
  58. ©1
  59. $ kafka-ingest format=bytes topic=bytes-partitions timestamp=1 partition=1
  60. ©2
  61. > CREATE CLUSTER data_offset_2_cluster SIZE '${arg.default-storage-size}';
  62. > CREATE SOURCE data_offset_2
  63. IN CLUSTER data_offset_2_cluster
  64. FROM KAFKA CONNECTION kafka_conn (START OFFSET=[0,1], TOPIC 'testdrive-bytes-partitions-${testdrive.seed}')
  65. > CREATE TABLE data_offset_2_tbl FROM SOURCE data_offset_2 (REFERENCE "testdrive-bytes-partitions-${testdrive.seed}")
  66. FORMAT BYTES
  67. INCLUDE OFFSET
  68. > SELECT * FROM data_offset_2_tbl
  69. data offset
  70. ------------------------
  71. "\\xc2\\xa91" 0