huaxingao commented on code in PR #9801:
URL: https://github.com/apache/arrow-datafusion/pull/9801#discussion_r1540281687
##########
datafusion/core/tests/sql/aggregates.rs:
##########
@@ -401,3 +401,83 @@ async fn test_first_value_with_sort() -> Result<()> {
Ok(())
}
+
+#[tokio::test]
+async fn last_value() -> Result<()> {
+ let session_ctx = SessionContext::new();
+ session_ctx
+ .sql("CREATE TABLE abc AS VALUES (1, 2, 3), (null, 5, 6)")
Review Comment:
Removed. I have also removed `first_value` test I added last time
##########
datafusion/sqllogictest/test_files/aggregate.slt:
##########
@@ -3376,3 +3376,55 @@ SELECT FIRST_VALUE(column1 ORDER BY column2) IGNORE
NULLS FROM t;
statement ok
DROP TABLE t;
+
+# Test for ignore null in LAST_VALUE
+statement ok
+CREATE TABLE t AS VALUES (3), (4), (null::bigint);
+
+query I
+SELECT LAST_VALUE(column1) FROM t;
+----
+NULL
+
+query I
+SELECT LAST_VALUE(column1) RESPECT NULLS FROM t;
+----
+NULL
+
+query I
+SELECT LAST_VALUE(column1) IGNORE NULLS FROM t;
+----
+4
+
+statement ok
+DROP TABLE t;
+
+# Test for ignore null with ORDER BY in LASR_VALUE
Review Comment:
Fixed. Thanks
##########
datafusion/sqllogictest/test_files/aggregate.slt:
##########
@@ -3376,3 +3376,55 @@ SELECT FIRST_VALUE(column1 ORDER BY column2) IGNORE
NULLS FROM t;
statement ok
DROP TABLE t;
+
+# Test for ignore null in LAST_VALUE
+statement ok
+CREATE TABLE t AS VALUES (3), (4), (null::bigint);
+
+query I
+SELECT LAST_VALUE(column1) FROM t;
+----
+NULL
+
+query I
+SELECT LAST_VALUE(column1) RESPECT NULLS FROM t;
+----
+NULL
+
+query I
+SELECT LAST_VALUE(column1) IGNORE NULLS FROM t;
+----
+4
+
+statement ok
+DROP TABLE t;
+
+# Test for ignore null with ORDER BY in LASR_VALUE
+statement ok
+CREATE TABLE t AS VALUES (3, 3), (4, 4), (null::bigint, 1), (null::bigint, 2);
+
+query I
+SELECT column1 FROM t ORDER BY column2 DESC;
+----
+4
+3
+NULL
+NULL
+
+query I
+SELECT LAST_VALUE(column1 ORDER BY column2 DESC) FROM t;
+----
+NULL
+
+query I
+SELECT LAST_VALUE(column1 ORDER BY column2 DESC) FROM t;
Review Comment:
Fixed. Thanks
--
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]