Skip to content

Commit

Permalink
test(substrait): update TPCH tests (#12462)
Browse files Browse the repository at this point in the history
* test(substrait): rename vendored test files to match upstream

* test(substrait): update vendored TPCH plans from substrait-consumer

version: https://github.com/substrait-io/consumer-testing/tree/d9a0453

* test(substrait): collect schemas through from expressions

Substrait plans can contains relations within expressions, for example
in Subqueries. As such, in order to fully collect schemas we must
traverse through relation and expressions.

* feat(substrait): more flexible IntervalDayToSecond handling

When subseconds is not set, allow for missing precision_mode

* test(substrait): update existing TPCH tests

* test(substrait): include new TPCH tests

* test(substrait): remove unused test csv files

* test(substrait): minor TestSchemaCollector updates

* clippy
  • Loading branch information
vbarua authored Sep 16, 2024
1 parent 7bd7747 commit 257e140
Show file tree
Hide file tree
Showing 48 changed files with 18,274 additions and 17,745 deletions.
9 changes: 7 additions & 2 deletions datafusion/substrait/src/logical_plan/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,14 +2064,19 @@ fn from_substrait_literal(
// DF only supports millisecond precision, so for any more granular type we lose precision
let milliseconds = match precision_mode {
Some(PrecisionMode::Microseconds(ms)) => ms / 1000,
None =>
if *subseconds != 0 {
return substrait_err!("Cannot set subseconds field of IntervalDayToSecond without setting precision");
} else {
0_i32
}
Some(PrecisionMode::Precision(0)) => *subseconds as i32 * 1000,
Some(PrecisionMode::Precision(3)) => *subseconds as i32,
Some(PrecisionMode::Precision(6)) => (subseconds / 1000) as i32,
Some(PrecisionMode::Precision(9)) => (subseconds / 1000 / 1000) as i32,
_ => {
return not_impl_err!(
"Unsupported Substrait interval day to second precision mode"
)
"Unsupported Substrait interval day to second precision mode: {precision_mode:?}")
}
};

Expand Down
796 changes: 331 additions & 465 deletions datafusion/substrait/tests/cases/consumer_integration.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion datafusion/substrait/tests/cases/function_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod tests {
#[tokio::test]
async fn contains_function_test() -> Result<()> {
let proto_plan = read_json("tests/testdata/contains_plan.substrait.json");
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan);
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;
let plan = from_substrait_plan(&ctx, &proto_plan).await?;

let plan_str = format!("{}", plan);
Expand Down
6 changes: 3 additions & 3 deletions datafusion/substrait/tests/cases/logical_plans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod tests {
// ./isthmus-cli/build/graal/isthmus --create "create table data (d boolean)" "select not d from data"
let proto_plan =
read_json("tests/testdata/test_plans/select_not_bool.substrait.json");
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan);
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;
let plan = from_substrait_plan(&ctx, &proto_plan).await?;

assert_eq!(
Expand All @@ -62,7 +62,7 @@ mod tests {
// ./isthmus-cli/build/graal/isthmus --create "create table data (d int, part int, ord int)" "select sum(d) OVER (PARTITION BY part ORDER BY ord ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) AS lead_expr from data"
let proto_plan =
read_json("tests/testdata/test_plans/select_window.substrait.json");
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan);
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;
let plan = from_substrait_plan(&ctx, &proto_plan).await?;

assert_eq!(
Expand All @@ -81,7 +81,7 @@ mod tests {
// This test confirms that reading a plan with non-nullable lists works as expected.
let proto_plan =
read_json("tests/testdata/test_plans/non_nullable_lists.substrait.json");
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan);
let ctx = add_plan_schemas_to_ctx(SessionContext::new(), &proto_plan)?;
let plan = from_substrait_plan(&ctx, &proto_plan).await?;

assert_eq!(format!("{}", &plan), "Values: (List([1, 2]))");
Expand Down
2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/customer.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/lineitem.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/nation.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/orders.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/part.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/partsupp.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/region.csv

This file was deleted.

2 changes: 0 additions & 2 deletions datafusion/substrait/tests/testdata/tpch/supplier.csv

This file was deleted.

Loading

0 comments on commit 257e140

Please sign in to comment.