github-6942.td 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 default-storage-size=1
  10. > DROP CLUSTER IF EXISTS gh_6942_cluster CASCADE;
  11. > CREATE CLUSTER gh_6942_cluster SIZE '${arg.default-storage-size}', REPLICATION FACTOR 1;
  12. > CREATE SOURCE auction_house
  13. IN CLUSTER gh_6942_cluster
  14. FROM LOAD GENERATOR AUCTION
  15. (TICK INTERVAL '0.01s', UP TO 1000)
  16. > CREATE TABLE accounts FROM SOURCE auction_house (REFERENCE accounts);
  17. > CREATE TABLE auctions FROM SOURCE auction_house (REFERENCE auctions);
  18. > CREATE TABLE bids FROM SOURCE auction_house (REFERENCE bids);
  19. > CREATE TABLE organizations FROM SOURCE auction_house (REFERENCE organizations);
  20. > CREATE TABLE users FROM SOURCE auction_house (REFERENCE users);
  21. > CREATE VIEW winning_bids AS
  22. SELECT DISTINCT ON (auctions.id) bids.*, auctions.item, auctions.seller
  23. FROM auctions, bids
  24. WHERE auctions.id = bids.auction_id
  25. AND bids.bid_time < auctions.end_time
  26. AND mz_now() >= auctions.end_time
  27. ORDER BY auctions.id,
  28. bids.bid_time DESC,
  29. bids.amount,
  30. bids.buyer
  31. > CREATE INDEX wins_by_item ON winning_bids (item)
  32. > CREATE INDEX wins_by_bidder ON winning_bids (buyer)
  33. > CREATE INDEX wins_by_seller ON winning_bids (seller)
  34. > CREATE VIEW fraud_activity AS
  35. SELECT w2.seller,
  36. w2.item AS seller_item,
  37. w2.amount AS seller_amount,
  38. w1.item buyer_item,
  39. w1.amount buyer_amount
  40. FROM winning_bids w1,
  41. winning_bids w2
  42. WHERE w1.buyer = w2.seller
  43. AND w2.amount > w1.amount
  44. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}/materialize
  45. DROP DATABASE materialize
  46. $ postgres-execute connection=postgres://mz_system@${testdrive.materialize-internal-sql-addr}/materialize
  47. CREATE DATABASE materialize