Skip to content

Commit 86be1cf

Browse files
committed
cargo fmt
1 parent 98a2439 commit 86be1cf

File tree

6 files changed

+55
-30
lines changed

6 files changed

+55
-30
lines changed

wren-modeling-rs/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ version = "0.1.0"
1515
[workspace.dependencies]
1616
arrow-schema = { version = "51.0.0", default-features = false }
1717
datafusion = { version = "38.0.0" }
18+
log = { version = "0.4.14" }
19+
petgraph = "0.6.5"
20+
petgraph-evcxr = "*"
1821
serde = { version = "1.0.201", features = ["derive", "rc"] }
1922
serde_json = { version = "1.0.117" }
2023
tokio = { version = "1.4.0", features = ["rt", "rt-multi-thread", "macros"] }
21-
petgraph = "0.6.5"
22-
petgraph-evcxr = "*"
23-
log = { version = "0.4.14" }

wren-modeling-rs/sqllogictest/Cargo.toml

+8-10
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,29 @@ name = "wren_sqllogictest"
1414
path = "src/lib.rs"
1515

1616
[dependencies]
17-
wren-core = { path = "../core" }
18-
datafusion = { workspace = true }
19-
sqllogictest = "0.20.4"
2017
async-trait = "0.1.80"
21-
thiserror = "1.0.61"
22-
tokio = { workspace = true }
23-
log = { workspace = true }
2418
bigdecimal = "0.4.3"
19+
datafusion = { workspace = true }
2520
half = { version = "2.4.1", default-features = true }
21+
log = { workspace = true }
2622
rust_decimal = { version = "1.27.0" }
23+
sqllogictest = "0.20.4"
24+
thiserror = "1.0.61"
25+
tokio = { workspace = true }
26+
wren-core = { path = "../core" }
2727

2828
itertools = "0.13.0"
2929
object_store = { version = "0.10.1", default-features = false }
3030

31-
tempfile = "3.10.1"
32-
futures = "0.3.17"
3331
clap = { version = "4.4.8", features = ["derive", "env"] }
34-
32+
futures = "0.3.17"
33+
tempfile = "3.10.1"
3534

3635
[dev-dependencies]
3736
env_logger = "0.11.3"
3837
num_cpus = "1.16.0"
3938
tokio = { workspace = true, features = ["rt-multi-thread"] }
4039

41-
4240
[[test]]
4341
harness = false
4442
name = "sqllogictests"

wren-modeling-rs/sqllogictest/bin/sqllogictests.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ async fn run_complete_file(test_file: TestFile) -> Result<()> {
183183
)
184184
.await
185185
// Can't use e directly because it isn't marked Send, so turn it into a string.
186-
.map_err(|e| DataFusionError::Execution(format!("Error completing {relative_path:?}: {e}")))
186+
.map_err(|e| {
187+
DataFusionError::Execution(format!("Error completing {relative_path:?}: {e}"))
188+
})
187189
}
188190

189191
/// Represents a parsed test file
@@ -214,7 +216,9 @@ impl TestFile {
214216
}
215217
}
216218

