ggjh-159 commented on code in PR #13742: URL: https://github.com/apache/gluten/pull/13742#discussion_r4755476939
########## gluten-flink/ut/src/test/java/org/apache/gluten/table/runtime/stream/custom/WindowJoinTumbleTest.java: ########## @@ -0,0 +1,144 @@ +/* + * 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. + */ +package org.apache.gluten.table.runtime.stream.custom; + +import org.apache.gluten.table.runtime.stream.common.GlutenStreamingTestBase; + + +import org.junit.jupiter.api.Test; + + +import org.apache.flink.types.Row; +import java.util.Arrays; +import java.time.LocalDateTime; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * SQL-level tests for the TUMBLE window TVF (velox projection) and the + * TUMBLE window join (velox operator). Each test compares the rows the + * gluten translation produces against the rows Flink semantics requires. + */ +class WindowJoinTumbleTest extends GlutenStreamingTestBase { + + // A bounded table with event-time values and a watermark. The test base + // runs in bounded mode: the final watermark (MAX) fires every window. + private void createTumbleTables() { + createSimpleBoundedValuesTable( + "tumbleSrc", + "ts TIMESTAMP(3), k INT, v VARCHAR, " + + "WATERMARK FOR ts AS ts - INTERVAL '1' SECOND", + Arrays.asList( + Row.of(LocalDateTime.parse("2024-01-01T00:00:02"), 1, "a"), + Row.of(LocalDateTime.parse("2024-01-01T00:00:05"), 1, "b"), + Row.of(LocalDateTime.parse("2024-01-01T00:00:08"), 2, "c"))); + } + + @Test + void testTumbleTVFWindowBounds() { + createTumbleTables(); + String query = + "SELECT k, window_start, window_end, COUNT(*) AS cnt " + + "FROM TABLE(" + + " TUMBLE(TABLE tumbleSrc, DESCRIPTOR(ts), INTERVAL '5' SECONDS)" + + ") " + + "GROUP BY k, window_start, window_end"; + List<String> rows = runQuery(query); + // k=1: both rows (ts=2, ts=5) land in window [00:00:00, 00:00:05) = + // 2 rows. k=2: ts=8 lands in [00:00:05, 00:00:10) = 1 row. + assertThat(rows).hasSize(2); Review Comment: Two of the four new SQL-level tests fail on the stack this PR pins, and the expectations do not match Flink. testTumbleTVFWindowBounds (the TVF followed by GROUP BY k, window_start, window_end) returns no rows: that query goes through the existing group-window aggregation offload, which the stacked framework branch now rejects with "WindowAggregator is not yet migrated to operator-owned keyed state". testTumbleWindowJoin expects five pairs, but a row at 00:00:05 belongs to [00:00:05, 00:00:10), not [00:00:00, 00:00:05), so Flink returns three pairs - (1,a,1,a), (1,b,1,b), (2,c,2,c); the run returns one because the windows that fire only at the end of input are lost (see the velox PR). testTumbleTVFRawProjection checks only the row count, not the bounds. Please correct the expectations to Flink's, make all four pass on the pinned stack, and assert the exact window bounds. -- 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]
