You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/30 00:36:11 UTC

[GitHub] [arrow-datafusion] comphead commented on issue #3644: Type coercion error: The type of Boolean AND Decimal128(10, 2) of binary physical should be same

comphead commented on issue #3644:
URL: https://github.com/apache/arrow-datafusion/issues/3644#issuecomment-1262972079

   @andygrove please attach the test.csv file?
   
   I tried 2 tests with pure sql, those works.
   
   ```
   #[tokio::test]
   async fn test_decimal_optimizer() -> Result<()> {
       let ctx = SessionContext::new();
   
       let sql = "select * from (SELECT cast(1 as decimal(10,2)) a, cast(2 as decimal(10,2)) b) test where a != b and case when b > a then a/b else null end >= case when a > b then a/b else null end;";
       let actual = execute_to_batches(&ctx, sql).await;
   
   
       Ok(())
   }
   
   #[tokio::test]
   async fn test_decimal_optimizer1() -> Result<()> {
       let schema = Arc::new(Schema::new(vec![
           Field::new("a", DataType::Decimal128(10,2), true),
           Field::new("b", DataType::Decimal128(10,2), true),
       ]));
   
       let data = RecordBatch::try_new(
           schema.clone(),
           vec![
               Arc::new(
                   Decimal128Array::from_iter_values([1])
                       .with_precision_and_scale(10, 2)
                       .unwrap(),
               ),
               Arc::new(
                   Decimal128Array::from_iter_values([2])
                       .with_precision_and_scale(10, 2)
                       .unwrap(),
               ),
           ],
       )?;
   
       let table = MemTable::try_new(schema, vec![vec![data]])?;
   
       let ctx = SessionContext::new();
       ctx.register_table("test", Arc::new(table))?;
   
   
       let sql = "select * from test where a != b and case when b > a then a/b else null end >= case when a > b then a/b else null end;";
       let actual = execute_to_batches(&ctx, sql).await;
   
   
       Ok(())
   }
   ```


-- 
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-unsubscribe@arrow.apache.org

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