alamb commented on code in PR #8327:
URL: https://github.com/apache/arrow-datafusion/pull/8327#discussion_r1407725548


##########
datafusion/core/tests/window.rs:
##########
@@ -0,0 +1,140 @@
+// 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.
+
+//! Tests for window queries
+use std::sync::Arc;
+
+use arrow_array::RecordBatch;
+use arrow_schema::{DataType, Field, Schema};
+use datafusion::prelude::SessionContext;
+use datafusion_common::{assert_batches_eq, Result, ScalarValue};
+use datafusion_execution::config::SessionConfig;
+use datafusion_expr::{WindowFrame, WindowFrameBound, WindowFrameUnits};
+use datafusion_physical_expr::expressions::{col, NthValue};
+use datafusion_physical_expr::window::{BuiltInWindowExpr, 
BuiltInWindowFunctionExpr};
+use datafusion_physical_plan::memory::MemoryExec;
+use datafusion_physical_plan::windows::{BoundedWindowAggExec, 
PartitionSearchMode};
+use datafusion_physical_plan::{collect, get_plan_string, ExecutionPlan};
+
+// Tests NTH_VALUE(negative index) with memoize feature.
+// To be able to trigger memoize feature for NTH_VALUE we need to
+// - feed BoundedWindowAggExec with batch stream data.
+// - Window frame should contain UNBOUNDED PRECEDING.
+// It hard to ensure these conditions are met, from the sql query.

Review Comment:
   I think this test would more naturally belong in the same module as 
`BoundedWindowAggExec` as it uses pretty low level APIs (i wouldn't really 
expect any users to ever write this kind of query)
   
   I suggest:
   1. Change this test to use the LogicalPlan or DataFrame APIs instead
   2. Move the test into 
https://github.com/apache/arrow-datafusion/blob/main/datafusion/physical-plan/src/windows/bounded_window_agg_exec.rs



##########
datafusion/physical-expr/src/window/nth_value.rs:
##########
@@ -162,16 +165,27 @@ impl PartitionEvaluator for NthValueEvaluator {
             NthValueKind::Nth(n) => {
                 let n_range =
                     state.window_frame_range.end - 
state.window_frame_range.start;
-                (n_range >= (n as usize) && size >= (n as usize), false)
+                #[allow(clippy::comparison_chain)]

Review Comment:
   Is there any particular reason not to follow clippy style (with cmp and 
match)? 
   
   
https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/comparison_chain.rs



##########
datafusion/core/tests/window.rs:
##########
@@ -0,0 +1,140 @@
+// Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   I wonder if we can make this a submodule under core_integration (each test 
binary takes up non trivial disk space and a while ago we hit runner disk space 
limits)
   
   Aka make it a module in a subdirectory as part of 
   https://github.com/apache/arrow-datafusion/blob/main/datafusion/core/tests
   
   



##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3493,6 +3493,48 @@ select sum(1) over() x, sum(1) over () y
 ----
 1 1
 
+query TT

Review Comment:
   Could you please leave a comment explaining what this is a test for 
(specifically that you are expecting that the nth value should be negative)? 
   
   Also I can't see a negative nth value in the plan so maybe I am missing 
something



##########
datafusion/physical-expr/src/window/nth_value.rs:
##########
@@ -77,17 +79,17 @@ impl NthValue {
         n: u32,

Review Comment:
   why not change  this API  to accept i64? It seems strange that the public 
interface doesn't support negative NTH valuess



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

Reply via email to