rows_from.slt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/rows_from
  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. # not supported yet
  20. halt
  21. mode cockroach
  22. query II colnames
  23. SELECT * FROM ROWS FROM (generate_series(1,2), generate_series(4,8))
  24. ----
  25. generate_series generate_series
  26. 1 4
  27. 2 5
  28. NULL 6
  29. NULL 7
  30. NULL 8
  31. query II colnames
  32. SELECT * FROM ROWS FROM (generate_series(1,4), generate_series(4,5))
  33. ----
  34. generate_series generate_series
  35. 1 4
  36. 2 5
  37. 3 NULL
  38. 4 NULL
  39. query II colnames
  40. SELECT * FROM ROWS FROM (generate_series(1,0), generate_series(1,0))
  41. ----
  42. generate_series generate_series
  43. query II colnames
  44. SELECT * FROM ROWS FROM (generate_series(1,0), generate_series(1,1))
  45. ----
  46. generate_series generate_series
  47. NULL 1
  48. query II colnames
  49. SELECT * FROM ROWS FROM (generate_series(1,2), greatest(1,2,3,4))
  50. ----
  51. generate_series greatest
  52. 1 4
  53. 2 NULL
  54. query IT colnames
  55. SELECT * FROM ROWS FROM (generate_series(1,2), current_user)
  56. ----
  57. generate_series current_user
  58. 1 root
  59. 2 NULL
  60. query TI colnames
  61. SELECT * FROM ROWS FROM (current_user, generate_series(1,2))
  62. ----
  63. current_user generate_series
  64. root 1
  65. NULL 2
  66. query TT colnames
  67. SELECT * FROM ROWS FROM (current_user, current_user)
  68. ----
  69. current_user current_user
  70. root root
  71. query III colnames
  72. SELECT * FROM ROWS FROM (information_schema._pg_expandarray(array[4,5,6]), generate_series(10,15));
  73. ----
  74. x n generate_series
  75. 4 1 10
  76. 5 2 11
  77. 6 3 12
  78. NULL NULL 13
  79. NULL NULL 14
  80. NULL NULL 15
  81. # Regression test for materialize#27389.
  82. statement error pg_get_keywords\(\): set-returning functions must appear at the top level of FROM
  83. SELECT * FROM ROWS FROM(generate_series(length((pg_get_keywords()).word),10));