kafka-data-formats.td 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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
  17. IN CLUSTER input_csv_cluster
  18. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-input_csv-${testdrive.seed}');
  19. > CREATE TABLE input_csv_tbl (first, second)
  20. FROM SOURCE input_csv (REFERENCE "testdrive-input_csv-${testdrive.seed}")
  21. FORMAT CSV WITH 2 COLUMNS;
  22. $ kafka-ingest format=bytes topic=input_csv
  23. 1,2
  24. 2,3
  25. > SELECT * from input_csv_tbl;
  26. first second
  27. -------------
  28. 1 2
  29. 2 3
  30. $ kafka-ingest format=bytes topic=input_csv_partitioned partition=0
  31. 1,2
  32. $ kafka-ingest format=bytes topic=input_csv_partitioned partition=1
  33. 2,3
  34. > CREATE CLUSTER input_csv_partitioned_cluster SIZE '${arg.default-storage-size}';
  35. > CREATE SOURCE input_csv_partitioned
  36. IN CLUSTER input_csv_partitioned_cluster
  37. FROM KAFKA CONNECTION kafka_conn (START OFFSET=[1,0], TOPIC 'testdrive-input_csv_partitioned-${testdrive.seed}');
  38. > CREATE TABLE input_csv_partitioned_tbl (first, second)
  39. FROM SOURCE input_csv_partitioned (REFERENCE "testdrive-input_csv_partitioned-${testdrive.seed}")
  40. FORMAT CSV WITH 2 COLUMNS;
  41. > SELECT * FROM input_csv_partitioned_tbl
  42. first second
  43. ------------
  44. 2 3