Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add crdb/order_by.slt #209

Merged
merged 3 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2024-01-17
toolchain: nightly-2024-04-26
override: true
components: rustfmt, clippy

Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2024-01-17
toolchain: nightly-2024-04-26
override: true
components: rustfmt, clippy

Expand All @@ -74,7 +74,7 @@ jobs:
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2024-01-17
toolchain: nightly-2024-04-26
override: true
components: rustfmt, clippy

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ csv = { version = "1.3.0" }
dirs = { version = "5.0.1" }
env_logger = { version = "0.11.3", optional = true }
futures = { version = "0.3.30" }
futures-async-stream = { version = "0.2.10" }
futures-async-stream = { version = "0.2.11" }
integer-encoding = { version = "3.0.4" }
itertools = { version = "0.12.1" }
kip_db = { version = "0.1.2-alpha.26" }
kip_db = { version = "0.1.2-alpha.26.fix1" }
lazy_static = { version = "1.4.0" }
log = { version = "0.4.21", optional = true }
ordered-float = { version = "4.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-01-18
nightly-2024-04-27
2 changes: 1 addition & 1 deletion src/binder/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a, 'b, T: Transaction> Binder<'a, 'b, T> {
return_orderby.push(SortField::new(
expr,
asc.map_or(true, |asc| asc),
nulls_first.map_or(true, |first| first),
nulls_first.map_or(false, |first| first),
));
}
Some(return_orderby)
Expand Down
3 changes: 1 addition & 2 deletions src/execution/volcano/dql/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ pub(crate) fn sort(
let mut key = Vec::new();

expr.eval(&tuple, schema)?.memcomparable_encode(&mut key)?;
key.push(if *nulls_first { u8::MIN } else { u8::MAX });

if !asc {
for byte in key.iter_mut() {
*byte ^= 0xFF;
}
}
key.push(if *nulls_first { u8::MIN } else { u8::MAX });
full_key.extend(key);
}
Ok::<(Tuple, Vec<u8>), DatabaseError>((tuple, full_key))
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![feature(iterator_try_collect)]
#![feature(slice_pattern)]
#![feature(is_sorted)]
#![feature(stmt_expr_attributes)]
extern crate core;
pub mod binder;
pub mod catalog;
Expand Down
1 change: 1 addition & 0 deletions src/optimizer/heuristic/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::optimizer::rule::normalization::NormalizationRuleImpl;
/// A batch of rules.
#[derive(Clone)]
pub struct HepBatch {
#[allow(dead_code)]
pub name: String,
pub strategy: HepBatchStrategy,
pub rules: Vec<NormalizationRuleImpl>,
Expand Down
3 changes: 3 additions & 0 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ impl TryFrom<sqlparser::ast::DataType> for LogicalType {
char_unit.unwrap_or(CharLengthUnits::Characters),
))
}
sqlparser::ast::DataType::String => {
Ok(LogicalType::Varchar(None, CharLengthUnits::Characters))
}
sqlparser::ast::DataType::Float(_) => Ok(LogicalType::Float),
sqlparser::ast::DataType::Double | sqlparser::ast::DataType::DoublePrecision => {
Ok(LogicalType::Double)
Expand Down
48 changes: 24 additions & 24 deletions tests/slt/crdb/join.slt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ INSERT INTO onecolumn(id, x) VALUES (0, 44), (1, NULL), (2, 42)
query II
SELECT * FROM onecolumn AS a(aid, x) CROSS JOIN onecolumn AS b(bid, y) order by x
----
1 null 0 44
1 null 1 null
1 null 2 42
2 42 0 44
2 42 1 null
2 42 2 42
0 44 0 44
0 44 1 null
0 44 2 42
1 null 0 44
1 null 1 null
1 null 2 42

# FIXME
# statement error 1065
Expand All @@ -45,16 +45,16 @@ SELECT * FROM onecolumn AS a NATURAL JOIN onecolumn as b order by a.x desc
query II
SELECT * FROM onecolumn AS a(aid, x) LEFT OUTER JOIN onecolumn AS b(bid, y) ON a.x = b.y order by a.x
----
1 null null null
2 42 2 42
0 44 0 44
1 null null null

query I
SELECT * FROM onecolumn AS a LEFT OUTER JOIN onecolumn AS b USING(x) ORDER BY x
----
1 null null
2 42 2
0 44 0
1 null null

# FIXME
# statement error 1065
Expand All @@ -63,31 +63,31 @@ SELECT * FROM onecolumn AS a LEFT OUTER JOIN onecolumn AS b USING(x) ORDER BY x
query I
SELECT * FROM onecolumn AS a NATURAL LEFT OUTER JOIN onecolumn AS b order by a.x
----
1 null
2 42
0 44
1 null

query II
SELECT * FROM onecolumn AS a(aid, x) RIGHT OUTER JOIN onecolumn AS b(bid, y) ON a.x = b.y order by x
----
null null 1 null
2 42 2 42
0 44 0 44
null null 1 null

query I
SELECT * FROM onecolumn AS a RIGHT OUTER JOIN onecolumn AS b USING(x) ORDER BY x
----
null null 1
2 42 2
0 44 0
null null 1

# FIXME: The fields output by Using are determined by JoinType. At this time, because it is a Right Outer Join, the first row of results should be (1 null).
query I
SELECT * FROM onecolumn AS a NATURAL RIGHT OUTER JOIN onecolumn AS b order by x
----
null null
2 42
0 44
null null

statement ok
drop table if exists onecolumn_w
Expand Down Expand Up @@ -120,29 +120,29 @@ INSERT INTO othercolumn(o_id, x) VALUES (0, 43),(1, 42),(2, 16)
query II
SELECT * FROM onecolumn AS a FULL OUTER JOIN othercolumn AS b ON a.x = b.x ORDER BY a.x,b.x
----
1 null null null
null null 2 16
null null 0 43
2 42 1 42
0 44 null null
null null 2 16
null null 0 43
1 null null null

query II
SELECT * FROM onecolumn AS a full OUTER JOIN othercolumn AS b ON a.x = b.x and a.x > 16 order by a.x
----
2 42 1 42
0 44 null null
null null 0 43
null null 2 16
1 null null null
2 42 1 42
0 44 null null

query II
SELECT * FROM onecolumn AS a full OUTER JOIN othercolumn AS b ON a.x = b.x and b.x > 16 order by b.x,a.x
----
1 null null null
0 44 null null
null null 2 16
2 42 1 42
null null 0 43
0 44 null null
1 null null null

# TODO: Full Join on nested loop join
# query II
Expand Down Expand Up @@ -212,9 +212,9 @@ SELECT * FROM empty AS a JOIN onecolumn AS b USING(x)
query IT
SELECT * FROM onecolumn AS a(aid, x) LEFT OUTER JOIN empty AS b(bid, y) ON a.x = b.y ORDER BY a.x
----
null null 1 null
null null 2 42
null null 0 44
null null 1 null

# FIXME: The fields output by Using are determined by JoinType.
# query I
Expand All @@ -240,9 +240,9 @@ SELECT * FROM onecolumn AS a RIGHT OUTER JOIN empty AS b USING(x)
query II
SELECT * FROM empty AS a(aid, x) FULL OUTER JOIN onecolumn AS b(bid, y) ON a.x = b.y ORDER BY b.y
----
null null 1 null
null null 2 42
null null 0 44
null null 1 null

statement ok
SELECT * FROM empty AS a FULL OUTER JOIN onecolumn AS b USING(x) ORDER BY x
Expand Down Expand Up @@ -302,23 +302,23 @@ SELECT o.x, t.y FROM onecolumn o INNER JOIN twocolumn t ON (o.x=t.x AND t.y=53)
query IT
SELECT o.x, t.y FROM onecolumn o LEFT OUTER JOIN twocolumn t ON (o.x=t.x AND t.y=53) order by o.x
----
null null
42 53
44 null
null null

query II
SELECT o.x, t.y FROM onecolumn o LEFT OUTER JOIN twocolumn t ON (o.x=t.x AND o.x=44) order by o.x
----
null null
42 null
44 51
null null

query II
SELECT o.x, t.y FROM onecolumn o LEFT OUTER JOIN twocolumn t ON (o.x=t.x AND t.x=44) order by o.x
----
null null
42 null
44 51
null null

# TODO: Full Join on nested loop join
# query
Expand Down Expand Up @@ -365,18 +365,18 @@ null null 2 4 false
query III
SELECT * FROM a FULL OUTER JOIN b ON a.i = b.i order by b
----
0 1 null null null
null null 2 4 false
1 2 0 2 true
2 3 1 3 true
0 1 null null null

query III
SELECT * FROM a FULL OUTER JOIN b ON (a.i = b.i and a.i>2) ORDER BY a.i, b.i
----
null null 2 4 false
0 1 null null null
1 2 0 2 true
2 3 1 3 true
null null 2 4 false

statement ok
INSERT INTO b VALUES (3, 3, false)
Expand All @@ -392,11 +392,11 @@ null null 2 4 false
query III
SELECT * FROM a FULL OUTER JOIN b ON a.i=b.i ORDER BY b.i, b.b
----
0 1 null null null
1 2 0 2 true
2 3 3 3 false
2 3 1 3 true
null null 2 4 false
0 1 null null null

# TODO
# query IIIIII
Expand Down
Loading
Loading