github-5873.td 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # Regression test for a panic fixed by https://github.com/MaterializeInc/materialize/pull/5873
  11. #
  12. $ set-sql-timeout duration=125ms
  13. > CREATE TABLE customer (
  14. c_custkey integer,
  15. c_name text NOT NULL,
  16. c_address text NOT NULL,
  17. c_nationkey integer NOT NULL,
  18. c_phone text NOT NULL,
  19. c_acctbal decimal(15, 2) NOT NULL,
  20. c_mktsegment text NOT NULL,
  21. c_comment text NOT NULL
  22. );
  23. > CREATE INDEX pk_customer_custkey ON customer (c_custkey);
  24. > CREATE INDEX fk_customer_nationkey ON customer (c_nationkey ASC);
  25. > CREATE TABLE orders (
  26. o_orderkey integer,
  27. o_custkey integer NOT NULL,
  28. o_orderstatus text NOT NULL,
  29. o_totalprice decimal(15, 2) NOT NULL,
  30. o_orderdate DATE NOT NULL,
  31. o_orderpriority text NOT NULL,
  32. o_clerk text NOT NULL,
  33. o_shippriority integer NOT NULL,
  34. o_comment text NOT NULL
  35. );
  36. > CREATE INDEX pk_orders_orderkey ON orders (o_orderkey);
  37. > CREATE INDEX fk_orders_custkey ON orders (o_custkey ASC);
  38. > CREATE TABLE lineitem (
  39. l_orderkey integer NOT NULL,
  40. l_partkey integer NOT NULL,
  41. l_suppkey integer NOT NULL,
  42. l_linenumber integer NOT NULL,
  43. l_quantity decimal(15, 2) NOT NULL,
  44. l_extendedprice decimal(15, 2) NOT NULL,
  45. l_discount decimal(15, 2) NOT NULL,
  46. l_tax decimal(15, 2) NOT NULL,
  47. l_returnflag text NOT NULL,
  48. l_linestatus text NOT NULL,
  49. l_shipdate date NOT NULL,
  50. l_commitdate date NOT NULL,
  51. l_receiptdate date NOT NULL,
  52. l_shipinstruct text NOT NULL,
  53. l_shipmode text NOT NULL,
  54. l_comment text NOT NULL
  55. );
  56. > CREATE INDEX pk_lineitem_orderkey_linenumber ON lineitem (l_orderkey, l_linenumber);
  57. > CREATE INDEX fk_lineitem_orderkey ON lineitem (l_orderkey ASC);
  58. > CREATE INDEX fk_lineitem_partkey ON lineitem (l_partkey ASC);
  59. > CREATE INDEX fk_lineitem_suppkey ON lineitem (l_suppkey ASC);
  60. > CREATE INDEX fk_lineitem_partsuppkey ON lineitem (l_partkey ASC, l_suppkey ASC);
  61. > SELECT o_orderkey , MIN( c_custkey ) , MAX( c_custkey )
  62. FROM lineitem JOIN orders ON ( l_commitDATE < o_orderdate + INTERVAL ' 1 MONTHS ' )
  63. JOIN customer ON ( o_custkey = c_custkey )
  64. WHERE l_receiptDATE = o_orderdate AND l_receiptDATE = o_orderdate + INTERVAL ' 6 DAYS ' AND l_shipDATE < o_orderdate GROUP BY 1;