waynexia commented on code in PR #5775:
URL: https://github.com/apache/arrow-datafusion/pull/5775#discussion_r1154552219
##########
datafusion/substrait/tests/roundtrip_logical_plan.rs:
##########
@@ -333,6 +405,23 @@ mod tests {
Ok(())
}
+ async fn roundtrip_all_types(sql: &str) -> Result<()> {
Review Comment:
When I wrote cases like `"select cast(a as boolean) from data"` I got an
error saying that there is no column a in the table (however `"select a from
data"` works). I'm not sure if it's expected. But only cast uses type for now.
Do you have any suggestions about testing new types?
##########
datafusion/substrait/tests/roundtrip_logical_plan.rs:
##########
@@ -262,7 +262,79 @@ mod tests {
#[tokio::test]
async fn qualified_catalog_schema_table_reference() -> Result<()> {
- roundtrip("SELECT * FROM datafusion.public.data;").await
+ roundtrip("SELECT a,b,c,d,e FROM datafusion.public.data;").await
+ }
+
+ #[tokio::test]
+ async fn read_all_types() -> Result<()> {
+ let mut ctx = create_all_type_context().await?;
+ let df = ctx
+ .sql(
+ "select * from data where
+ a = TRUE AND
+ b = 0 AND
+ c = 0 AND
+ d = 0 AND
+ e = 0 AND
+ f = 0 AND
+ g = 0 AND
+ h = 0 AND
+ i = 0;",
+ )
+ .await?;
+ println!("{:?}", df.clone().collect().await.unwrap());
+ let plan = df.into_optimized_plan()?;
+ let proto = to_substrait_plan(&plan)?;
+ let plan2 = from_substrait_plan(&mut ctx, &proto).await?;
+ let plan2 = ctx.state().optimize(&plan2)?;
+
+ println!("{plan:#?}");
+ println!("{plan2:#?}");
+
+ let plan1str = format!("{plan:?}");
+ let plan2str = format!("{plan2:?}");
+ assert_eq!(plan1str, plan2str);
+ Ok(())
+ }
+
+ #[tokio::test]
+ async fn integer_type_literal() -> Result<()> {
+ roundtrip_all_types(
+ "select * from data where
+ a = TRUE AND
+ b = 0 AND
+ c = 0 AND
+ d = 0 AND
+ e = 0 AND
+ f = 0 AND
+ g = 0 AND
+ h = 0 AND
+ i = 0;",
+ )
+ .await
+ }
+
+ // Literal in this cases have incorrect type. This is not a good case
+ #[tokio::test]
+ async fn other_type_literal() -> Result<()> {
Review Comment:
Literals in this case have different types with the columns :cry:
--
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]