kafka-data-formats.td 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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=input_csv partitions=1
  11. $ kafka-create-topic topic=input_csv_partitioned partitions=2
  12. $ kafka-create-topic topic=input_proto
  13. > CREATE CONNECTION kafka_conn
  14. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  15. > CREATE CLUSTER input_csv_cluster SIZE '${arg.default-storage-size}';
  16. > CREATE SOURCE input_csv (first, second)
  17. IN CLUSTER input_csv_cluster
  18. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-input_csv-${testdrive.seed}')
  19. FORMAT CSV WITH 2 COLUMNS;
  20. $ kafka-ingest format=bytes topic=input_csv
  21. 1,2
  22. 2,3
  23. > SELECT * from input_csv;
  24. first second
  25. -------------
  26. 1 2
  27. 2 3
  28. $ kafka-ingest format=bytes topic=input_csv_partitioned partition=0
  29. 1,2
  30. $ kafka-ingest format=bytes topic=input_csv_partitioned partition=1
  31. 2,3
  32. > CREATE CLUSTER input_csv_partitioned_cluster SIZE '${arg.default-storage-size}';
  33. > CREATE SOURCE input_csv_partitioned (first, second)
  34. IN CLUSTER input_csv_partitioned_cluster
  35. FROM KAFKA CONNECTION kafka_conn (START OFFSET=[1,0], TOPIC 'testdrive-input_csv_partitioned-${testdrive.seed}')
  36. FORMAT CSV WITH 2 COLUMNS;
  37. > SELECT * FROM input_csv_partitioned
  38. first second
  39. ------------
  40. 2 3