alamb commented on PR #15578:
URL: https://github.com/apache/datafusion/pull/15578#issuecomment-2781575831

   > Just want to confirm, do I need to migrate the big test case 
roundtrip_statement_with_dialect() ?
   
   IN my opinion, it is is note required. If you want to rewrite it I am sure 
it would be appreciated by future contributors
   
   Another pattern is to put the entire test into a structure that has a 
`Display` impl and then print out that display impl in the snapshot. I did 
something like this in https://github.com/pydantic/datafusion/pull/16
   
   So instead of 
   
   ```rust
   // each test case would look like this
   #[test]
   fn roundtrip_statement_with_dialect_1() -> Result<(), DataFusionError> {
       roundtrip_statement_with_dialect_helper!(
           query: "select min(ta.j1_id) as j1_min from j1 ta order by 
min(ta.j1_id) limit 10;",
           parser_dialect: MySqlDialect {},
           unparser_dialect: UnparserMySqlDialect {},
           expected: @"SELECT `j1_min` FROM (SELECT min(`ta`.`j1_id`) AS 
`j1_min`, min(`ta`.`j1_id`) FROM `j1` AS `ta` ORDER BY min(`ta`.`j1_id`) ASC) 
AS `derived_sort` LIMIT 10",
       );
       Ok(())
   }
   ```
   
   
   ```rust
   
   struct TestResult { 
     input_query: String,
     parser_dialect: &Dialect,
     unparser_dialect: &Dialect,
     output_query: String 
   }
   
   impl TestResult {
     fn try_new(
     input_query: String,
     parser_dialect: &Dialect,
     unparser_dialect: &Dialect,
     ) -> Result<Self> { 
      // do unparse , etc
     }
   }
   
   impl Display for TestResult { ... }
   
   // tests make a TestResult and compare the string result
   #[test]
   fn roundtrip_statement_with_dialect_1() -> Result<(), DataFusionError> {
       let result =
   
   
       insta::assert_snapshot!(
           TestResult::try_new(
             select min(ta.j1_id) as j1_min from j1 ta order by min(ta.j1_id) 
limit 10;",
             MySqlDialect {},
              UnparserMySqlDialect {},
           },
           @r"
           query: "select min(ta.j1_id) as j1_min from j1 ta order by 
min(ta.j1_id) limit 10;",
           parser_dialect: MySqlDialect {},
           unparser_dialect: UnparserMySqlDialect {},
           output "SELECT `j1_min` FROM (SELECT min(`ta`.`j1_id`) AS `j1_min`, 
min(`ta`.`j1_id`) FROM `j1` AS `ta` ORDER BY min(`ta`.`j1_id`) ASC) AS 
`derived_sort` LIMIT 10",
            );
   }
   }
   ```
   
   


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to