This is an automated email from the ASF dual-hosted git repository.
wayne pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 9798fbcab1 Port math.rs to sqllogictest (#6037)
9798fbcab1 is described below
commit 9798fbcab1e04123f05e7692475e104310e0473a
Author: Yongting You <[email protected]>
AuthorDate: Tue Apr 18 19:40:32 2023 -0700
Port math.rs to sqllogictest (#6037)
* Port math.rs to sqllogictest
* Remove table creation
* Adding null edge cases for atan2 test.
---
datafusion/core/tests/sql/math.rs | 56 ----------------------
datafusion/core/tests/sql/mod.rs | 1 -
.../core/tests/sqllogictests/test_files/math.slt | 6 +++
3 files changed, 6 insertions(+), 57 deletions(-)
diff --git a/datafusion/core/tests/sql/math.rs
b/datafusion/core/tests/sql/math.rs
deleted file mode 100644
index 89691242d0..0000000000
--- a/datafusion/core/tests/sql/math.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use super::*;
-use arrow::array::Float64Array;
-
-#[tokio::test]
-async fn test_atan2() -> Result<()> {
- let ctx = SessionContext::new();
-
- let t1_schema = Arc::new(Schema::new(vec![
- Field::new("x", DataType::Float64, true),
- Field::new("y", DataType::Float64, true),
- ]));
-
- let t1_data = RecordBatch::try_new(
- t1_schema.clone(),
- vec![
- Arc::new(Float64Array::from(vec![1.0, 1.0, -1.0, -1.0])),
- Arc::new(Float64Array::from(vec![2.0, -2.0, 2.0, -2.0])),
- ],
- )?;
- ctx.register_batch("t1", t1_data)?;
-
- let sql = "SELECT atan2(y, x) FROM t1";
- let actual = execute_to_batches(&ctx, sql).await;
-
- let expected = vec![
- "+---------------------+",
- "| atan2(t1.y,t1.x) |",
- "+---------------------+",
- "| 1.1071487177940904 |",
- "| -1.1071487177940904 |",
- "| 2.0344439357957027 |",
- "| -2.0344439357957027 |",
- "+---------------------+",
- ];
-
- assert_batches_eq!(expected, &actual);
-
- Ok(())
-}
diff --git a/datafusion/core/tests/sql/mod.rs b/datafusion/core/tests/sql/mod.rs
index 2a05c918b5..192e2f65f8 100644
--- a/datafusion/core/tests/sql/mod.rs
+++ b/datafusion/core/tests/sql/mod.rs
@@ -91,7 +91,6 @@ pub mod group_by;
pub mod joins;
pub mod json;
pub mod limit;
-pub mod math;
pub mod order;
pub mod parquet;
pub mod predicates;
diff --git a/datafusion/core/tests/sqllogictests/test_files/math.slt
b/datafusion/core/tests/sqllogictests/test_files/math.slt
index 84f0d4988d..152e8b78bd 100644
--- a/datafusion/core/tests/sqllogictests/test_files/math.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/math.slt
@@ -87,3 +87,9 @@ query RRRRRRRR
SELECT round(125.2345, -3), round(125.2345, -2), round(125.2345, -1),
round(125.2345), round(125.2345, 0), round(125.2345, 1), round(125.2345, 2),
round(125.2345, 3)
----
0 100 130 125 125 125.2 125.23 125.235
+
+# atan2
+query RRRRRRR
+SELECT atan2(2.0, 1.0), atan2(-2.0, 1.0), atan2(2.0, -1.0), atan2(-2.0, -1.0),
atan2(NULL, 1.0), atan2(2.0, NULL), atan2(NULL, NULL);
+----
+1.107148717794 -1.107148717794 2.034443935796 -2.034443935796 NULL NULL NULL