sort.td 7.4 KB

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