@@ -1782,16 +1782,12 @@ mod test {
17821782 /// `$PLAN`: the plan to optimized
17831783 ///
17841784 macro_rules! assert_plan {
1785- ( $EXPECTED_PLAN_LINES : expr, $PLAN : expr) => {
1785+ ( $PLAN : expr, @ $EXPECTED : expr) => {
17861786 let formatted = crate :: displayable( $PLAN) . indent( true ) . to_string( ) ;
1787- let actual: Vec <& str > = formatted. trim( ) . lines( ) . collect( ) ;
17881787
1789- let expected_plan_lines: Vec <& str > = $EXPECTED_PLAN_LINES
1790- . iter( ) . map( |s| * s) . collect( ) ;
1791-
1792- assert_eq!(
1793- expected_plan_lines, actual,
1794- "\n **Original Plan Mismatch\n \n expected:\n \n {expected_plan_lines:#?}\n actual:\n \n {actual:#?}\n \n "
1788+ insta:: assert_snapshot!(
1789+ formatted,
1790+ @$EXPECTED
17951791 ) ;
17961792 } ;
17971793 }
@@ -1808,13 +1804,12 @@ mod test {
18081804 . with_preserve_order ( ) ;
18091805
18101806 // Repartition should preserve order
1811- let expected_plan = [
1812- "RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2, preserve_order=true, sort_exprs=c0@0 ASC" ,
1813- " UnionExec" ,
1814- " DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC" ,
1815- " DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC" ,
1816- ] ;
1817- assert_plan ! ( expected_plan, & exec) ;
1807+ assert_plan ! ( & exec, @r"
1808+ RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2, preserve_order=true, sort_exprs=c0@0 ASC
1809+ UnionExec
1810+ DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC
1811+ DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC
1812+ " ) ;
18181813 Ok ( ( ) )
18191814 }
18201815
@@ -1824,16 +1819,15 @@ mod test {
18241819 let sort_exprs = sort_exprs ( & schema) ;
18251820 let source = sorted_memory_exec ( & schema, sort_exprs) ;
18261821 // output is sorted, but has only a single partition, so no need to sort
1827- let exec = RepartitionExec :: try_new ( source, Partitioning :: RoundRobinBatch ( 10 ) )
1828- . unwrap ( )
1822+ let exec = RepartitionExec :: try_new ( source, Partitioning :: RoundRobinBatch ( 10 ) ) ?
18291823 . with_preserve_order ( ) ;
18301824
18311825 // Repartition should not preserve order
1832- let expected_plan = [
1833- " RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1" ,
1834- " DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC" ,
1835- ] ;
1836- assert_plan ! ( expected_plan , & exec ) ;
1826+ assert_plan ! ( & exec , @ r"
1827+ RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=1
1828+ DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC
1829+ " ) ;
1830+
18371831 Ok ( ( ) )
18381832 }
18391833
@@ -1848,13 +1842,12 @@ mod test {
18481842 . with_preserve_order ( ) ;
18491843
18501844 // Repartition should not preserve order, as there is no order to preserve
1851- let expected_plan = [
1852- "RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2" ,
1853- " UnionExec" ,
1854- " DataSourceExec: partitions=1, partition_sizes=[0]" ,
1855- " DataSourceExec: partitions=1, partition_sizes=[0]" ,
1856- ] ;
1857- assert_plan ! ( expected_plan, & exec) ;
1845+ assert_plan ! ( & exec, @r"
1846+ RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=2
1847+ UnionExec
1848+ DataSourceExec: partitions=1, partition_sizes=[0]
1849+ DataSourceExec: partitions=1, partition_sizes=[0]
1850+ " ) ;
18581851 Ok ( ( ) )
18591852 }
18601853
@@ -1869,11 +1862,10 @@ mod test {
18691862 . unwrap ( ) ;
18701863
18711864 // Repartition should not preserve order
1872- let expected_plan = [
1873- "RepartitionExec: partitioning=RoundRobinBatch(20), input_partitions=1" ,
1874- " DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC" ,
1875- ] ;
1876- assert_plan ! ( expected_plan, exec. as_ref( ) ) ;
1865+ assert_plan ! ( exec. as_ref( ) , @r"
1866+ RepartitionExec: partitioning=RoundRobinBatch(20), input_partitions=1
1867+ DataSourceExec: partitions=1, partition_sizes=[0], output_ordering=c0@0 ASC
1868+ " ) ;
18771869 Ok ( ( ) )
18781870 }
18791871
0 commit comments