sort.td 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 single-replica-cluster=quickstart
  10. $ set schema={
  11. "type": "record",
  12. "name": "row",
  13. "fields": [
  14. { "name": "quote", "type": "string" },
  15. { "name": "val", "type": "long" }
  16. ]
  17. }
  18. $ kafka-create-topic topic=foobar
  19. > CREATE CONNECTION kafka_conn
  20. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  21. > CREATE SOURCE foobar
  22. IN CLUSTER ${arg.single-replica-cluster}
  23. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-foobar-${testdrive.seed}')
  24. FORMAT AVRO USING SCHEMA '${schema}'
  25. $ kafka-ingest format=avro topic=foobar schema=${schema} timestamp=42
  26. {"quote": "I have a theory that it's impossible to prove anything, but I can't prove it.", "val": 2079}
  27. {"quote": "It was a virgin forest, a place where the Hand of Man had never set foot.", "val": 12345}
  28. {"quote": "If it pours before seven, it has rained by eleven.", "val": 12345}
  29. {"quote": "All power corrupts, but we need electricity.", "val": 12345}
  30. {"quote": "I want to read my new poem about pork brains and outer space ...", "val": 6745}
  31. {"quote": "You are magnetic in your bearing.", "val": 24223}
  32. {"quote": "Yes, but every time I try to see things your way, I get a headache.", "val": 21243}
  33. {"quote": "Ring around the collar.", "val": 1735}
  34. {"quote": "New York is real. The rest is done with mirrors.", "val": 25040}
  35. > SELECT val, quote FROM foobar ORDER BY quote LIMIT 5
  36. val quote
  37. --------------------------------------------------------------------------------------
  38. 12345 "All power corrupts, but we need electricity."
  39. 2079 "I have a theory that it's impossible to prove anything, but I can't prove it."
  40. 6745 "I want to read my new poem about pork brains and outer space ..."
  41. 12345 "If it pours before seven, it has rained by eleven."
  42. 12345 "It was a virgin forest, a place where the Hand of Man had never set foot."
  43. > SELECT val, quote FROM foobar ORDER BY quote ASC LIMIT 5
  44. val quote
  45. --------------------------------------------------------------------------------------
  46. 12345 "All power corrupts, but we need electricity."
  47. 2079 "I have a theory that it's impossible to prove anything, but I can't prove it."
  48. 6745 "I want to read my new poem about pork brains and outer space ..."
  49. 12345 "If it pours before seven, it has rained by eleven."
  50. 12345 "It was a virgin forest, a place where the Hand of Man had never set foot."
  51. > SELECT * FROM foobar ORDER BY quote DESC LIMIT 5
  52. quote val
  53. ----------------------------------------------------------------------------------
  54. "You are magnetic in your bearing." 24223
  55. "Yes, but every time I try to see things your way, I get a headache." 21243
  56. "Ring around the collar." 1735
  57. "New York is real. The rest is done with mirrors." 25040
  58. "It was a virgin forest, a place where the Hand of Man had never set foot." 12345
  59. # Test that the second-column sort works fine
  60. > SELECT * FROM foobar ORDER BY val, quote LIMIT 6
  61. quote val
  62. ---------
  63. "Ring around the collar." 1735
  64. "I have a theory that it's impossible to prove anything, but I can't prove it." 2079
  65. "I want to read my new poem about pork brains and outer space ..." 6745
  66. "All power corrupts, but we need electricity." 12345
  67. "If it pours before seven, it has rained by eleven." 12345
  68. "It was a virgin forest, a place where the Hand of Man had never set foot." 12345
  69. > SELECT * FROM foobar ORDER BY val, quote DESC LIMIT 6
  70. quote val
  71. ---------------------------------------------------------------------------------------
  72. "Ring around the collar." 1735
  73. "I have a theory that it's impossible to prove anything, but I can't prove it." 2079
  74. "I want to read my new poem about pork brains and outer space ..." 6745
  75. "It was a virgin forest, a place where the Hand of Man had never set foot." 12345
  76. "If it pours before seven, it has rained by eleven." 12345
  77. "All power corrupts, but we need electricity." 12345
  78. > SELECT val, quote FROM foobar ORDER BY quote OFFSET 5 ROWS
  79. val quote
  80. ----------------------------------------------------------------------------
  81. 25040 "New York is real. The rest is done with mirrors."
  82. 1735 "Ring around the collar."
  83. 21243 "Yes, but every time I try to see things your way, I get a headache."
  84. 24223 "You are magnetic in your bearing."
  85. > SELECT val, quote FROM foobar ORDER BY quote LIMIT 4 OFFSET 0 ROWS
  86. val quote
  87. --------------------------------------------------------------------------------------
  88. 12345 "All power corrupts, but we need electricity."
  89. 2079 "I have a theory that it's impossible to prove anything, but I can't prove it."
  90. 6745 "I want to read my new poem about pork brains and outer space ..."
  91. 12345 "If it pours before seven, it has rained by eleven."
  92. > SELECT val, quote FROM foobar ORDER BY val, quote LIMIT 3 OFFSET 2 ROWS
  93. val quote
  94. --------------------------------------------------------------------------------------
  95. 6745 "I want to read my new poem about pork brains and outer space ..."
  96. 12345 "All power corrupts, but we need electricity."
  97. 12345 "If it pours before seven, it has rained by eleven."
  98. > SELECT val, quote FROM foobar ORDER BY quote DESC LIMIT 5 OFFSET 6 ROWS
  99. val quote
  100. --------------------------------------------------------------------------------------
  101. 6745 "I want to read my new poem about pork brains and outer space ..."
  102. 2079 "I have a theory that it's impossible to prove anything, but I can't prove it."
  103. 12345 "All power corrupts, but we need electricity."
  104. > SELECT val, quote FROM foobar ORDER BY quote DESC LIMIT 4 OFFSET 10 ROWS
  105. val quote
  106. --------------------------------------------------------------------------------------
  107. > SELECT val, quote FROM foobar ORDER BY quote DESC OFFSET 10 ROWS
  108. val quote
  109. --------------------------------------------------------------------------------------
  110. > SELECT val, quote FROM foobar ORDER BY quote DESC OFFSET 0 ROWS
  111. val quote
  112. --------------------------------------------------------------------------------------
  113. 24223 "You are magnetic in your bearing."
  114. 21243 "Yes, but every time I try to see things your way, I get a headache."
  115. 1735 "Ring around the collar."
  116. 25040 "New York is real. The rest is done with mirrors."
  117. 12345 "It was a virgin forest, a place where the Hand of Man had never set foot."
  118. 12345 "If it pours before seven, it has rained by eleven."
  119. 6745 "I want to read my new poem about pork brains and outer space ..."
  120. 2079 "I have a theory that it's impossible to prove anything, but I can't prove it."
  121. 12345 "All power corrupts, but we need electricity."