You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Weijun-H (via GitHub)" <gi...@apache.org> on 2024/03/30 12:24:30 UTC

[PR] move `Atan`, `Acosh`, `Asinh`, `Atanh` to `datafusion-function` [arrow-datafusion]

Weijun-H opened a new pull request, #9872:
URL: https://github.com/apache/arrow-datafusion/pull/9872

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Relates #9285
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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


Re: [PR] move `Atan`, `Acosh`, `Asinh`, `Atanh` to `datafusion-function` [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9872:
URL: https://github.com/apache/arrow-datafusion/pull/9872#discussion_r1545350387


##########
datafusion/sqllogictest/test_files/order.slt:
##########
@@ -527,9 +527,10 @@ Sort: atan_c11 ASC NULLS LAST
 ----TableScan: aggregate_test_100 projection=[c11]
 physical_plan
 SortPreservingMergeExec: [atan_c11@0 ASC NULLS LAST]
---ProjectionExec: expr=[atan(c11@0) as atan_c11]
-----RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
-------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c11], output_ordering=[c11@0 ASC NULLS LAST], has_header=true
+--SortExec: expr=[atan_c11@0 ASC NULLS LAST]

Review Comment:
   This test seems to show a regression (there is now a sort in it).
   I wonder if the issue is that you need to specify montononicity (which is now possible after https://github.com/apache/arrow-datafusion/pull/9869 from @tinfoil-knight )?
   
   



##########
datafusion/expr/src/built_in_function.rs:
##########
@@ -37,16 +37,8 @@ use strum_macros::EnumIter;
 #[derive(Debug, Clone, PartialEq, Eq, Hash, EnumIter, Copy)]
 pub enum BuiltinScalarFunction {
     // math functions
-    /// atan
-    Atan,
     /// atan2
     Atan2,

Review Comment:
   any particular reason that you did not migrate Atan2?



-- 
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


Re: [PR] move `Atan`, `Acosh`, `Asinh`, `Atanh` to `datafusion-function` [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #9872:
URL: https://github.com/apache/arrow-datafusion/pull/9872#issuecomment-2028459104

   Marking as draft as I think this PR is no longer waiting on feedback. Please mark it as ready for review when it is ready for another look 


-- 
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


Re: [PR] move `Atan2`, `Atan`, `Acosh`, `Asinh`, `Atanh` to `datafusion-function` [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9872:
URL: https://github.com/apache/arrow-datafusion/pull/9872#discussion_r1545589707


##########
datafusion/functions/src/utils.rs:
##########
@@ -68,6 +68,9 @@ get_optimal_return_type!(utf8_to_str_type, DataType::LargeUtf8, DataType::Utf8);
 // `utf8_to_int_type`: returns either a Int32 or Int64 based on the input type size.
 get_optimal_return_type!(utf8_to_int_type, DataType::Int64, DataType::Int32);
 
+/// Creates a scalar function implementation for the given function.

Review Comment:
   ❤️ 



##########
datafusion/functions/src/math/atan2.rs:
##########
@@ -0,0 +1,140 @@
+// 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.
+
+//! Math function: `atan2()`.
+
+use arrow::array::{ArrayRef, Float32Array, Float64Array};
+use arrow::datatypes::DataType;
+use datafusion_common::DataFusionError;
+use datafusion_common::{exec_err, Result};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::TypeSignature::*;
+use datafusion_expr::{ScalarUDFImpl, Signature, Volatility};
+use std::any::Any;
+use std::sync::Arc;
+
+use crate::make_function_inputs2;
+use crate::utils::make_scalar_function;
+
+#[derive(Debug)]
+pub(super) struct Atan2 {
+    signature: Signature,
+}
+
+impl Atan2 {

Review Comment:
   Maybe if we have more two argument math functions we can eventually macroize this like we have a macro for single argument functions



-- 
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


Re: [PR] move `Atan2`, `Atan`, `Acosh`, `Asinh`, `Atanh` to `datafusion-function` [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #9872:
URL: https://github.com/apache/arrow-datafusion/pull/9872#issuecomment-2028618373

   merging this quickly to keep the train going and minimize potential conflicts


-- 
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


Re: [PR] move `Atan2`, `Atan`, `Acosh`, `Asinh`, `Atanh` to `datafusion-function` [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #9872:
URL: https://github.com/apache/arrow-datafusion/pull/9872


-- 
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