andygrove commented on code in PR #341:
URL: https://github.com/apache/datafusion-spark/pull/341#discussion_r4614280574
##########
crates/sqllogictest/test_files/datetime/make_time.slt:
##########
@@ -271,6 +271,25 @@ NULL
statement ok
DROP TABLE make_time_t;
+# A NULL in any argument returns NULL before the other fields are checked
+statement ok
+CREATE TABLE make_time_null_t AS VALUES
+ (NULL::INT, 60, 60::DECIMAL(16, 6)),
+ (24, NULL::INT, -0.5::DECIMAL(16, 6)),
+ (24, 60, NULL::DECIMAL(16, 6)),
+ (1, 2, 3::DECIMAL(16, 6));
+
+query D
Review Comment:
Done in 4564ee8.
##########
crates/spark/src/function/datetime/make_time.rs:
##########
@@ -281,4 +281,89 @@ mod tests {
);
Ok(())
}
+
+ fn invoke_array(args: Vec<ArrayRef>) -> Result<Time64NanosecondArray> {
+ let ColumnarValue::Array(array) = invoke(args)? else {
+ unreachable!("make_time returns an array")
+ };
+ Ok(array.as_primitive::<Time64NanosecondType>().clone())
+ }
+
+ fn nanos(hours: i64, minutes: i64, secs: i64) -> i64 {
+ (hours * 3_600 + minutes * 60 + secs) * 1_000_000_000
+ }
+
+ #[test]
+ fn test_sliced_arrays() -> Result<()> {
+ // The invalid fields sit outside the visible slices, so the kernel
must
+ // honour each array's offset to succeed. The slices also start at
+ // different offsets, and their null bitmaps are sliced too.
+ let hours: ArrayRef = Arc::new(Int32Array::from(vec![
+ Some(99),
+ Some(1),
+ None,
+ Some(3),
+ Some(4),
+ Some(99),
+ ]));
+ let minutes: ArrayRef = Arc::new(Int32Array::from(vec![
+ Some(99),
+ Some(99),
+ Some(10),
+ Some(20),
+ None,
+ Some(40),
+ Some(99),
+ ]));
+ let secs: ArrayRef = Arc::new(
+ Decimal128Array::from(vec![
+ Some(-1),
+ Some(-1),
+ Some(-1),
+ Some(5_000_000),
+ Some(6_000_000),
+ Some(7_000_000),
+ None,
+ Some(-1),
+ ])
+ .with_precision_and_scale(16, 6)
+ .unwrap(),
+ );
+
+ let result = invoke_array(vec![
+ hours.slice(1, 4),
+ minutes.slice(2, 4),
+ secs.slice(3, 4),
+ ])?;
+ assert_eq!(
+ result,
+ Time64NanosecondArray::from(vec![Some(nanos(1, 10, 5)), None,
None, None,])
+ );
+ assert_eq!(result.offset(), 0);
Review Comment:
Removed in 4564ee8.
--
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]