github-6744.td 1.5 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. #
  10. # Test for the issue uncovered in a previous version of this PR
  11. # issue: https://github.com/MaterializeInc/materialize/pull/6291#issuecomment-816457944
  12. # fix: https://github.com/MaterializeInc/materialize/pull/6291/commits/71bcd461446796e178584133a4dd232b4cef8382
  13. #
  14. > CREATE TABLE customer (
  15. c_custkey integer
  16. );
  17. > CREATE TABLE orders (
  18. o_orderkey integer,
  19. o_custkey integer NOT NULL
  20. );
  21. > CREATE INDEX pk_orders_orderkey ON orders (o_orderkey);
  22. > CREATE INDEX fk_orders_custkey ON orders (o_custkey ASC);
  23. > CREATE TABLE lineitem (
  24. l_orderkey integer NOT NULL
  25. );
  26. > INSERT INTO "customer" VALUES (1),(14),(15);
  27. > INSERT INTO lineitem VALUES ( 176);
  28. > CREATE MATERIALIZED VIEW v1 AS
  29. SELECT * FROM lineitem JOIN orders ON ( l_orderkey = o_orderkey ) JOIN customer ON ( o_custkey = c_custkey );
  30. > INSERT INTO orders VALUES ( 176, 14);
  31. > CREATE VIEW v1_nonmaterialized AS
  32. SELECT * FROM lineitem JOIN orders ON ( l_orderkey = o_orderkey ) JOIN customer ON ( o_custkey = c_custkey );
  33. # 1 row expected; prior to the fix 2 rows were returned
  34. > SELECT * FROM v1;
  35. 176 176 14 14
  36. > SELECT * FROM v1_nonmaterialized;
  37. 176 176 14 14