Skip to content

Commit 6b0f955

Browse files
committed
fix clippy and unit test.
1 parent becf6b0 commit 6b0f955

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

src/query/service/tests/it/storages/index/range_filter.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ async fn test_range_filter() -> Result<()> {
9191
Test {
9292
name: "a is not null",
9393
expr: Expression::create_scalar_function("is_not_null", vec![col("a")]),
94+
expect: false,
95+
error: "",
96+
},
97+
Test {
98+
name: "b is not null",
99+
expr: Expression::create_scalar_function("is_not_null", vec![col("b")]),
94100
expect: true,
95101
error: "",
96102
},
@@ -192,7 +198,7 @@ async fn test_range_filter() -> Result<()> {
192198
for test in tests {
193199
let prune = RangeFilter::try_create(ctx.clone(), &[test.expr], schema.clone())?;
194200

195-
match prune.eval(&stats) {
201+
match prune.eval(&stats, 1) {
196202
Ok(actual) => assert_eq!(test.expect, actual, "{:#?}", test.name),
197203
Err(e) => assert_eq!(test.error, e.to_string(), "{}", test.name),
198204
}
@@ -239,7 +245,7 @@ fn test_build_verifiable_function() -> Result<()> {
239245
Test {
240246
name: "a is not null",
241247
expr: Expression::create_scalar_function("is_not_null", vec![col("a")]),
242-
expect: "is_not_null(min_a)",
248+
expect: "(nulls_a != row_count_a)",
243249
},
244250
Test {
245251
name: "b >= 0 and c like 0xffffff",

src/query/storages/hive/src/hive_partition_pruner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl HivePartitionPruner {
9999
let column_stats = self.get_column_stats(&partitions)?;
100100
let mut filted_partitions = vec![];
101101
for (idx, stats) in column_stats.into_iter().enumerate() {
102-
if range_filter.eval(&stats)? {
102+
if range_filter.eval(&stats, 1)? {
103103
filted_partitions.push(partitions[idx].clone());
104104
}
105105
}
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,47 @@
11
statement ok
2-
DROP DATABASE IF EXISTS db_09_0018;
2+
create table t_nullable_prune (a int null);
33

44
statement ok
5-
CREATE DATABASE db_09_0018;
5+
insert into t_nullable_prune select * from numbers(3);
66

77
statement ok
8-
USE db_09_0018;
9-
10-
statement ok
11-
create table t (a int null);
12-
13-
statement ok
14-
insert into t select * from numbers(3);
15-
16-
statement ok
17-
insert into t select null from numbers(3);
8+
insert into t_nullable_prune select null from numbers(3);
189

1910
statement query T
20-
explain select * from t;
11+
explain select * from t_nullable_prune;
2112

2213
----
2314
TableScan
24-
├── table: default.db_09_0018.t
15+
├── table: default.default.t_nullable_prune
2516
├── read rows: 6
2617
├── read bytes: 62
2718
├── partitions total: 2
2819
├── partitions scanned: 2
2920
└── push downs: [filters: [], limit: NONE]
3021

3122
statement query T
32-
explain select * from t where a is not null;
23+
explain select * from t_nullable_prune where a is not null;
3324

3425
----
3526
TableScan
36-
├── table: default.db_09_0018.t
27+
├── table: default.default.t_nullable_prune
3728
├── read rows: 3
3829
├── read bytes: 37
3930
├── partitions total: 2
4031
├── partitions scanned: 1
4132
└── push downs: [filters: [is_not_null(a)], limit: NONE]
4233

4334
statement query T
44-
explain select * from t where a is null;
35+
explain select * from t_nullable_prune where a is null;
4536

4637
----
4738
TableScan
48-
├── table: default.db_09_0018.t
39+
├── table: default.default.t_nullable_prune
4940
├── read rows: 3
5041
├── read bytes: 25
5142
├── partitions total: 2
5243
├── partitions scanned: 1
5344
└── push downs: [filters: [not(is_not_null(a))], limit: NONE]
5445

5546
statement ok
56-
DROP TABLE t;
57-
58-
statement ok
59-
DROP DATABASE db_09_0018;
47+
DROP TABLE default.default.t_nullable_prune;

0 commit comments

Comments
 (0)