217-
fn read_test_files<'a>(options: &'a Options) -> Result<Box<dyn Iterator<Item = TestFile> + 'a>> {
219+
fn read_test_files<'a>(
220+
options: &'a Options,
221+
) -> Result<Box<dyn Iterator<Item = TestFile> + 'a>> {
218222
Ok(Box::new(
219223
read_dir_recursive(TEST_DIRECTORY)?
220224
.into_iter()

wren-modeling-rs/sqllogictest/src/engine/conversion.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ pub(crate) fn f64_to_str(value: f64) -> String {
8383

8484
pub(crate) fn i128_to_str(value: i128, precision: &u8, scale: &i8) -> String {
8585
big_decimal_to_str(
86-
BigDecimal::from_str(&Decimal128Type::format_decimal(value, *precision, *scale)).unwrap(),
86+
BigDecimal::from_str(&Decimal128Type::format_decimal(value, *precision, *scale))
87+
.unwrap(),
8788
)
8889
}
8990

9091
pub(crate) fn i256_to_str(value: i256, precision: &u8, scale: &i8) -> String {
9192
big_decimal_to_str(
92-
BigDecimal::from_str(&Decimal256Type::format_decimal(value, *precision, *scale)).unwrap(),
93+
BigDecimal::from_str(&Decimal256Type::format_decimal(value, *precision, *scale))
94+
.unwrap(),
9395
)
9496
}
9597

wren-modeling-rs/sqllogictest/src/engine/normalize.rs

+24-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717

1818
use datafusion::arrow::datatypes::Fields;
1919
use datafusion::arrow::util::display::ArrayFormatter;
20-
use datafusion::arrow::{array, array::ArrayRef, datatypes::DataType, record_batch::RecordBatch};
20+
use datafusion::arrow::{
21+
array, array::ArrayRef, datatypes::DataType, record_batch::RecordBatch,
22+
};
2123
use datafusion::common::format::DEFAULT_FORMAT_OPTIONS;
2224
use datafusion::common::DataFusionError;
2325
use std::path::PathBuf;
@@ -157,7 +159,8 @@ fn workspace_root() -> &'static object_store::path::Path {
157159
let sanitized_workplace_root = if cfg!(windows) {
158160
// Object store paths are delimited with `/`, e.g. `/datafusion/datafusion/testing/data/csv/aggregate_test_100.csv`.
159161
// The default windows delimiter is `\`, so the workplace path is `datafusion\datafusion`.
160-
workspace_root.replace(std::path::MAIN_SEPARATOR, object_store::path::DELIMITER)
162+
workspace_root
163+
.replace(std::path::MAIN_SEPARATOR, object_store::path::DELIMITER)
161164
} else {
162165
workspace_root.to_string()
163166
};
@@ -204,10 +207,18 @@ pub fn cell_to_string(col: &ArrayRef, row: usize) -> Result<String> {
204207
} else {
205208
match col.data_type() {
206209
DataType::Null => Ok(NULL_STR.to_string()),
207-
DataType::Boolean => Ok(bool_to_str(get_row_value!(array::BooleanArray, col, row))),
208-
DataType::Float16 => Ok(f16_to_str(get_row_value!(array::Float16Array, col, row))),
209-
DataType::Float32 => Ok(f32_to_str(get_row_value!(array::Float32Array, col, row))),
210-
DataType::Float64 => Ok(f64_to_str(get_row_value!(array::Float64Array, col, row))),
210+
DataType::Boolean => {
211+
Ok(bool_to_str(get_row_value!(array::BooleanArray, col, row)))
212+
}
213+
DataType::Float16 => {
214+
Ok(f16_to_str(get_row_value!(array::Float16Array, col, row)))
215+
}
216+
DataType::Float32 => {
217+
Ok(f32_to_str(get_row_value!(array::Float32Array, col, row)))
218+
}
219+
DataType::Float64 => {
220+
Ok(f64_to_str(get_row_value!(array::Float64Array, col, row)))
221+
}
211222
DataType::Decimal128(precision, scale) => {
212223
let value = get_row_value!(array::Decimal128Array, col, row);
213224
Ok(i128_to_str(value, precision, scale))
@@ -221,7 +232,9 @@ pub fn cell_to_string(col: &ArrayRef, row: usize) -> Result<String> {
221232
col,
222233
row
223234
))),
224-
DataType::Utf8 => Ok(varchar_to_str(get_row_value!(array::StringArray, col, row))),
235+
DataType::Utf8 => {
236+
Ok(varchar_to_str(get_row_value!(array::StringArray, col, row)))
237+
}
225238
_ => {
226239
let f = ArrayFormatter::try_new(col.as_ref(), &DEFAULT_FORMAT_OPTIONS);
227240
Ok(f.unwrap().value(row).to_string())
@@ -252,9 +265,10 @@ pub(crate) fn convert_schema_to_types(columns: &Fields) -> Vec<DFColumnType> {
252265
| DataType::Decimal128(_, _)
253266
| DataType::Decimal256(_, _) => DFColumnType::Float,
254267
DataType::Utf8 | DataType::LargeUtf8 => DFColumnType::Text,
255-
DataType::Date32 | DataType::Date64 | DataType::Time32(_) | DataType::Time64(_) => {
256-
DFColumnType::DateTime
257-
}
268+
DataType::Date32
269+
| DataType::Date64
270+
| DataType::Time32(_)
271+
| DataType::Time64(_) => DFColumnType::DateTime,
258272
DataType::Timestamp(_, _) => DFColumnType::Timestamp,
259273
_ => DFColumnType::Another,
260274
})

wren-modeling-rs/sqllogictest/src/engine/utils.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
use datafusion::common::exec_datafusion_err;
22
use std::path::{Path, PathBuf};
33

4-
pub fn read_dir_recursive<P: AsRef<Path>>(path: P) -> datafusion::common::Result<Vec<PathBuf>> {
4+
pub fn read_dir_recursive<P: AsRef<Path>>(
5+
path: P,
6+
) -> datafusion::common::Result<Vec<PathBuf>> {
57
let mut dst = vec![];
68
read_dir_recursive_impl(&mut dst, path.as_ref())?;
79
Ok(dst)
810
}
911

1012
/// Append all paths recursively to dst
11-
fn read_dir_recursive_impl(dst: &mut Vec<PathBuf>, path: &Path) -> datafusion::common::Result<()> {
13+
fn read_dir_recursive_impl(
14+
dst: &mut Vec<PathBuf>,
15+
path: &Path,
16+
) -> datafusion::common::Result<()> {
1217
let entries = std::fs::read_dir(path)
1318
.map_err(|e| exec_datafusion_err!("Error reading directory {path:?}: {e}"))?;
1419
for entry in entries {
1520
let path = entry
16-
.map_err(|e| exec_datafusion_err!("Error reading entry in directory {path:?}: {e}"))?
21+
.map_err(|e| {
22+
exec_datafusion_err!("Error reading entry in directory {path:?}: {e}")
23+
})?
1724
.path();
1825

1926
if path.is_dir() {

0 commit comments

Comments
 (0)