You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Licensed to the Apache Software Foundation (ASF) under one
2
+
// or more contributor license agreements. See the NOTICE file
3
+
// distributed with this work for additional information
4
+
// regarding copyright ownership. The ASF licenses this file
5
+
// to you under the Apache License, Version 2.0 (the
6
+
// "License"); you may not use this file except in compliance
7
+
// with the License. You may obtain a copy of the License at
8
+
//
9
+
// http://www.apache.org/licenses/LICENSE-2.0
10
+
//
11
+
// Unless required by applicable law or agreed to in writing,
12
+
// software distributed under the License is distributed on an
13
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+
// KIND, either express or implied. See the License for the
15
+
// specific language governing permissions and limitations
16
+
// under the License.
17
+
18
+
//! TPCH `substrait_consumer` tests
19
+
//!
20
+
//! This module tests that substrait plans as json encoded protobuf can be
21
+
//! correctly read as DataFusion plans.
22
+
//!
23
+
//! The input data comes from <https://github.com/substrait-io/consumer-testing/tree/main/substrait_consumer/tests/integration/queries/tpch_substrait_plans>
24
+
25
+
#[cfg(test)]
26
+
mod tests {
27
+
use datafusion::common::Result;
28
+
use datafusion::execution::options::CsvReadOptions;
29
+
use datafusion::prelude::SessionContext;
30
+
use datafusion_substrait::logical_plan::consumer::from_substrait_plan;
31
+
use std::fs::File;
32
+
use std::io::BufReader;
33
+
use substrait::proto::Plan;
34
+
35
+
#[tokio::test]
36
+
asyncfntpch_test_1() -> Result<()>{
37
+
let ctx = create_context().await?;
38
+
let path = "tests/testdata/tpch_substrait_plans/query_1.json";
39
+
let proto = serde_json::from_reader::<_,Plan>(BufReader::new(
40
+
File::open(path).expect("file not found"),
41
+
))
42
+
.expect("failed to parse json");
43
+
44
+
let plan = from_substrait_plan(&ctx,&proto).await?;
45
+
46
+
assert!(
47
+
format!("{:?}", plan).eq_ignore_ascii_case(
48
+
"Sort: FILENAME_PLACEHOLDER_0.l_returnflag ASC NULLS LAST, FILENAME_PLACEHOLDER_0.l_linestatus ASC NULLS LAST\n\
Licensed to the Apache Software Foundation (ASF) under one
3
+
or more contributor license agreements. See the NOTICE file
4
+
distributed with this work for additional information
5
+
regarding copyright ownership. The ASF licenses this file
6
+
to you under the Apache License, Version 2.0 (the
7
+
"License"); you may not use this file except in compliance
8
+
with the License. You may obtain a copy of the License at
9
+
10
+
http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+
Unless required by applicable law or agreed to in writing,
13
+
software distributed under the License is distributed on an
14
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+
KIND, either express or implied. See the License for the
16
+
specific language governing permissions and limitations
17
+
under the License.
18
+
-->
19
+
20
+
# Apache DataFusion Substrait consumer integration test
21
+
22
+
these test json files come from [consumer-testing](https://github.com/substrait-io/consumer-testing/tree/main/substrait_consumer/tests/integration/queries/tpch_substrait_plans)
0 commit comments