alamb commented on code in PR #8842:
URL: https://github.com/apache/arrow-datafusion/pull/8842#discussion_r1450985891
##########
datafusion/expr/src/window_frame.rs:
##########
@@ -30,21 +30,24 @@ use sqlparser::ast;
use sqlparser::parser::ParserError::ParserError;
use std::convert::{From, TryFrom};
use std::fmt;
+use std::fmt::Formatter;
use std::hash::Hash;
/// The frame-spec determines which output rows are read by an aggregate
window function.
///
/// The ending frame boundary can be omitted (if the BETWEEN and AND keywords
that surround the
/// starting frame boundary are also omitted), in which case the ending frame
boundary defaults to
/// CURRENT ROW.
-#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash)]
pub struct WindowFrame {
/// A frame type - either ROWS, RANGE or GROUPS
pub units: WindowFrameUnits,
/// A starting frame boundary
pub start_bound: WindowFrameBound,
/// An ending frame boundary
pub end_bound: WindowFrameBound,
+ /// Flag indicates whether window frame is causal.
Review Comment:
Can you please document what `causal` means in this context (I am not sure I
understand what it means)? Perhaps you can update the doc comments on
`WindowFrame` to explain what the concept is and give an example of a causal
bound and non causal bound and then link to that definition when referred to
elsewhere?
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3871,3 +3871,31 @@ FROM (SELECT c1, c2, ROW_NUMBER() OVER(PARTITION BY c1)
as rn
LIMIT 5)
GROUP BY rn
ORDER BY rn;
+
+# create a table for testing
+statement ok
+CREATE TABLE table_with_pk (
+ sn INT PRIMARY KEY,
+ ts TIMESTAMP,
+ currency VARCHAR(3),
+ amount FLOAT
+ ) as VALUES
+ (0, '2022-01-01 06:00:00'::timestamp, 'EUR', 30.0),
+ (1, '2022-01-01 08:00:00'::timestamp, 'EUR', 50.0),
+ (2, '2022-01-01 11:30:00'::timestamp, 'TRY', 75.0),
+ (3, '2022-01-02 12:00:00'::timestamp, 'EUR', 200.0),
+ (4, '2022-01-03 10:00:00'::timestamp, 'TRY', 100.0)
+
+query TT
+EXPLAIN SELECT *, SUM(amount) OVER(ORDER BY sn) as sum1
Review Comment:
Could you add some comments here explaining what this test is validating
(specifically so if it changes in the future we will have some additional
context on the intent of the test)?
##########
datafusion/sql/src/expr/function.rs:
##########
@@ -102,6 +103,21 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
// Numeric literals in window function ORDER BY are treated as
constants
false,
)?;
+
+ let func_deps = schema.functional_dependencies();
Review Comment:
Could you document what ordering is stable means ?
--
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]