Jefffrey commented on code in PR #20479:
URL: https://github.com/apache/datafusion/pull/20479#discussion_r2850608454


##########
datafusion/spark/src/function/math/bin.rs:
##########
@@ -78,64 +79,57 @@ impl ScalarUDFImpl for BitmapBucketNumber {
     ) -> Result<FieldRef> {
         Ok(Arc::new(Field::new(
             self.name(),
-            DataType::Int64,
+            DataType::Utf8,
             args.arg_fields[0].is_nullable(),
         )))
     }
 
     fn invoke_with_args(&self, args: ScalarFunctionArgs) -> 
Result<ColumnarValue> {
-        make_scalar_function(bitmap_bucket_number_inner, vec![])(&args.args)
+        make_scalar_function(spark_bin_inner, vec![])(&args.args)
     }
 }
 
-pub fn bitmap_bucket_number_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {
-    let [array] = take_function_args("bitmap_bucket_number", arg)?;
+pub fn spark_bin_inner(arg: &[ArrayRef]) -> Result<ArrayRef> {

Review Comment:
   This wasn't addressed



##########
datafusion/spark/src/function/math/bin.rs:
##########
@@ -0,0 +1,177 @@
+// 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 arrow::array::{ArrayRef, AsArray, StringArray};
+use arrow::datatypes::{
+    DataType, Decimal32Type, Decimal64Type, Field, FieldRef, Float16Type, 
Float32Type,
+    Float64Type, Int8Type, Int16Type, Int32Type, Int64Type,
+};
+use bigdecimal::ToPrimitive;
+use datafusion::logical_expr::{ColumnarValue, Signature, TypeSignature, 
Volatility};
+use datafusion_common::types::{NativeType, logical_int64};
+use datafusion_common::utils::take_function_args;
+use datafusion_common::{Result, internal_err};
+use datafusion_expr::{Coercion, ScalarFunctionArgs, ScalarUDFImpl, 
TypeSignatureClass};
+use datafusion_functions::utils::make_scalar_function;
+use std::any::Any;
+use std::sync::Arc;
+
+/// Spark-compatible `bin` expression
+/// <https://spark.apache.org/docs/latest/api/sql/index.html#bin>
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkBin {
+    signature: Signature,
+}
+
+impl Default for SparkBin {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
+impl SparkBin {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::one_of(
+                vec![TypeSignature::Coercible(vec![Coercion::new_implicit(
+                    TypeSignatureClass::Native(logical_int64()),
+                    vec![TypeSignatureClass::Numeric],
+                    NativeType::Int64,
+                )])],
+                Volatility::Immutable,
+            ),

Review Comment:
   This signature essentially casts all numeric input types to i64 before the 
function receives it; this means the arms in`spark_bin_inner` that pertain to 
checking for float, decimal, ints (that aren't i64) are essentially dead code 
as they'll never be reached



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to