alamb commented on a change in pull request #716:
URL: https://github.com/apache/arrow-datafusion/pull/716#discussion_r669916709
##########
File path: datafusion/src/execution/context.rs
##########
@@ -2364,6 +2365,75 @@ mod tests {
assert_batches_sorted_eq!(expected, &results);
}
+ #[tokio::test]
+ async fn case_builtin_math_expression() {
+ let mut ctx = ExecutionContext::new();
+
+ let type_values = vec![
+ (
+ DataType::Int8,
+ Arc::new(Int8Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::Int16,
+ Arc::new(Int16Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::Int32,
+ Arc::new(Int32Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::Int64,
+ Arc::new(Int64Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::UInt8,
+ Arc::new(UInt8Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::UInt16,
+ Arc::new(UInt16Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::UInt32,
+ Arc::new(UInt32Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::UInt64,
+ Arc::new(UInt64Array::from(vec![1])) as ArrayRef,
+ ),
+ (
+ DataType::Float32,
+ Arc::new(Float32Array::from(vec![1.0_f32])) as ArrayRef,
+ ),
+ (
+ DataType::Float64,
+ Arc::new(Float64Array::from(vec![1.0_f64])) as ArrayRef,
+ ),
+ ];
+
+ for (data_type, array) in type_values.iter() {
+ let schema =
+ Arc::new(Schema::new(vec![Field::new("v", data_type.clone(),
false)]));
+ let batch =
+ RecordBatch::try_new(schema.clone(),
vec![array.clone()]).unwrap();
+ let provider = MemTable::try_new(schema,
vec![vec![batch]]).unwrap();
+ ctx.register_table("t", Arc::new(provider)).unwrap();
+ let expected = vec![
+ "+---------+",
+ "| sqrt(v) |",
+ "+---------+",
+ "| 1 |",
+ "+---------+",
+ ];
+ let results = plan_and_collect(&mut ctx, "SELECT sqrt(v) FROM t")
Review comment:
👍 it is a good test. We can finagle the types later if needed (e.g. if
we ever want to support `sqrt(numeric)` --> `numeric`.
I think this PR makes DataFusion better than it is on master.
--
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]