Skip to content

Commit 1274b55

Browse files
authored
fix: Update tests to reflect recent changes (#60)
* Previously tests were not corrected after the merge of NET-92. This has been fixed.
1 parent 0c55c82 commit 1274b55

7 files changed

Lines changed: 31 additions & 30 deletions

File tree

crates/query/fixtures/fuel/queries/missing_block_fields/query.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"block": {
77
"number": true,
88
"hash": true,
9-
"eventInboxRoot": true,
10-
"consensusParametersVersion": true,
11-
"stateTransitionBytecodeVersion": true,
12-
"messageOutboxRoot": true
9+
"consensusParametersVersion": true
1310
}
1411
},
1512
"includeAllBlocks": false
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:33134c5ff181dbcc4ef7aecda446521e58c291b5a639eef18d2fa900c1bc16d9
3-
size 583
2+
oid sha256:6195a941e4334fb0a727b62577bb130c8aceccf252d7c25d7af8da404db760a2
3+
size 65
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:4305c10b962392df8c44de367922fcbbcee89cad10de5718e388a64d3f45cb2c
3-
size 1154
2+
oid sha256:556f4a8eb8fd91ce5e57e5be160cd56c1f59bfd01d656dca727c44120372b424
3+
size 58

crates/query/src/scan/errors.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,21 @@ use crate::primitives::Name;
22

33
#[derive(Debug)]
44
pub struct TableDoesNotExist {
5-
pub table_name: Name
5+
pub table_name: Name,
66
}
77

8-
98
impl TableDoesNotExist {
109
pub fn new(table_name: Name) -> Self {
11-
Self {
12-
table_name
13-
}
10+
Self { table_name }
1411
}
1512
}
1613

17-
1814
impl std::fmt::Display for TableDoesNotExist {
1915
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2016
write!(f, "table '{}' does not exist", self.table_name)
2117
}
2218
}
2319

24-
2520
impl std::error::Error for TableDoesNotExist {}
2621

2722
#[derive(Debug)]
@@ -30,20 +25,22 @@ pub struct ColumnDoesNotExist {
3025
pub table_name: String,
3126
}
3227

33-
3428
impl ColumnDoesNotExist {
3529
pub fn new(table_name: String, column_name: Name) -> Self {
3630
Self {
3731
table_name,
38-
column_name
32+
column_name,
3933
}
4034
}
4135
}
4236

43-
4437
impl std::fmt::Display for ColumnDoesNotExist {
4538
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46-
write!(f, "column '{}' is not found in {}", self.column_name, self.table_name)
39+
write!(
40+
f,
41+
"column '{}' is not found in '{}'",
42+
self.column_name, self.table_name
43+
)
4744
}
4845
}
4946

crates/query/src/scan/parquet/file.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,33 @@ use rayon::prelude::*;
1717
use std::cmp::Ordering;
1818
use std::collections::HashSet;
1919
use std::ops::Not;
20+
use std::path::PathBuf;
2021
use std::sync::Arc;
2122

2223
#[derive(Clone)]
2324
pub struct ParquetFile {
2425
io: MmapIO,
2526
metadata: Arc<ParquetMetadata>,
26-
filename: Arc<String>,
27+
table_name: String,
2728
}
2829

2930
impl ParquetFile {
30-
pub fn open<P: Into<String>>(file: P) -> anyhow::Result<Self> {
31-
let filename = file.into();
31+
pub fn open(file: impl Into<PathBuf>) -> anyhow::Result<Self> {
32+
let path = file.into();
3233

33-
let io = MmapIO::open(&filename)?;
34+
let table_name = path.file_stem()
35+
.map(|s| s.to_string_lossy().into_owned())
36+
.unwrap_or_default();
37+
38+
let io = MmapIO::open(&path)?;
3439

3540
let metadata =
3641
ArrowReaderMetadata::load(&io, ArrowReaderOptions::new().with_page_index(true))?;
3742

3843
Ok(Self {
3944
io,
4045
metadata: Arc::new(ParquetMetadata::new(metadata)),
41-
filename: Arc::new(filename),
46+
table_name,
4247
})
4348
}
4449
}
@@ -171,8 +176,8 @@ impl TableReader for ParquetFile {
171176
if default_null_columns.map_or(false, |dnc| dnc.contains(name)) {
172177
missing_null_columns.push(name);
173178
} else {
174-
tracing::error!("column '{}' is not found in {}", name, self.filename);
175-
anyhow::bail!(ColumnDoesNotExist::new(self.filename.to_string(), name));
179+
tracing::error!("column '{}' is not found in {}", name, self.table_name);
180+
anyhow::bail!(ColumnDoesNotExist::new(self.table_name.to_string(), name));
176181
}
177182
}
178183
}

crates/query/src/scan/parquet/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct MmapIO {
1313

1414

1515
impl MmapIO {
16-
pub fn open(filename: &str) -> std::io::Result<Self> {
16+
pub fn open(filename: impl AsRef<std::path::Path>) -> std::io::Result<Self> {
1717
let file = std::fs::File::open(filename)?;
1818
let mmap = unsafe {
1919
MmapOptions::new().map(&file)

crates/query/tests/fixtures.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ fn test_fixture(chunk: &dyn Chunk, query_file: PathBuf) {
2020
let case_dir = query_file.parent().unwrap();
2121
let result_file = case_dir.join("result.json");
2222

23-
let actual_bytes = execute_query(chunk, &query_file).unwrap();
24-
let actual: serde_json::Value = serde_json::from_slice(&actual_bytes).unwrap();
23+
let actual: serde_json::Value = match execute_query(chunk, &query_file) {
24+
Ok(bytes) => serde_json::from_slice(&bytes).unwrap(),
25+
Err(err) => serde_json::Value::String(err.to_string()),
26+
};
2527

2628
let expected: serde_json::Value = match std::fs::read(&result_file) {
2729
Ok(expected_bytes) => serde_json::from_slice(&expected_bytes).unwrap(),
@@ -182,4 +184,4 @@ mod storage {
182184

183185
Ok(())
184186
}
185-
}
187+
}

0 commit comments

Comments
 (0)