alamb commented on code in PR #3124:
URL: https://github.com/apache/arrow-datafusion/pull/3124#discussion_r959928739
##########
datafusion/expr/src/function.rs:
##########
@@ -73,7 +73,23 @@ macro_rules! make_utf8_to_return_type {
make_utf8_to_return_type!(utf8_to_str_type, DataType::LargeUtf8,
DataType::Utf8);
make_utf8_to_return_type!(utf8_to_int_type, DataType::Int64, DataType::Int32);
-make_utf8_to_return_type!(utf8_to_binary_type, DataType::Binary,
DataType::Binary);
+
+fn utf8_or_binary_to_binary_type(arg_type: &DataType, name: &str) ->
Result<DataType> {
+ Ok(match arg_type {
+ DataType::LargeUtf8
+ | DataType::Utf8
+ | DataType::Binary
+ | DataType::LargeBinary => DataType::Binary,
+ DataType::Null => DataType::Null,
+ _ => {
+ // this error is internal as `data_types` should have captured
this.
+ return Err(DataFusionError::Internal(format!(
+ "The {:?} function can only accept strings.",
Review Comment:
I think this error message should refer to `Binary` in addition to strings
##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -1649,3 +1649,68 @@ async fn binary_mathematical_operator_with_null_lt() {
assert!(batch.columns()[0].is_null(1));
}
}
+
+#[tokio::test]
+async fn query_binary_eq() -> Result<()> {
+ let schema = Arc::new(Schema::new(vec![
+ Field::new("c1", DataType::Binary, true),
+ Field::new("c2", DataType::LargeBinary, true),
+ Field::new("c3", DataType::Binary, true),
+ Field::new("c4", DataType::LargeBinary, true),
+ ]));
+
+ let c1 = BinaryArray::from_opt_vec(vec![
+ Some(b"one"),
+ Some(b"two"),
+ None,
+ Some(b""),
+ Some(b"three"),
+ ]);
+ let c2 = LargeBinaryArray::from_opt_vec(vec![
+ Some(b"one"),
+ Some(b"two"),
+ None,
+ Some(b""),
+ Some(b"three"),
+ ]);
+ let c3 = BinaryArray::from_opt_vec(vec![
+ Some(b"one"),
+ Some(b""),
+ None,
+ Some(b""),
+ Some(b"three"),
+ ]);
+ let c4 = LargeBinaryArray::from_opt_vec(vec![
+ Some(b"one"),
+ Some(b"two"),
+ None,
+ Some(b""),
+ Some(b""),
+ ]);
+
+ let data = RecordBatch::try_new(
+ schema.clone(),
+ vec![Arc::new(c1), Arc::new(c2), Arc::new(c3), Arc::new(c4)],
+ )?;
+
+ let table = MemTable::try_new(schema, vec![vec![data]])?;
+
+ let ctx = SessionContext::new();
+
+ ctx.register_table("test", Arc::new(table))?;
+
+ let sql = "
Review Comment:
👍
Thanks @ozgrakkurt
--
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]