diff --git a/crates/query/fixtures/fuel/queries/missing_block_fields/query.json b/crates/query/fixtures/fuel/queries/missing_block_fields/query.json index b8e5d40e..e7fb5fe2 100644 --- a/crates/query/fixtures/fuel/queries/missing_block_fields/query.json +++ b/crates/query/fixtures/fuel/queries/missing_block_fields/query.json @@ -6,10 +6,7 @@ "block": { "number": true, "hash": true, - "eventInboxRoot": true, - "consensusParametersVersion": true, - "stateTransitionBytecodeVersion": true, - "messageOutboxRoot": true + "consensusParametersVersion": true } }, "includeAllBlocks": false diff --git a/crates/query/fixtures/fuel/queries/missing_block_fields/result.json b/crates/query/fixtures/fuel/queries/missing_block_fields/result.json index 13404a7f..e935b468 100644 --- a/crates/query/fixtures/fuel/queries/missing_block_fields/result.json +++ b/crates/query/fixtures/fuel/queries/missing_block_fields/result.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33134c5ff181dbcc4ef7aecda446521e58c291b5a639eef18d2fa900c1bc16d9 -size 583 +oid sha256:6195a941e4334fb0a727b62577bb130c8aceccf252d7c25d7af8da404db760a2 +size 65 diff --git a/crates/query/fixtures/fuel/queries/missing_field_with_join/result.json b/crates/query/fixtures/fuel/queries/missing_field_with_join/result.json index ec36baac..ed2e66d1 100644 --- a/crates/query/fixtures/fuel/queries/missing_field_with_join/result.json +++ b/crates/query/fixtures/fuel/queries/missing_field_with_join/result.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4305c10b962392df8c44de367922fcbbcee89cad10de5718e388a64d3f45cb2c -size 1154 +oid sha256:556f4a8eb8fd91ce5e57e5be160cd56c1f59bfd01d656dca727c44120372b424 +size 58 diff --git a/crates/query/src/scan/errors.rs b/crates/query/src/scan/errors.rs index ccc975d8..f45ee7da 100644 --- a/crates/query/src/scan/errors.rs +++ b/crates/query/src/scan/errors.rs @@ -2,26 +2,21 @@ use crate::primitives::Name; #[derive(Debug)] pub struct TableDoesNotExist { - pub table_name: Name + pub table_name: Name, } - impl TableDoesNotExist { pub fn new(table_name: Name) -> Self { - Self { - table_name - } + Self { table_name } } } - impl std::fmt::Display for TableDoesNotExist { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "table '{}' does not exist", self.table_name) } } - impl std::error::Error for TableDoesNotExist {} #[derive(Debug)] @@ -30,20 +25,22 @@ pub struct ColumnDoesNotExist { pub table_name: String, } - impl ColumnDoesNotExist { pub fn new(table_name: String, column_name: Name) -> Self { Self { table_name, - column_name + column_name, } } } - impl std::fmt::Display for ColumnDoesNotExist { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "column '{}' is not found in {}", self.column_name, self.table_name) + write!( + f, + "column '{}' is not found in '{}'", + self.column_name, self.table_name + ) } } diff --git a/crates/query/src/scan/parquet/file.rs b/crates/query/src/scan/parquet/file.rs index 6c1615e0..5ba1a937 100644 --- a/crates/query/src/scan/parquet/file.rs +++ b/crates/query/src/scan/parquet/file.rs @@ -17,20 +17,25 @@ use rayon::prelude::*; use std::cmp::Ordering; use std::collections::HashSet; use std::ops::Not; +use std::path::PathBuf; use std::sync::Arc; #[derive(Clone)] pub struct ParquetFile { io: MmapIO, metadata: Arc, - filename: Arc, + table_name: String, } impl ParquetFile { - pub fn open>(file: P) -> anyhow::Result { - let filename = file.into(); + pub fn open(file: impl Into) -> anyhow::Result { + let path = file.into(); - let io = MmapIO::open(&filename)?; + let table_name = path.file_stem() + .map(|s| s.to_string_lossy().into_owned()) + .unwrap_or_default(); + + let io = MmapIO::open(&path)?; let metadata = ArrowReaderMetadata::load(&io, ArrowReaderOptions::new().with_page_index(true))?; @@ -38,7 +43,7 @@ impl ParquetFile { Ok(Self { io, metadata: Arc::new(ParquetMetadata::new(metadata)), - filename: Arc::new(filename), + table_name, }) } } @@ -171,8 +176,8 @@ impl TableReader for ParquetFile { if default_null_columns.map_or(false, |dnc| dnc.contains(name)) { missing_null_columns.push(name); } else { - tracing::error!("column '{}' is not found in {}", name, self.filename); - anyhow::bail!(ColumnDoesNotExist::new(self.filename.to_string(), name)); + tracing::error!("column '{}' is not found in {}", name, self.table_name); + anyhow::bail!(ColumnDoesNotExist::new(self.table_name.to_string(), name)); } } } diff --git a/crates/query/src/scan/parquet/io.rs b/crates/query/src/scan/parquet/io.rs index 3c928c46..cc423c9a 100644 --- a/crates/query/src/scan/parquet/io.rs +++ b/crates/query/src/scan/parquet/io.rs @@ -13,7 +13,7 @@ pub struct MmapIO { impl MmapIO { - pub fn open(filename: &str) -> std::io::Result { + pub fn open(filename: impl AsRef) -> std::io::Result { let file = std::fs::File::open(filename)?; let mmap = unsafe { MmapOptions::new().map(&file) diff --git a/crates/query/tests/fixtures.rs b/crates/query/tests/fixtures.rs index d26a2436..c01b6cd2 100644 --- a/crates/query/tests/fixtures.rs +++ b/crates/query/tests/fixtures.rs @@ -20,8 +20,10 @@ fn test_fixture(chunk: &dyn Chunk, query_file: PathBuf) { let case_dir = query_file.parent().unwrap(); let result_file = case_dir.join("result.json"); - let actual_bytes = execute_query(chunk, &query_file).unwrap(); - let actual: serde_json::Value = serde_json::from_slice(&actual_bytes).unwrap(); + let actual: serde_json::Value = match execute_query(chunk, &query_file) { + Ok(bytes) => serde_json::from_slice(&bytes).unwrap(), + Err(err) => serde_json::Value::String(err.to_string()), + }; let expected: serde_json::Value = match std::fs::read(&result_file) { Ok(expected_bytes) => serde_json::from_slice(&expected_bytes).unwrap(), @@ -182,4 +184,4 @@ mod storage { Ok(()) } -} \ No newline at end of file +}