alamb opened a new pull request, #6894:
URL: https://github.com/apache/arrow-datafusion/pull/6894

   # Which issue does this PR close?
   
   Noticed by @nseekhao 
https://github.com/apache/arrow-datafusion/pull/6868#issuecomment-1624255211 
and @waynexia  in 
https://github.com/apache/arrow-datafusion/pull/6868#issuecomment-1627705660
   
   
   
   # Rationale for this change
   
   The tests in these files are the same -- the whitespace diff shows that the 
major difference is they have different indenting levels
   
   <details><summary>Click to see output of <tt>diff -b -du</tt></summary>
   
   ```
   
   <p>
   ```diff
   --- datafusion/substrait/tests/roundtrip_logical_plan.rs     2023-07-09 
10:00:26
   +++ datafusion/substrait/tests/cases/roundtrip_logical_plan.rs       
2023-07-09 10:00:26
   @@ -15,29 +15,27 @@
    // specific language governing permissions and limitations
    // under the License.
    
   -use datafusion_substrait::logical_plan::{consumer, producer};
   +use datafusion_substrait::logical_plan::{
   +    consumer::from_substrait_plan, producer::to_substrait_plan,
   +};
    
   -#[cfg(test)]
   -mod tests {
   -
   -    use std::hash::Hash;
   -    use std::sync::Arc;
   +use std::hash::Hash;
   +use std::sync::Arc;
    
   -    use crate::{consumer::from_substrait_plan, producer::to_substrait_plan};
   -    use datafusion::arrow::datatypes::{DataType, Field, Schema, TimeUnit};
   -    use datafusion::common::{DFSchema, DFSchemaRef};
   -    use datafusion::error::Result;
   -    use datafusion::execution::context::SessionState;
   -    use datafusion::execution::registry::SerializerRegistry;
   -    use datafusion::execution::runtime_env::RuntimeEnv;
   -    use datafusion::logical_expr::{Extension, LogicalPlan, 
UserDefinedLogicalNode};
   -    use 
datafusion::optimizer::simplify_expressions::expr_simplifier::THRESHOLD_INLINE_INLIST;
   -    use datafusion::prelude::*;
   -    use 
substrait::proto::extensions::simple_extension_declaration::MappingType;
   +use datafusion::arrow::datatypes::{DataType, Field, Schema, TimeUnit};
   +use datafusion::common::{DFSchema, DFSchemaRef};
   +use datafusion::error::Result;
   +use datafusion::execution::context::SessionState;
   +use datafusion::execution::registry::SerializerRegistry;
   +use datafusion::execution::runtime_env::RuntimeEnv;
   +use datafusion::logical_expr::{Extension, LogicalPlan, 
UserDefinedLogicalNode};
   +use 
datafusion::optimizer::simplify_expressions::expr_simplifier::THRESHOLD_INLINE_INLIST;
   +use datafusion::prelude::*;
   +use substrait::proto::extensions::simple_extension_declaration::MappingType;
    
   -    struct MockSerializerRegistry;
   +struct MockSerializerRegistry;
    
   -    impl SerializerRegistry for MockSerializerRegistry {
   +impl SerializerRegistry for MockSerializerRegistry {
        fn serialize_logical_plan(
            &self,
            node: &dyn UserDefinedLogicalNode,
   @@ -65,17 +63,17 @@
                    unreachable!()
                }
            }
   -    }
   +}
    
   -    #[derive(Debug, PartialEq, Eq, Hash)]
   -    struct MockUserDefinedLogicalPlan {
   +#[derive(Debug, PartialEq, Eq, Hash)]
   +struct MockUserDefinedLogicalPlan {
            /// Replacement for serialize/deserialize data
            validation_bytes: Vec<u8>,
            inputs: Vec<LogicalPlan>,
            empty_schema: DFSchemaRef,
   -    }
   +}
    
   -    impl UserDefinedLogicalNode for MockUserDefinedLogicalPlan {
   +impl UserDefinedLogicalNode for MockUserDefinedLogicalPlan {
        fn as_any(&self) -> &dyn std::any::Any {
            self
        }
   @@ -123,9 +121,9 @@
            fn dyn_eq(&self, _: &dyn UserDefinedLogicalNode) -> bool {
                unimplemented!()
            }
   -    }
   +}
    
   -    impl MockUserDefinedLogicalPlan {
   +impl MockUserDefinedLogicalPlan {
        pub fn new(validation_bytes: Vec<u8>) -> Self {
            Self {
                validation_bytes,
   @@ -144,29 +142,28 @@
            {
                Ok(Arc::new(MockUserDefinedLogicalPlan::new(bytes.to_vec())))
            }
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_select() -> Result<()> {
   +#[tokio::test]
   +async fn simple_select() -> Result<()> {
            roundtrip("SELECT a, b FROM data").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn wildcard_select() -> Result<()> {
   +#[tokio::test]
   +async fn wildcard_select() -> Result<()> {
            roundtrip("SELECT * FROM data").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_with_filter() -> Result<()> {
   +#[tokio::test]
   +async fn select_with_filter() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE a > 1").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_with_reused_functions() -> Result<()> {
   +#[tokio::test]
   +async fn select_with_reused_functions() -> Result<()> {
            let sql = "SELECT * FROM data WHERE a > 1 AND a < 10 AND b > 0";
            roundtrip(sql).await?;
   -        let (mut function_names, mut function_anchors) =
   -            function_extension_info(sql).await?;
   +    let (mut function_names, mut function_anchors) = 
function_extension_info(sql).await?;
        function_names.sort();
        function_anchors.sort();
    
   @@ -174,136 +171,132 @@
            assert_eq!(function_anchors, [0, 1, 2]);
    
            Ok(())
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_with_filter_date() -> Result<()> {
   +#[tokio::test]
   +async fn select_with_filter_date() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE c > CAST('2020-01-01' AS 
DATE)").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_with_filter_bool_expr() -> Result<()> {
   +#[tokio::test]
   +async fn select_with_filter_bool_expr() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE d AND a > 1").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_with_limit() -> Result<()> {
   +#[tokio::test]
   +async fn select_with_limit() -> Result<()> {
            roundtrip_fill_na("SELECT * FROM data LIMIT 100").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_with_limit_offset() -> Result<()> {
   +#[tokio::test]
   +async fn select_with_limit_offset() -> Result<()> {
            roundtrip("SELECT * FROM data LIMIT 200 OFFSET 10").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_aggregate() -> Result<()> {
   +#[tokio::test]
   +async fn simple_aggregate() -> Result<()> {
            roundtrip("SELECT a, sum(b) FROM data GROUP BY a").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn aggregate_distinct_with_having() -> Result<()> {
   -        roundtrip(
   -            "SELECT a, count(distinct b) FROM data GROUP BY a, c HAVING 
count(b) > 100",
   -        )
   +#[tokio::test]
   +async fn aggregate_distinct_with_having() -> Result<()> {
   +    roundtrip("SELECT a, count(distinct b) FROM data GROUP BY a, c HAVING 
count(b) > 100")
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn aggregate_multiple_keys() -> Result<()> {
   +#[tokio::test]
   +async fn aggregate_multiple_keys() -> Result<()> {
            roundtrip("SELECT a, c, avg(b) FROM data GROUP BY a, c").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn decimal_literal() -> Result<()> {
   +#[tokio::test]
   +async fn decimal_literal() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE b > 2.5").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn null_decimal_literal() -> Result<()> {
   +#[tokio::test]
   +async fn null_decimal_literal() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE b = NULL").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn u32_literal() -> Result<()> {
   +#[tokio::test]
   +async fn u32_literal() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE e > 4294967295").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_distinct() -> Result<()> {
   +#[tokio::test]
   +async fn simple_distinct() -> Result<()> {
            test_alias(
                "SELECT distinct a FROM data",
                "SELECT a FROM data GROUP BY a",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn select_distinct_two_fields() -> Result<()> {
   +#[tokio::test]
   +async fn select_distinct_two_fields() -> Result<()> {
            test_alias(
                "SELECT distinct a, b FROM data",
                "SELECT a, b FROM data GROUP BY a, b",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_alias() -> Result<()> {
   +#[tokio::test]
   +async fn simple_alias() -> Result<()> {
            test_alias("SELECT d1.a, d1.b FROM data d1", "SELECT a, b FROM 
data").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn two_table_alias() -> Result<()> {
   +#[tokio::test]
   +async fn two_table_alias() -> Result<()> {
            test_alias(
                "SELECT d1.a FROM data d1 JOIN data2 d2 ON d1.a = d2.a",
                "SELECT data.a FROM data JOIN data2 ON data.a = data2.a",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn between_integers() -> Result<()> {
   +#[tokio::test]
   +async fn between_integers() -> Result<()> {
            test_alias(
                "SELECT * FROM data WHERE a BETWEEN 2 AND 6",
                "SELECT * FROM data WHERE a >= 2 AND a <= 6",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn not_between_integers() -> Result<()> {
   +#[tokio::test]
   +async fn not_between_integers() -> Result<()> {
            test_alias(
                "SELECT * FROM data WHERE a NOT BETWEEN 2 AND 6",
                "SELECT * FROM data WHERE a < 2 OR a > 6",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_scalar_function_abs() -> Result<()> {
   +#[tokio::test]
   +async fn simple_scalar_function_abs() -> Result<()> {
            roundtrip("SELECT ABS(a) FROM data").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_scalar_function_pow() -> Result<()> {
   +#[tokio::test]
   +async fn simple_scalar_function_pow() -> Result<()> {
            roundtrip("SELECT POW(a, 2) FROM data").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_scalar_function_substr() -> Result<()> {
   +#[tokio::test]
   +async fn simple_scalar_function_substr() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE a = SUBSTR('datafusion', 0, 
3)").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn case_without_base_expression() -> Result<()> {
   -        roundtrip(
   -            "SELECT (CASE WHEN a >= 0 THEN 'positive' ELSE 'negative' END) 
FROM data",
   -        )
   +#[tokio::test]
   +async fn case_without_base_expression() -> Result<()> {
   +    roundtrip("SELECT (CASE WHEN a >= 0 THEN 'positive' ELSE 'negative' 
END) FROM data")
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn case_with_base_expression() -> Result<()> {
   +#[tokio::test]
   +async fn case_with_base_expression() -> Result<()> {
        roundtrip(
            "SELECT (CASE a
                                WHEN 0 THEN 'zero'
   @@ -312,75 +305,75 @@
                               END) FROM data",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn cast_decimal_to_int() -> Result<()> {
   +#[tokio::test]
   +async fn cast_decimal_to_int() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE a = CAST(2.5 AS int)").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn implicit_cast() -> Result<()> {
   +#[tokio::test]
   +async fn implicit_cast() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE a = b").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn aggregate_case() -> Result<()> {
   +#[tokio::test]
   +async fn aggregate_case() -> Result<()> {
            assert_expected_plan(
                "SELECT SUM(CASE WHEN a > 0 THEN 1 ELSE NULL END) FROM data",
                "Aggregate: groupBy=[[]], aggr=[[SUM(CASE WHEN data.a > 
Int64(0) THEN Int64(1) ELSE Int64(NULL) END)]]\
                \n  TableScan: data projection=[a]",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_inlist_1() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_inlist_1() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE a IN (1, 2, 3)").await
   -    }
   +}
    
   -    #[tokio::test]
   -    // Test with length <= 
datafusion_optimizer::simplify_expressions::expr_simplifier::THRESHOLD_INLINE_INLIST
   -    async fn roundtrip_inlist_2() -> Result<()> {
   +#[tokio::test]
   +// Test with length <= 
datafusion_optimizer::simplify_expressions::expr_simplifier::THRESHOLD_INLINE_INLIST
   +async fn roundtrip_inlist_2() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE f IN ('a', 'b', 'c')").await
   -    }
   +}
    
   -    #[tokio::test]
   -    // Test with length > 
datafusion_optimizer::simplify_expressions::expr_simplifier::THRESHOLD_INLINE_INLIST
   -    async fn roundtrip_inlist_3() -> Result<()> {
   +#[tokio::test]
   +// Test with length > 
datafusion_optimizer::simplify_expressions::expr_simplifier::THRESHOLD_INLINE_INLIST
   +async fn roundtrip_inlist_3() -> Result<()> {
            let inlist = (0..THRESHOLD_INLINE_INLIST + 1)
                .map(|i| format!("'{i}'"))
                .collect::<Vec<_>>()
                .join(", ");
    
            roundtrip(&format!("SELECT * FROM data WHERE f IN 
({inlist})")).await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_inlist_4() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_inlist_4() -> Result<()> {
            roundtrip("SELECT * FROM data WHERE f NOT IN ('a', 'b', 'c', 
'd')").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_inner_join() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_inner_join() -> Result<()> {
            roundtrip("SELECT data.a FROM data JOIN data2 ON data.a = 
data2.a").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_non_equi_inner_join() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_non_equi_inner_join() -> Result<()> {
            roundtrip("SELECT data.a FROM data JOIN data2 ON data.a <> 
data2.a").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_non_equi_join() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_non_equi_join() -> Result<()> {
            roundtrip(
                "SELECT data.a FROM data, data2 WHERE data.a = data2.a AND 
data.e > data2.a",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_exists_filter() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_exists_filter() -> Result<()> {
        assert_expected_plan(
            "SELECT b FROM data d1 WHERE EXISTS (SELECT * FROM data2 d2 WHERE 
d2.a = d1.a AND d2.e != d1.e)",
            "Projection: data.b\
   @@ -388,10 +381,10 @@
                \n    TableScan: data projection=[a, b, e]\
                \n    TableScan: data2 projection=[a, e]"
            ).await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn inner_join() -> Result<()> {
   +#[tokio::test]
   +async fn inner_join() -> Result<()> {
        assert_expected_plan(
            "SELECT data.a FROM data JOIN data2 ON data.a = data2.a",
            "Projection: data.a\
   @@ -400,26 +393,25 @@
                \n    TableScan: data2 projection=[a]",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_left_join() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_left_join() -> Result<()> {
            roundtrip("SELECT data.a FROM data LEFT JOIN data2 ON data.a = 
data2.a").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_right_join() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_right_join() -> Result<()> {
            roundtrip("SELECT data.a FROM data RIGHT JOIN data2 ON data.a = 
data2.a").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_outer_join() -> Result<()> {
   -        roundtrip("SELECT data.a FROM data FULL OUTER JOIN data2 ON data.a 
= data2.a")
   -            .await
   -    }
   +#[tokio::test]
   +async fn roundtrip_outer_join() -> Result<()> {
   +    roundtrip("SELECT data.a FROM data FULL OUTER JOIN data2 ON data.a = 
data2.a").await
   +}
    
   -    #[tokio::test]
   -    async fn simple_intersect() -> Result<()> {
   +#[tokio::test]
   +async fn simple_intersect() -> Result<()> {
        assert_expected_plan(
            "SELECT COUNT(*) FROM (SELECT data.a FROM data INTERSECT SELECT 
data2.a FROM data2);",
            "Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]]\
   @@ -429,10 +421,10 @@
                \n    TableScan: data2 projection=[a]",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_intersect_table_reuse() -> Result<()> {
   +#[tokio::test]
   +async fn simple_intersect_table_reuse() -> Result<()> {
        assert_expected_plan(
            "SELECT COUNT(*) FROM (SELECT data.a FROM data INTERSECT SELECT 
data.a FROM data);",
            "Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]]\
   @@ -442,25 +434,25 @@
                \n    TableScan: data projection=[a]",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn simple_window_function() -> Result<()> {
   +#[tokio::test]
   +async fn simple_window_function() -> Result<()> {
            roundtrip("SELECT RANK() OVER (PARTITION BY a ORDER BY b), d, 
SUM(b) OVER (PARTITION BY a) FROM data;").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn qualified_schema_table_reference() -> Result<()> {
   +#[tokio::test]
   +async fn qualified_schema_table_reference() -> Result<()> {
            roundtrip("SELECT * FROM public.data;").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn qualified_catalog_schema_table_reference() -> Result<()> {
   +#[tokio::test]
   +async fn qualified_catalog_schema_table_reference() -> Result<()> {
            roundtrip("SELECT a,b,c,d,e FROM datafusion.public.data;").await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_inner_join_table_reuse_zero_index() -> Result<()> {
   +#[tokio::test]
   +async fn roundtrip_inner_join_table_reuse_zero_index() -> Result<()> {
        assert_expected_plan(
            "SELECT d1.b, d2.c FROM data d1 JOIN data d2 ON d1.a = d2.a",
            "Projection: data.b, data.c\
   @@ -469,10 +461,10 @@
                \n    TableScan: data projection=[a, c]",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn roundtrip_inner_join_table_reuse_non_zero_index() -> 
Result<()> {
   +#[tokio::test]
   +async fn roundtrip_inner_join_table_reuse_non_zero_index() -> Result<()> {
        assert_expected_plan(
            "SELECT d1.b, d2.c FROM data d1 JOIN data d2 ON d1.b = d2.b",
            "Projection: data.b, data.c\
   @@ -481,16 +473,16 @@
                \n    TableScan: data projection=[b, c]",
            )
            .await
   -    }
   +}
    
   -    /// Construct a plan that contains several literals of types that are 
currently supported.
   -    /// This case ignores:
   -    /// - Date64, for this literal is not supported
   -    /// - FixedSizeBinary, for converting UTF-8 literal to FixedSizeBinary 
is not supported
   -    /// - List, this nested type is not supported in arrow_cast
   -    /// - Decimal128 and Decimal256, them will fallback to UTF8 cast expr 
rather than plain literal.
   -    #[tokio::test]
   -    async fn all_type_literal() -> Result<()> {
   +/// Construct a plan that contains several literals of types that are 
currently supported.
   +/// This case ignores:
   +/// - Date64, for this literal is not supported
   +/// - FixedSizeBinary, for converting UTF-8 literal to FixedSizeBinary is 
not supported
   +/// - List, this nested type is not supported in arrow_cast
   +/// - Decimal128 and Decimal256, them will fallback to UTF8 cast expr 
rather than plain literal.
   +#[tokio::test]
   +async fn all_type_literal() -> Result<()> {
        roundtrip_all_types(
            "select * from data where
                bool_col = TRUE AND
   @@ -515,11 +507,11 @@
                large_utf8_col = arrow_cast('large_utf8', 'LargeUtf8');",
            )
            .await
   -    }
   +}
    
   -    /// Construct a plan that cast columns. Only those SQL types are 
supported for now.
   -    #[tokio::test]
   -    async fn new_test_grammar() -> Result<()> {
   +/// Construct a plan that cast columns. Only those SQL types are supported 
for now.
   +#[tokio::test]
   +async fn new_test_grammar() -> Result<()> {
        roundtrip_all_types(
            "select
                bool_col::boolean,
   @@ -539,10 +531,10 @@
                from data",
            )
            .await
   -    }
   +}
    
   -    #[tokio::test]
   -    async fn extension_logical_plan() -> Result<()> {
   +#[tokio::test]
   +async fn extension_logical_plan() -> Result<()> {
        let mut ctx = create_context().await?;
        let validation_bytes = "MockUserDefinedLogicalPlan".as_bytes().to_vec();
        let ext_plan = LogicalPlan::Extension(Extension {
   @@ -561,9 +553,9 @@
            assert_eq!(plan1str, plan2str);
    
            Ok(())
   -    }
   +}
    
   -    async fn assert_expected_plan(sql: &str, expected_plan_str: &str) -> 
Result<()> {
   +async fn assert_expected_plan(sql: &str, expected_plan_str: &str) -> 
Result<()> {
        let mut ctx = create_context().await?;
        let df = ctx.sql(sql).await?;
        let plan = df.into_optimized_plan()?;
   @@ -573,9 +565,9 @@
            let plan2str = format!("{plan2:?}");
            assert_eq!(expected_plan_str, &plan2str);
            Ok(())
   -    }
   +}
    
   -    async fn roundtrip_fill_na(sql: &str) -> Result<()> {
   +async fn roundtrip_fill_na(sql: &str) -> Result<()> {
        let mut ctx = create_context().await?;
        let df = ctx.sql(sql).await?;
        let plan1 = df.into_optimized_plan()?;
   @@ -589,9 +581,9 @@
    
            assert_eq!(plan1str, plan2str);
            Ok(())
   -    }
   +}
    
   -    async fn test_alias(sql_with_alias: &str, sql_no_alias: &str) -> 
Result<()> {
   +async fn test_alias(sql_with_alias: &str, sql_no_alias: &str) -> Result<()> 
{
        // Since we ignore the SubqueryAlias in the producer, the result should 
be
        // the same as producing a Substrait plan from the same query without 
aliases
        // sql_with_alias -> substrait -> logical plan = sql_no_alias -> 
substrait -> logical plan
   @@ -612,9 +604,9 @@
            let plan2str = format!("{plan:?}");
            assert_eq!(plan1str, plan2str);
            Ok(())
   -    }
   +}
    
   -    async fn roundtrip(sql: &str) -> Result<()> {
   +async fn roundtrip(sql: &str) -> Result<()> {
        let mut ctx = create_context().await?;
        let df = ctx.sql(sql).await?;
        let plan = df.into_optimized_plan()?;
   @@ -629,9 +621,9 @@
            let plan2str = format!("{plan2:?}");
            assert_eq!(plan1str, plan2str);
            Ok(())
   -    }
   +}
    
   -    async fn roundtrip_all_types(sql: &str) -> Result<()> {
   +async fn roundtrip_all_types(sql: &str) -> Result<()> {
        let mut ctx = create_all_type_context().await?;
        let df = ctx.sql(sql).await?;
        let plan = df.into_optimized_plan()?;
   @@ -646,9 +638,9 @@
            let plan2str = format!("{plan2:?}");
            assert_eq!(plan1str, plan2str);
            Ok(())
   -    }
   +}
    
   -    async fn function_extension_info(sql: &str) -> Result<(Vec<String>, 
Vec<u32>)> {
   +async fn function_extension_info(sql: &str) -> Result<(Vec<String>, 
Vec<u32>)> {
        let ctx = create_context().await?;
        let df = ctx.sql(sql).await?;
        let plan = df.into_optimized_plan()?;
   @@ -657,11 +649,8 @@
            let mut function_names: Vec<String> = vec![];
            let mut function_anchors: Vec<u32> = vec![];
            for e in &proto.extensions {
   -            let (function_anchor, function_name) = match 
e.mapping_type.as_ref().unwrap()
   -            {
   -                MappingType::ExtensionFunction(ext_f) => {
   -                    (ext_f.function_anchor, &ext_f.name)
   -                }
   +        let (function_anchor, function_name) = match 
e.mapping_type.as_ref().unwrap() {
   +            MappingType::ExtensionFunction(ext_f) => 
(ext_f.function_anchor, &ext_f.name),
                _ => unreachable!("Producer does not generate a non-function 
extension"),
            };
            function_names.push(function_name.to_string());
   @@ -669,9 +658,9 @@
            }
    
            Ok((function_names, function_anchors))
   -    }
   +}
    
   -    async fn create_context() -> Result<SessionContext> {
   +async fn create_context() -> Result<SessionContext> {
        let state = SessionState::with_config_rt(
            SessionConfig::default(),
            Arc::new(RuntimeEnv::default()),
   @@ -693,10 +682,10 @@
            ctx.register_csv("data2", "tests/testdata/data.csv", 
CsvReadOptions::new())
                .await?;
            Ok(ctx)
   -    }
   +}
    
   -    /// Cover all supported types
   -    async fn create_all_type_context() -> Result<SessionContext> {
   +/// Cover all supported types
   +async fn create_all_type_context() -> Result<SessionContext> {
        let ctx = SessionContext::new();
        let mut explicit_options = CsvReadOptions::new();
        let schema = Schema::new(vec![
   @@ -753,5 +742,4 @@
                .await?;
    
            Ok(ctx)
   -    }
    }
   ```
   
   </p>
   </details> 
   
   # What changes are included in this PR?
   
   Delete one copy of the tests:
   
   ```shell
   git rm datafusion/substrait/tests/roundtrip_logical_plan.rs
   ```
   
   # Are these changes tested?
   existing CI
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   no
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to