values.slt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/values
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. mode cockroach
  20. # Tests for the implicit one row, zero column values operator.
  21. query I
  22. SELECT 1
  23. ----
  24. 1
  25. query I
  26. SELECT 1 + 2
  27. ----
  28. 3
  29. query III colnames
  30. VALUES (1, 2, 3), (4, 5, 6)
  31. ----
  32. column1 column2 column3
  33. 1 2 3
  34. 4 5 6
  35. query I
  36. VALUES (length('a')), (1 + length('a')), (length('abc')), (length('ab') * 2)
  37. ----
  38. 1
  39. 2
  40. 3
  41. 4
  42. query I
  43. SELECT a + b FROM (VALUES (1, 2), (3, 4), (5, 6)) AS v(a, b)
  44. ----
  45. 3
  46. 7
  47. 11
  48. query error pgcode 42601 VALUES expression has varying number of columns: 2 vs 1
  49. VALUES (1), (2, 3)
  50. query I
  51. VALUES (1), (1), (2), (3) ORDER BY 1 DESC LIMIT 3
  52. ----
  53. 3
  54. 2
  55. 1
  56. query error pgcode 42703 column "z" does not exist
  57. VALUES (1), (1), (2), (3) ORDER BY z
  58. # subqueries can be evaluated in VALUES
  59. query I
  60. VALUES ((SELECT 1)), ((SELECT 2))
  61. ----
  62. 1
  63. 2
  64. query error pgcode 42804 invalid input syntax for type integer
  65. VALUES (NULL, 1), (2, NULL), (NULL, 'a')