start-offset-before.td 2.4 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. #
  10. # Insert 10K values prior to restart and check that we never re-ingest
  11. # the entire topic as observed by the librdkafka counters
  12. #
  13. $ set count=1000
  14. $ set keyschema={
  15. "type": "record",
  16. "name": "Key",
  17. "fields": [
  18. {"name": "f1", "type": "string"}
  19. ]
  20. }
  21. $ set schema={
  22. "type" : "record",
  23. "name" : "test",
  24. "fields" : [
  25. {"name":"f2", "type":"string"}
  26. ]
  27. }
  28. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  29. $ kafka-create-topic topic=offset
  30. $ kafka-ingest format=avro topic=offset key-format=avro key-schema=${keyschema} schema=${schema} repeat=${count} timestamp=1
  31. {"f1": "a${kafka-ingest.iteration}"} {"f2": "a${kafka-ingest.iteration}"}
  32. $ kafka-ingest format=avro topic=offset key-format=avro key-schema=${keyschema} schema=${schema} repeat=${count} timestamp=2
  33. {"f1": "b${kafka-ingest.iteration}"} {"f2": "b${kafka-ingest.iteration}"}
  34. $ kafka-ingest format=avro topic=offset key-format=avro key-schema=${keyschema} schema=${schema} repeat=${count} timestamp=3
  35. {"f1": "c${kafka-ingest.iteration}"} {"f2": "c${kafka-ingest.iteration}"}
  36. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  37. URL '${testdrive.schema-registry-url}'
  38. );
  39. > CREATE SOURCE start_offset
  40. FROM KAFKA CONNECTION kafka_conn (START OFFSET = [100], TOPIC 'testdrive-offset-${testdrive.seed}')
  41. > CREATE TABLE start_offset_tbl FROM SOURCE start_offset (REFERENCE "testdrive-offset-${testdrive.seed}")
  42. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  43. ENVELOPE UPSERT
  44. > CREATE SOURCE kafka_time_offset
  45. FROM KAFKA CONNECTION kafka_conn (START TIMESTAMP=2, TOPIC 'testdrive-offset-${testdrive.seed}')
  46. > CREATE TABLE kafka_time_offset_tbl FROM SOURCE kafka_time_offset (REFERENCE "testdrive-offset-${testdrive.seed}")
  47. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  48. ENVELOPE UPSERT
  49. > SELECT COUNT(*) FROM start_offset_tbl;
  50. 2900
  51. > SELECT COUNT(*) FROM kafka_time_offset_tbl;
  52. 2000