decimal.td 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 single-replica-cluster=quickstart
  10. # This test exercises decimals at the boundary (e.g., by sending them through
  11. # pgwire). Operations on decimals are more thoroughly tested in decimal.slt.
  12. $ set schema={
  13. "name": "row",
  14. "type": "record",
  15. "fields": [
  16. {
  17. "name": "a",
  18. "type": {
  19. "type": "bytes",
  20. "scale": 2,
  21. "precision": 15,
  22. "logicalType": "decimal"
  23. }
  24. }
  25. ]
  26. }
  27. $ kafka-create-topic topic=data
  28. $ kafka-ingest format=avro topic=data schema=${schema}
  29. {"a": [7, 2]}
  30. {"a": [186]}
  31. > CREATE CONNECTION kafka_conn
  32. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  33. > CREATE SOURCE data
  34. IN CLUSTER ${arg.single-replica-cluster}
  35. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-data-${testdrive.seed}')
  36. FORMAT AVRO USING SCHEMA '${schema}'
  37. > SELECT * FROM data
  38. 17.94
  39. -0.7