Skip to content

Commit

Permalink
range-point and range-range cursors for scan
Browse files Browse the repository at this point in the history
  • Loading branch information
FiV0 committed Aug 4, 2023
1 parent 12eac5f commit e69c7c9
Show file tree
Hide file tree
Showing 10 changed files with 714 additions and 220 deletions.
546 changes: 476 additions & 70 deletions core/src/main/clojure/xtdb/operator/scan.clj

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/test/clojure/xtdb/as_of_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
:xt/system-from tt2
:xt/system-to end-of-time-zdt}]

(t/is (= #{replaced-v0-doc v1-doc}
;; TODO nil system-to #2655
(t/is (= #{(assoc replaced-v0-doc :xt/system-to nil)
(assoc v1-doc :xt/system-to nil)}
(set (tu/query-ra '[:scan {:table xt_docs}
[xt/id version
xt/valid-from xt/valid-to
Expand Down
16 changes: 16 additions & 0 deletions src/test/clojure/xtdb/datalog_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2348,3 +2348,19 @@
:end #time/zoned-date-time "2020-01-06T00:00Z[UTC]"}}}
(set (xt/q node '{:find [n valid-time] :where [($ :ints {:n n :xt/id 0 :xt/valid-time valid-time}
{:for-valid-time [:in #inst "2020-01-01" #inst "2020-01-06"]})]}))))))

(deftest test-no-zero-width-intervals
(xt/submit-tx tu/*node* [[:put :xt-docs {:xt/id 1 :v 1}]
[:put :xt-docs {:xt/id 1 :v 2}]
[:put :xt-docs {:xt/id 2 :v 1} {:for-valid-time [:in #inst "2020-01-01" #inst "2020-01-02"]}]])
(xt/submit-tx tu/*node* [[:put :xt-docs {:xt/id 2 :v 2} {:for-valid-time [:in #inst "2020-01-01" #inst "2020-01-02"]}]])
(t/is (= [{:v 2}]
(xt/q tu/*node*
'{:find [v]
:where [(match :xt-docs [{:xt/id 1} v] {:for-system-time :all-time})]}))
"no zero width system time intervals")
(t/is (= [{:v 2}]
(xt/q tu/*node*
'{:find [v]
:where [(match :xt-docs [{:xt/id 2} v] {:for-valid-time :all-time})]}))
"no zero width valid-time intervals"))
12 changes: 1 addition & 11 deletions src/test/clojure/xtdb/node_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@

(t/deftest test-multi-value-insert-423
(letfn [(expected [tt]
{[(util/->zdt #inst "2024-01-01") (util/->zdt util/end-of-time), tt tt]
"Happy 2024!",

;; weird? zero-width system-time so won't normally show up
[(util/->zdt #inst "2024-01-01") (util/->zdt #inst "2026-01-01"), tt tt]
"Happy 2024!",

[(util/->zdt #inst "2024-01-01") (util/->zdt #inst "2025-01-01"), tt (util/->zdt util/end-of-time)]
{[(util/->zdt #inst "2024-01-01") (util/->zdt #inst "2025-01-01"), tt (util/->zdt util/end-of-time)]
"Happy 2024!"

[(util/->zdt #inst "2025-01-01") (util/->zdt util/end-of-time), tt tt]
"Happy 2025!",

[(util/->zdt #inst "2025-01-01") (util/->zdt #inst "2026-01-01"), tt (util/->zdt util/end-of-time)]
"Happy 2025!",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ cat
query TI
SELECT T1.col1, AVG(t1.col2) FROM t1 GROUP BY T1.col1
----
30
2000
fish
1000
cat
3000
30
2000

query T
SELECT t1.col1 FROM T1 WHERE t1.col1 IN ( T1.COL1 )
----
30
fish
cat
30

query I
SELECT teeone.col2 FROM t1 AS TEEoNE WHERE TEEone.col1 = ( SELECT t1.col1 FROM T1 WHERE t1.col1 = teeONe.cOL1 ) ORDER BY teeone."CoL2"
Expand Down
26 changes: 13 additions & 13 deletions src/test/resources/xtdb/sql/logic_test/direct-sql/limit.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ INSERT INTO t1(xt$id, data) VALUES(1, 'foo'), (2, 'foo'), (3, 'foo'), (4, 'foo')
statement ok
UPDATE t1 SET data = [1000] WHERE t1.xt$id > 7

query IT nosort
query IT rowsort
SELECT t1.xt$id, t1.data FROM t1
----
1
foo
10
[1000]
11
[1000]
12
[1000]
2
foo
3
Expand All @@ -27,28 +33,22 @@ foo
[1000]
9
[1000]
10
[1000]
11
[1000]
12
[1000]

query IT nosort
query IT rowsort
SELECT t1.xt$id, t1.data FROM t1 LIMIT 5
----
1
foo
2
foo
3
foo
4
foo
5
foo
6
foo
8
[1000]

query IT nosort
query IT rowsort
SELECT t1.xt$id, t1.data FROM t1 WHERE t1.xt$id > 9 LIMIT 10
----
10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ SELECT 4 FROM foo
query I
SELECT (SELECT foo.xt$id FROM bar) FROM foo
----
1
2
1
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ INSERT INTO t3(xt$id, data) VALUES (2, [6, 7])
query T nosort
SELECT t3.data FROM t3
----
[2 3]
[6 7]
[2 3]

query T nosort
SELECT t3.data[2] FROM t3
----
3
7
3

skipif xtdb # see #546
query TT nosort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INSERT INTO t1(xt$id, start, end) VALUES(2, DATE '2100-01-01', DATE '3000-01-01'
statement ok
INSERT INTO t1(xt$id, start, end) VALUES(3, DATE '2000-01-01', DATE '2020-01-01')

query ITT nosort
query ITT rowsort
SELECT t1.xt$id, t1.start, t1.end FROM t1
----
1
Expand All @@ -36,13 +36,6 @@ SELECT t1.xt$id, t1.start, t1.end FROM t1 WHERE PERIOD (t1.start, t1.end) PRECED
2000-01-01
2020-01-01

query ITT nosort
SELECT t1.xt$id, t1.start, t1.end FROM t1 WHERE t1.SYSTEM_TIME CONTAINS PERIOD (t1.start, t1.end)
----
2
2100-01-01
3000-01-01

query ITT nosort
SELECT t1.xt$id, t1.start, t1.end FROM t1 WHERE PERIOD (t1.start, t1.end) PRECEDES t1.SYSTEM_TIME
----
Expand Down
Loading

0 comments on commit e69c7c9

Please sign in to comment.