martin-g commented on code in PR #20479:
URL: https://github.com/apache/datafusion/pull/20479#discussion_r2840329864


##########
datafusion/spark/src/function/math/bin.rs:
##########
@@ -15,9 +15,10 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use arrow::array::{ArrayRef, AsArray, Int64Array};
-use arrow::datatypes::Field;
-use arrow::datatypes::{DataType, FieldRef, Int8Type, Int16Type, Int32Type, 
Int64Type};
+use arrow::array::{ArrayRef, AsArray, StringArray};
+use arrow::datatypes::{
+    DataType, Field, FieldRef, Int8Type, Int16Type, Int32Type, Int64Type,
+};
 use datafusion::logical_expr::{ColumnarValue, Signature, TypeSignature, 
Volatility};

Review Comment:
   nit:
   ```suggestion
   use datafusion_expr::{ColumnarValue, Signature, TypeSignature, Volatility};
   ```



##########
datafusion/spark/src/function/math/bin.rs:
##########


Review Comment:
   Actually Spark's bin() supports even floating numbers:
   ```
   spark-sql (default)> select bin(13);
   1101
   Time taken: 0.785 seconds, Fetched 1 row(s)
   spark-sql (default)> select bin(-13);
   1111111111111111111111111111111111111111111111111111111111110011
   Time taken: 0.032 seconds, Fetched 1 row(s)
   spark-sql (default)> select bin(13.3);
   1101
   Time taken: 0.04 seconds, Fetched 1 row(s)
   ```
   The function documentation says: "Returns the string representation of the 
**long** value expr represented in binary"
   So, it should use `logical_number` above



##########
datafusion/spark/src/function/math/bin.rs:
##########


Review Comment:
   This could use coercible signature instead:
   ```rust
   let int64 = Coercion::new_implicit(
       TypeSignatureClass::Native(logical_int64()),
       vec![TypeSignatureClass::Numeric],
       NativeType::Int64,
   );
   TypeSignature::Coercible(vec![int64])
   ```



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