decimal.td 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. > CREATE TABLE data_tbl FROM SOURCE data (REFERENCE "testdrive-data-${testdrive.seed}")
  37. FORMAT AVRO USING SCHEMA '${schema}'
  38. > SELECT * FROM data_tbl
  39. 17.94
  40. -0.7