You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "shuai-xu (via GitHub)" <gi...@apache.org> on 2025/08/27 03:56:15 UTC

[PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

shuai-xu opened a new pull request, #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548

   ## What changes are proposed in this pull request?
   This pr contains:
   1. support all the operators use for nexmark test, e.g. GroupAgg, Rank, TopN
   2. nexmark q18, q19, q20, q21 run pass, while the result is not equal to flink yet.
   3. support checkpoint related interfaces.
   
   ## How was this patch tested?
   This pr is tested by manually run nexmark tests.
   


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

Posted by "shuai-xu (via GitHub)" <gi...@apache.org>.
shuai-xu commented on PR #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548#issuecomment-3251381399

   > try to run but it seems to fail due to memory leak error: `E20250830 11:49:14.568943 3949495 MemoryManager.cc:264] [Velox4J MemoryManager DTOR] Memory leak found on Velox memory pool: Memory Pool[Decoding Memory Pool LEAF root[root] parent[root] MALLOC track-usage thread-safe]<unlimited max capacity capacity 128.00MB used 512B available 1023.50KB reservation [used 512B, reserved 1.00MB, min 0B] counters [allocs 4, frees 0, reserves 0, releases 0, collisions 0])>. Please make sure your code released all opened resources already. E20250830 11:49:14.569058 3949495 MemoryManager.cc:264] [Velox4J MemoryManager DTOR] Memory leak found on Velox memory pool: Memory Pool[root AGGREGATE root[root] parent[null] MALLOC track-usage thread-safe]<unlimited max capacity capacity 128.00MB used 512B available 0B reservation [used 0B, reserved 1.00MB, min 0B] counters [allocs 0, frees 0, reserves 0, releases 0, collisions 0])>. Please make sure your code released all opened resources already. E202
 50830 11:49:14.569092 3949495 MemoryPool.cpp:461] [MEM] Memory leak (Used memory): Memory Pool[Decoding Memory Pool LEAF root[root] parent[root] MALLOC track-usage thread-safe]<unlimited max capacity capacity 128.00MB used 512B available 1023.50KB reservation [used 512B, reserved 1.00MB, min 0B] counters [allocs 4, frees 0, reserves 0, releases 0, collisions 0])> E20250830 11:49:14.569126 3949495 Exceptions.h:66] Line: velox4j/src/main/cpp/main/velox4j/memory/MemoryManager.cc:92, Function:removePool, Expression: pool->reservedBytes() == 0 (1048576 vs. 0), Source: RUNTIME, ErrorCode: INVALID_STATE terminate called after throwing an instance of 'facebook::velox::VeloxRuntimeError' what(): Exception: VeloxRuntimeError Error Source: RUNTIME Error Code: INVALID_STATE Reason: (1048576 vs. 0) Retriable: False Expression: pool->reservedBytes() == 0 Function: removePool File: velox4j/src/main/cpp/main/velox4j/memory/MemoryManager.cc Line: 92 Stack trace: 0 _ZN8facebook5velox7process10StackTr
 aceC1Ei 1 _ZN8facebook5velox14VeloxExceptionC1EPKcmS3_St17basic_string_viewIcSt11char_traitsIcEES7_S7_S7_bNS1_4TypeES7_ 2 _ZN8facebook5velox6detail14veloxCheckFailINS0_17VeloxRuntimeErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEvRKNS1_18VeloxCheckFailArgsET0_ 3 _ZN7velox4j12_GLOBAL__N_120ListenableArbitrator10removePoolEPN8facebook5velox6memory10MemoryPoolE 4 _ZN8facebook5velox6memory13MemoryManager8dropPoolEPNS1_10MemoryPoolE 5 _ZN8facebook5velox6memory14MemoryPoolImplD2Ev 6 _ZN7velox4j13MemoryManager11tryDestructEv 7 _ZN7velox4j13MemoryManagerD2Ev 8 _ZNSt10_HashtableIjSt4pairIKjSt10shared_ptrIvEESaIS4_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE8_M_eraseEmPNS6_15_Hash_node_baseEPNS6_10_Hash_nodeIS4_Lb0EEE 9 _ZN7velox4j11ResourceMapISt10shared_ptrIvEE5eraseEj 10 _ZN7velox4j11ObjectStore15releaseInternalEj 11 _ZN7velox4j12_GLOBAL__N_116releaseCp
 pObjectEP7JNIEnv_P8_jobjectl 12 0x0000ffff80769cfc ` any idea to solve?
   
   It seems this is not the root reason, the job may fail by some other reason, you can check the log.


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

Posted by "shuai-xu (via GitHub)" <gi...@apache.org>.
shuai-xu commented on code in PR #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548#discussion_r2320647367


##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecWindowAggregate.java:
##########
@@ -0,0 +1,333 @@
+/*
+ * 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.flink.table.planner.plan.nodes.exec.stream;
+
+import org.apache.gluten.rexnode.AggregateCallConverter;
+import org.apache.gluten.rexnode.Utils;
+import org.apache.gluten.rexnode.WindowUtils;
+import org.apache.gluten.table.runtime.operators.GlutenVectorOneInputOperator;
+import org.apache.gluten.util.LogicalTypeConverter;
+import org.apache.gluten.util.PlanNodeIdGenerator;
+
+import io.github.zhztheplayer.velox4j.aggregate.Aggregate;
+import io.github.zhztheplayer.velox4j.aggregate.AggregateStep;
+import io.github.zhztheplayer.velox4j.expression.FieldAccessTypedExpr;
+import io.github.zhztheplayer.velox4j.plan.AggregationNode;
+import io.github.zhztheplayer.velox4j.plan.EmptyNode;
+import io.github.zhztheplayer.velox4j.plan.HashPartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PlanNode;
+import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
+import io.github.zhztheplayer.velox4j.plan.StreamWindowAggregationNode;
+import io.github.zhztheplayer.velox4j.plan.StreamWindowPartitionFunctionSpec;
+
+import org.apache.flink.FlinkVersion;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.tuple.Tuple5;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.SimpleOperatorFactory;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.codegen.CodeGeneratorContext;
+import org.apache.flink.table.planner.codegen.agg.AggsHandlerCodeGenerator;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.plan.logical.WindowingStrategy;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata;
+import org.apache.flink.table.planner.plan.nodes.exec.InputProperty;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil;
+import org.apache.flink.table.planner.plan.utils.AggregateInfoList;
+import org.apache.flink.table.planner.plan.utils.KeySelectorUtil;
+import org.apache.flink.table.planner.utils.JavaScalaConversionUtil;
+import org.apache.flink.table.planner.utils.TableConfigUtils;
+import org.apache.flink.table.runtime.generated.GeneratedNamespaceAggsHandleFunction;
+import org.apache.flink.table.runtime.groupwindow.NamedWindowProperty;
+import org.apache.flink.table.runtime.groupwindow.WindowProperty;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.operators.window.TimeWindow;
+import org.apache.flink.table.runtime.operators.window.tvf.common.WindowAssigner;
+import org.apache.flink.table.runtime.operators.window.tvf.slicing.SliceSharedAssigner;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.runtime.util.TimeWindowUtil;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.tools.RelBuilder;
+import org.apache.commons.math3.util.ArithmeticUtils;
+
+import javax.annotation.Nullable;
+
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.TimeZone;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Stream {@link ExecNode} for window table-valued based aggregate.
+ *
+ * <p>The differences between {@link StreamExecWindowAggregate} and {@link
+ * StreamExecGroupWindowAggregate} is that, this node is translated from window TVF syntax, but the
+ * other is from the legacy GROUP WINDOW FUNCTION syntax. In the long future, {@link
+ * StreamExecGroupWindowAggregate} will be dropped.
+ */
+@ExecNodeMetadata(
+    name = "stream-exec-window-aggregate",
+    version = 1,
+    consumedOptions = "table.local-time-zone",
+    producedTransformations = StreamExecWindowAggregate.WINDOW_AGGREGATE_TRANSFORMATION,
+    minPlanVersion = FlinkVersion.v1_15,
+    minStateVersion = FlinkVersion.v1_15)
+public class StreamExecWindowAggregate extends StreamExecWindowAggregateBase {
+
+  public static final String WINDOW_AGGREGATE_TRANSFORMATION = "window-aggregate";
+
+  private static final long WINDOW_AGG_MEMORY_RATIO = 100;
+
+  public static final String FIELD_NAME_WINDOWING = "windowing";
+  public static final String FIELD_NAME_NAMED_WINDOW_PROPERTIES = "namedWindowProperties";
+
+  @JsonProperty(FIELD_NAME_GROUPING)
+  private final int[] grouping;
+
+  @JsonProperty(FIELD_NAME_AGG_CALLS)
+  private final AggregateCall[] aggCalls;
+
+  @JsonProperty(FIELD_NAME_WINDOWING)
+  private final WindowingStrategy windowing;
+
+  @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES)
+  private final NamedWindowProperty[] namedWindowProperties;
+
+  @JsonProperty(FIELD_NAME_NEED_RETRACTION)
+  private final boolean needRetraction;
+
+  public StreamExecWindowAggregate(
+      ReadableConfig tableConfig,
+      int[] grouping,
+      AggregateCall[] aggCalls,
+      WindowingStrategy windowing,
+      NamedWindowProperty[] namedWindowProperties,
+      Boolean needRetraction,
+      InputProperty inputProperty,
+      RowType outputType,
+      String description) {
+    this(
+        ExecNodeContext.newNodeId(),
+        ExecNodeContext.newContext(StreamExecWindowAggregate.class),
+        ExecNodeContext.newPersistedConfig(StreamExecWindowAggregate.class, tableConfig),
+        grouping,
+        aggCalls,
+        windowing,
+        namedWindowProperties,
+        needRetraction,
+        Collections.singletonList(inputProperty),
+        outputType,
+        description);
+  }
+
+  @JsonCreator
+  public StreamExecWindowAggregate(
+      @JsonProperty(FIELD_NAME_ID) int id,
+      @JsonProperty(FIELD_NAME_TYPE) ExecNodeContext context,
+      @JsonProperty(FIELD_NAME_CONFIGURATION) ReadableConfig persistedConfig,
+      @JsonProperty(FIELD_NAME_GROUPING) int[] grouping,
+      @JsonProperty(FIELD_NAME_AGG_CALLS) AggregateCall[] aggCalls,
+      @JsonProperty(FIELD_NAME_WINDOWING) WindowingStrategy windowing,
+      @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES) NamedWindowProperty[] namedWindowProperties,
+      @Nullable @JsonProperty(FIELD_NAME_NEED_RETRACTION) Boolean needRetraction,
+      @JsonProperty(FIELD_NAME_INPUT_PROPERTIES) List<InputProperty> inputProperties,
+      @JsonProperty(FIELD_NAME_OUTPUT_TYPE) RowType outputType,
+      @JsonProperty(FIELD_NAME_DESCRIPTION) String description) {
+    super(id, context, persistedConfig, inputProperties, outputType, description);
+    this.grouping = checkNotNull(grouping);
+    this.aggCalls = checkNotNull(aggCalls);
+    this.windowing = checkNotNull(windowing);
+    this.namedWindowProperties = checkNotNull(namedWindowProperties);
+    this.needRetraction = Optional.ofNullable(needRetraction).orElse(false);
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  protected Transformation<RowData> translateToPlanInternal(
+      PlannerBase planner, ExecNodeConfig config) {
+    final ExecEdge inputEdge = getInputEdges().get(0);
+    final Transformation<RowData> inputTransform =
+        (Transformation<RowData>) inputEdge.translateToPlan(planner);
+    final RowType inputRowType = (RowType) inputEdge.getOutputType();
+
+    final ZoneId shiftTimeZone =
+        TimeWindowUtil.getShiftTimeZone(
+            windowing.getTimeAttributeType(), TableConfigUtils.getLocalTimeZone(config));
+    final WindowAssigner windowAssigner = createWindowAssigner(windowing, shiftTimeZone);

Review Comment:
   shiftTimeZone is used, so keep it.



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

Posted by "shuai-xu (via GitHub)" <gi...@apache.org>.
shuai-xu merged PR #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

Posted by "ryyyyyy1 (via GitHub)" <gi...@apache.org>.
ryyyyyy1 commented on PR #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548#issuecomment-3238921048

   try to run but it seems to fail due to memory leak error:
   `E20250830 11:49:14.568943 3949495 MemoryManager.cc:264] [Velox4J MemoryManager DTOR] Memory leak found on Velox memory pool: Memory Pool[Decoding Memory Pool LEAF root[root] parent[root] MALLOC track-usage thread-safe]<unlimited max capacity capacity 128.00MB used 512B available 1023.50KB reservation [used 512B, reserved 1.00MB, min 0B] counters [allocs 4, frees 0, reserves 0, releases 0, collisions 0])>. Please make sure your code released all opened resources already.
   E20250830 11:49:14.569058 3949495 MemoryManager.cc:264] [Velox4J MemoryManager DTOR] Memory leak found on Velox memory pool: Memory Pool[root AGGREGATE root[root] parent[null] MALLOC track-usage thread-safe]<unlimited max capacity capacity 128.00MB used 512B available 0B reservation [used 0B, reserved 1.00MB, min 0B] counters [allocs 0, frees 0, reserves 0, releases 0, collisions 0])>. Please make sure your code released all opened resources already.
   E20250830 11:49:14.569092 3949495 MemoryPool.cpp:461] [MEM] Memory leak (Used memory): Memory Pool[Decoding Memory Pool LEAF root[root] parent[root] MALLOC track-usage thread-safe]<unlimited max capacity capacity 128.00MB used 512B available 1023.50KB reservation [used 512B, reserved 1.00MB, min 0B] counters [allocs 4, frees 0, reserves 0, releases 0, collisions 0])>
   E20250830 11:49:14.569126 3949495 Exceptions.h:66] Line: velox4j/src/main/cpp/main/velox4j/memory/MemoryManager.cc:92, Function:removePool, Expression: pool->reservedBytes() == 0 (1048576 vs. 0), Source: RUNTIME, ErrorCode: INVALID_STATE
   terminate called after throwing an instance of 'facebook::velox::VeloxRuntimeError'
     what():  Exception: VeloxRuntimeError
   Error Source: RUNTIME
   Error Code: INVALID_STATE
   Reason: (1048576 vs. 0)
   Retriable: False
   Expression: pool->reservedBytes() == 0
   Function: removePool
   File: velox4j/src/main/cpp/main/velox4j/memory/MemoryManager.cc
   Line: 92
   Stack trace:
    0  _ZN8facebook5velox7process10StackTraceC1Ei
    1  _ZN8facebook5velox14VeloxExceptionC1EPKcmS3_St17basic_string_viewIcSt11char_traitsIcEES7_S7_S7_bNS1_4TypeES7_
    2  _ZN8facebook5velox6detail14veloxCheckFailINS0_17VeloxRuntimeErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEvRKNS1_18VeloxCheckFailArgsET0_
    3  _ZN7velox4j12_GLOBAL__N_120ListenableArbitrator10removePoolEPN8facebook5velox6memory10MemoryPoolE
    4  _ZN8facebook5velox6memory13MemoryManager8dropPoolEPNS1_10MemoryPoolE
    5  _ZN8facebook5velox6memory14MemoryPoolImplD2Ev
    6  _ZN7velox4j13MemoryManager11tryDestructEv
    7  _ZN7velox4j13MemoryManagerD2Ev
    8  _ZNSt10_HashtableIjSt4pairIKjSt10shared_ptrIvEESaIS4_ENSt8__detail10_Select1stESt8equal_toIjESt4hashIjENS6_18_Mod_range_hashingENS6_20_Default_ranged_hashENS6_20_Prime_rehash_policyENS6_17_Hashtable_traitsILb0ELb0ELb1EEEE8_M_eraseEmPNS6_15_Hash_node_baseEPNS6_10_Hash_nodeIS4_Lb0EEE
    9  _ZN7velox4j11ResourceMapISt10shared_ptrIvEE5eraseEj
    10 _ZN7velox4j11ObjectStore15releaseInternalEj
    11 _ZN7velox4j12_GLOBAL__N_116releaseCppObjectEP7JNIEnv_P8_jobjectl
    12 0x0000ffff80769cfc
   `
   any idea to solve?


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548#issuecomment-3226654623

   https://github.com/apache/incubator-gluten/issues/10546


-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org


Re: [PR] [GLUTEN-10546][FLINK] Support all flink operators for nexmark [incubator-gluten]

Posted by "PHILO-HE (via GitHub)" <gi...@apache.org>.
PHILO-HE commented on code in PR #10548:
URL: https://github.com/apache/incubator-gluten/pull/10548#discussion_r2309322581


##########
gluten-flink/planner/src/main/java/org/apache/gluten/rexnode/WindowUtils.java:
##########
@@ -39,6 +39,7 @@ public static Tuple5<Long, Long, Long, Integer, Integer> extractWindowParameters
     int rowtimeIndex = -1;
     int windowType = -1;
     WindowSpec windowSpec = windowing.getWindow();
+    System.out.println("WindowSpec " + windowSpec);

Review Comment:
   ditto.



##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecGroupWindowAggregate.java:
##########
@@ -0,0 +1,279 @@
+/*
+ * 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.flink.table.planner.plan.nodes.exec.stream;
+
+import org.apache.gluten.rexnode.AggregateCallConverter;
+import org.apache.gluten.rexnode.Utils;
+import org.apache.gluten.table.runtime.operators.GlutenVectorOneInputOperator;
+import org.apache.gluten.util.LogicalTypeConverter;
+import org.apache.gluten.util.PlanNodeIdGenerator;
+
+import io.github.zhztheplayer.velox4j.aggregate.Aggregate;
+import io.github.zhztheplayer.velox4j.expression.FieldAccessTypedExpr;
+import io.github.zhztheplayer.velox4j.plan.GroupWindowAggregationNode;
+import io.github.zhztheplayer.velox4j.plan.GroupWindowAggsHandlerNode;
+import io.github.zhztheplayer.velox4j.plan.HashPartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PlanNode;
+import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
+import io.github.zhztheplayer.velox4j.plan.StreamWindowPartitionFunctionSpec;
+
+import org.apache.flink.FlinkVersion;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.SimpleOperatorFactory;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.plan.logical.LogicalWindow;
+import org.apache.flink.table.planner.plan.logical.SlidingGroupWindow;
+import org.apache.flink.table.planner.plan.logical.TumblingGroupWindow;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata;
+import org.apache.flink.table.planner.plan.nodes.exec.InputProperty;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil;
+import org.apache.flink.table.planner.plan.utils.KeySelectorUtil;
+import org.apache.flink.table.planner.plan.utils.WindowEmitStrategy;
+import org.apache.flink.table.planner.utils.TableConfigUtils;
+import org.apache.flink.table.runtime.groupwindow.NamedWindowProperty;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.runtime.util.TimeWindowUtil;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.apache.calcite.rel.core.AggregateCall;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.table.planner.plan.utils.AggregateUtil.hasRowIntervalType;
+import static org.apache.flink.table.planner.plan.utils.AggregateUtil.isRowtimeAttribute;
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Stream {@link ExecNode} for either group window aggregate or group window table aggregate.
+ *
+ * <p>The differences between {@link StreamExecWindowAggregate} and {@link
+ * StreamExecGroupWindowAggregate} is that, this node is translated from window TVF syntax, but the
+ * * other is from the legacy GROUP WINDOW FUNCTION syntax. In the long future, {@link
+ * StreamExecGroupWindowAggregate} will be dropped.
+ */
+@ExecNodeMetadata(
+    name = "stream-exec-group-window-aggregate",
+    version = 1,
+    consumedOptions = {
+      "table.local-time-zone",
+      "table.exec.mini-batch.enabled",
+      "table.exec.mini-batch.size"
+    },
+    producedTransformations = StreamExecGroupWindowAggregate.GROUP_WINDOW_AGGREGATE_TRANSFORMATION,
+    minPlanVersion = FlinkVersion.v1_15,
+    minStateVersion = FlinkVersion.v1_15)
+public class StreamExecGroupWindowAggregate extends StreamExecAggregateBase {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(StreamExecGroupWindowAggregate.class);
+
+  public static final String GROUP_WINDOW_AGGREGATE_TRANSFORMATION = "group-window-aggregate";
+
+  public static final String FIELD_NAME_WINDOW = "window";
+  public static final String FIELD_NAME_NAMED_WINDOW_PROPERTIES = "namedWindowProperties";
+
+  @JsonProperty(FIELD_NAME_GROUPING)
+  private final int[] grouping;
+
+  @JsonProperty(FIELD_NAME_AGG_CALLS)
+  private final AggregateCall[] aggCalls;
+
+  @JsonProperty(FIELD_NAME_WINDOW)
+  private final LogicalWindow window;
+
+  @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES)
+  private final NamedWindowProperty[] namedWindowProperties;
+
+  @JsonProperty(FIELD_NAME_NEED_RETRACTION)
+  private final boolean needRetraction;
+
+  public StreamExecGroupWindowAggregate(
+      ReadableConfig tableConfig,
+      int[] grouping,
+      AggregateCall[] aggCalls,
+      LogicalWindow window,
+      NamedWindowProperty[] namedWindowProperties,
+      boolean needRetraction,
+      InputProperty inputProperty,
+      RowType outputType,
+      String description) {
+    this(
+        ExecNodeContext.newNodeId(),
+        ExecNodeContext.newContext(StreamExecGroupWindowAggregate.class),
+        ExecNodeContext.newPersistedConfig(StreamExecGroupWindowAggregate.class, tableConfig),
+        grouping,
+        aggCalls,
+        window,
+        namedWindowProperties,
+        needRetraction,
+        Collections.singletonList(inputProperty),
+        outputType,
+        description);
+  }
+
+  @JsonCreator
+  public StreamExecGroupWindowAggregate(
+      @JsonProperty(FIELD_NAME_ID) int id,
+      @JsonProperty(FIELD_NAME_TYPE) ExecNodeContext context,
+      @JsonProperty(FIELD_NAME_CONFIGURATION) ReadableConfig persistedConfig,
+      @JsonProperty(FIELD_NAME_GROUPING) int[] grouping,
+      @JsonProperty(FIELD_NAME_AGG_CALLS) AggregateCall[] aggCalls,
+      @JsonProperty(FIELD_NAME_WINDOW) LogicalWindow window,
+      @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES) NamedWindowProperty[] namedWindowProperties,
+      @JsonProperty(FIELD_NAME_NEED_RETRACTION) boolean needRetraction,
+      @JsonProperty(FIELD_NAME_INPUT_PROPERTIES) List<InputProperty> inputProperties,
+      @JsonProperty(FIELD_NAME_OUTPUT_TYPE) RowType outputType,
+      @JsonProperty(FIELD_NAME_DESCRIPTION) String description) {
+    super(id, context, persistedConfig, inputProperties, outputType, description);
+    checkArgument(inputProperties.size() == 1);
+    this.grouping = checkNotNull(grouping);
+    this.aggCalls = checkNotNull(aggCalls);
+    this.window = checkNotNull(window);
+    this.namedWindowProperties = checkNotNull(namedWindowProperties);
+    this.needRetraction = needRetraction;
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  protected Transformation<RowData> translateToPlanInternal(
+      PlannerBase planner, ExecNodeConfig config) {
+    final boolean isCountWindow;
+    System.out.println("Window: " + window);
+    System.out.println("WindowOutput: " + getOutputType());
+    // System.out.println("WindowSpec: " + window.getWindow());

Review Comment:
   Please remove the three lines of debug code above or use `logger.debug` instead.



##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecWindowAggregate.java:
##########
@@ -0,0 +1,333 @@
+/*
+ * 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.flink.table.planner.plan.nodes.exec.stream;
+
+import org.apache.gluten.rexnode.AggregateCallConverter;
+import org.apache.gluten.rexnode.Utils;
+import org.apache.gluten.rexnode.WindowUtils;
+import org.apache.gluten.table.runtime.operators.GlutenVectorOneInputOperator;
+import org.apache.gluten.util.LogicalTypeConverter;
+import org.apache.gluten.util.PlanNodeIdGenerator;
+
+import io.github.zhztheplayer.velox4j.aggregate.Aggregate;
+import io.github.zhztheplayer.velox4j.aggregate.AggregateStep;
+import io.github.zhztheplayer.velox4j.expression.FieldAccessTypedExpr;
+import io.github.zhztheplayer.velox4j.plan.AggregationNode;
+import io.github.zhztheplayer.velox4j.plan.EmptyNode;
+import io.github.zhztheplayer.velox4j.plan.HashPartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PlanNode;
+import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
+import io.github.zhztheplayer.velox4j.plan.StreamWindowAggregationNode;
+import io.github.zhztheplayer.velox4j.plan.StreamWindowPartitionFunctionSpec;
+
+import org.apache.flink.FlinkVersion;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.api.java.tuple.Tuple5;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.SimpleOperatorFactory;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.codegen.CodeGeneratorContext;
+import org.apache.flink.table.planner.codegen.agg.AggsHandlerCodeGenerator;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.plan.logical.WindowingStrategy;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata;
+import org.apache.flink.table.planner.plan.nodes.exec.InputProperty;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil;
+import org.apache.flink.table.planner.plan.utils.AggregateInfoList;
+import org.apache.flink.table.planner.plan.utils.KeySelectorUtil;
+import org.apache.flink.table.planner.utils.JavaScalaConversionUtil;
+import org.apache.flink.table.planner.utils.TableConfigUtils;
+import org.apache.flink.table.runtime.generated.GeneratedNamespaceAggsHandleFunction;
+import org.apache.flink.table.runtime.groupwindow.NamedWindowProperty;
+import org.apache.flink.table.runtime.groupwindow.WindowProperty;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.operators.window.TimeWindow;
+import org.apache.flink.table.runtime.operators.window.tvf.common.WindowAssigner;
+import org.apache.flink.table.runtime.operators.window.tvf.slicing.SliceSharedAssigner;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.runtime.util.TimeWindowUtil;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.tools.RelBuilder;
+import org.apache.commons.math3.util.ArithmeticUtils;
+
+import javax.annotation.Nullable;
+
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.TimeZone;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Stream {@link ExecNode} for window table-valued based aggregate.
+ *
+ * <p>The differences between {@link StreamExecWindowAggregate} and {@link
+ * StreamExecGroupWindowAggregate} is that, this node is translated from window TVF syntax, but the
+ * other is from the legacy GROUP WINDOW FUNCTION syntax. In the long future, {@link
+ * StreamExecGroupWindowAggregate} will be dropped.
+ */
+@ExecNodeMetadata(
+    name = "stream-exec-window-aggregate",
+    version = 1,
+    consumedOptions = "table.local-time-zone",
+    producedTransformations = StreamExecWindowAggregate.WINDOW_AGGREGATE_TRANSFORMATION,
+    minPlanVersion = FlinkVersion.v1_15,
+    minStateVersion = FlinkVersion.v1_15)
+public class StreamExecWindowAggregate extends StreamExecWindowAggregateBase {
+
+  public static final String WINDOW_AGGREGATE_TRANSFORMATION = "window-aggregate";
+
+  private static final long WINDOW_AGG_MEMORY_RATIO = 100;
+
+  public static final String FIELD_NAME_WINDOWING = "windowing";
+  public static final String FIELD_NAME_NAMED_WINDOW_PROPERTIES = "namedWindowProperties";
+
+  @JsonProperty(FIELD_NAME_GROUPING)
+  private final int[] grouping;
+
+  @JsonProperty(FIELD_NAME_AGG_CALLS)
+  private final AggregateCall[] aggCalls;
+
+  @JsonProperty(FIELD_NAME_WINDOWING)
+  private final WindowingStrategy windowing;
+
+  @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES)
+  private final NamedWindowProperty[] namedWindowProperties;
+
+  @JsonProperty(FIELD_NAME_NEED_RETRACTION)
+  private final boolean needRetraction;
+
+  public StreamExecWindowAggregate(
+      ReadableConfig tableConfig,
+      int[] grouping,
+      AggregateCall[] aggCalls,
+      WindowingStrategy windowing,
+      NamedWindowProperty[] namedWindowProperties,
+      Boolean needRetraction,
+      InputProperty inputProperty,
+      RowType outputType,
+      String description) {
+    this(
+        ExecNodeContext.newNodeId(),
+        ExecNodeContext.newContext(StreamExecWindowAggregate.class),
+        ExecNodeContext.newPersistedConfig(StreamExecWindowAggregate.class, tableConfig),
+        grouping,
+        aggCalls,
+        windowing,
+        namedWindowProperties,
+        needRetraction,
+        Collections.singletonList(inputProperty),
+        outputType,
+        description);
+  }
+
+  @JsonCreator
+  public StreamExecWindowAggregate(
+      @JsonProperty(FIELD_NAME_ID) int id,
+      @JsonProperty(FIELD_NAME_TYPE) ExecNodeContext context,
+      @JsonProperty(FIELD_NAME_CONFIGURATION) ReadableConfig persistedConfig,
+      @JsonProperty(FIELD_NAME_GROUPING) int[] grouping,
+      @JsonProperty(FIELD_NAME_AGG_CALLS) AggregateCall[] aggCalls,
+      @JsonProperty(FIELD_NAME_WINDOWING) WindowingStrategy windowing,
+      @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES) NamedWindowProperty[] namedWindowProperties,
+      @Nullable @JsonProperty(FIELD_NAME_NEED_RETRACTION) Boolean needRetraction,
+      @JsonProperty(FIELD_NAME_INPUT_PROPERTIES) List<InputProperty> inputProperties,
+      @JsonProperty(FIELD_NAME_OUTPUT_TYPE) RowType outputType,
+      @JsonProperty(FIELD_NAME_DESCRIPTION) String description) {
+    super(id, context, persistedConfig, inputProperties, outputType, description);
+    this.grouping = checkNotNull(grouping);
+    this.aggCalls = checkNotNull(aggCalls);
+    this.windowing = checkNotNull(windowing);
+    this.namedWindowProperties = checkNotNull(namedWindowProperties);
+    this.needRetraction = Optional.ofNullable(needRetraction).orElse(false);
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  protected Transformation<RowData> translateToPlanInternal(
+      PlannerBase planner, ExecNodeConfig config) {
+    final ExecEdge inputEdge = getInputEdges().get(0);
+    final Transformation<RowData> inputTransform =
+        (Transformation<RowData>) inputEdge.translateToPlan(planner);
+    final RowType inputRowType = (RowType) inputEdge.getOutputType();
+
+    final ZoneId shiftTimeZone =
+        TimeWindowUtil.getShiftTimeZone(
+            windowing.getTimeAttributeType(), TableConfigUtils.getLocalTimeZone(config));
+    final WindowAssigner windowAssigner = createWindowAssigner(windowing, shiftTimeZone);

Review Comment:
   `shiftTimeZone` and `windowAssigner` are not used after the modification. Maybe, we can remove it.



##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecGroupWindowAggregate.java:
##########
@@ -0,0 +1,279 @@
+/*
+ * 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.flink.table.planner.plan.nodes.exec.stream;
+
+import org.apache.gluten.rexnode.AggregateCallConverter;
+import org.apache.gluten.rexnode.Utils;
+import org.apache.gluten.table.runtime.operators.GlutenVectorOneInputOperator;
+import org.apache.gluten.util.LogicalTypeConverter;
+import org.apache.gluten.util.PlanNodeIdGenerator;
+
+import io.github.zhztheplayer.velox4j.aggregate.Aggregate;
+import io.github.zhztheplayer.velox4j.expression.FieldAccessTypedExpr;
+import io.github.zhztheplayer.velox4j.plan.GroupWindowAggregationNode;
+import io.github.zhztheplayer.velox4j.plan.GroupWindowAggsHandlerNode;
+import io.github.zhztheplayer.velox4j.plan.HashPartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PartitionFunctionSpec;
+import io.github.zhztheplayer.velox4j.plan.PlanNode;
+import io.github.zhztheplayer.velox4j.plan.StatefulPlanNode;
+import io.github.zhztheplayer.velox4j.plan.StreamWindowPartitionFunctionSpec;
+
+import org.apache.flink.FlinkVersion;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.SimpleOperatorFactory;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import org.apache.flink.table.planner.plan.logical.LogicalWindow;
+import org.apache.flink.table.planner.plan.logical.SlidingGroupWindow;
+import org.apache.flink.table.planner.plan.logical.TumblingGroupWindow;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeConfig;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeContext;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeMetadata;
+import org.apache.flink.table.planner.plan.nodes.exec.InputProperty;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil;
+import org.apache.flink.table.planner.plan.utils.KeySelectorUtil;
+import org.apache.flink.table.planner.plan.utils.WindowEmitStrategy;
+import org.apache.flink.table.planner.utils.TableConfigUtils;
+import org.apache.flink.table.runtime.groupwindow.NamedWindowProperty;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.runtime.util.TimeWindowUtil;
+import org.apache.flink.table.types.logical.RowType;
+
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.apache.calcite.rel.core.AggregateCall;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.time.ZoneId;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.table.planner.plan.utils.AggregateUtil.hasRowIntervalType;
+import static org.apache.flink.table.planner.plan.utils.AggregateUtil.isRowtimeAttribute;
+import static org.apache.flink.util.Preconditions.checkArgument;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * Stream {@link ExecNode} for either group window aggregate or group window table aggregate.
+ *
+ * <p>The differences between {@link StreamExecWindowAggregate} and {@link
+ * StreamExecGroupWindowAggregate} is that, this node is translated from window TVF syntax, but the
+ * * other is from the legacy GROUP WINDOW FUNCTION syntax. In the long future, {@link
+ * StreamExecGroupWindowAggregate} will be dropped.
+ */
+@ExecNodeMetadata(
+    name = "stream-exec-group-window-aggregate",
+    version = 1,
+    consumedOptions = {
+      "table.local-time-zone",
+      "table.exec.mini-batch.enabled",
+      "table.exec.mini-batch.size"
+    },
+    producedTransformations = StreamExecGroupWindowAggregate.GROUP_WINDOW_AGGREGATE_TRANSFORMATION,
+    minPlanVersion = FlinkVersion.v1_15,
+    minStateVersion = FlinkVersion.v1_15)
+public class StreamExecGroupWindowAggregate extends StreamExecAggregateBase {
+
+  private static final Logger LOGGER =
+      LoggerFactory.getLogger(StreamExecGroupWindowAggregate.class);
+
+  public static final String GROUP_WINDOW_AGGREGATE_TRANSFORMATION = "group-window-aggregate";
+
+  public static final String FIELD_NAME_WINDOW = "window";
+  public static final String FIELD_NAME_NAMED_WINDOW_PROPERTIES = "namedWindowProperties";
+
+  @JsonProperty(FIELD_NAME_GROUPING)
+  private final int[] grouping;
+
+  @JsonProperty(FIELD_NAME_AGG_CALLS)
+  private final AggregateCall[] aggCalls;
+
+  @JsonProperty(FIELD_NAME_WINDOW)
+  private final LogicalWindow window;
+
+  @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES)
+  private final NamedWindowProperty[] namedWindowProperties;
+
+  @JsonProperty(FIELD_NAME_NEED_RETRACTION)
+  private final boolean needRetraction;
+
+  public StreamExecGroupWindowAggregate(
+      ReadableConfig tableConfig,
+      int[] grouping,
+      AggregateCall[] aggCalls,
+      LogicalWindow window,
+      NamedWindowProperty[] namedWindowProperties,
+      boolean needRetraction,
+      InputProperty inputProperty,
+      RowType outputType,
+      String description) {
+    this(
+        ExecNodeContext.newNodeId(),
+        ExecNodeContext.newContext(StreamExecGroupWindowAggregate.class),
+        ExecNodeContext.newPersistedConfig(StreamExecGroupWindowAggregate.class, tableConfig),
+        grouping,
+        aggCalls,
+        window,
+        namedWindowProperties,
+        needRetraction,
+        Collections.singletonList(inputProperty),
+        outputType,
+        description);
+  }
+
+  @JsonCreator
+  public StreamExecGroupWindowAggregate(
+      @JsonProperty(FIELD_NAME_ID) int id,
+      @JsonProperty(FIELD_NAME_TYPE) ExecNodeContext context,
+      @JsonProperty(FIELD_NAME_CONFIGURATION) ReadableConfig persistedConfig,
+      @JsonProperty(FIELD_NAME_GROUPING) int[] grouping,
+      @JsonProperty(FIELD_NAME_AGG_CALLS) AggregateCall[] aggCalls,
+      @JsonProperty(FIELD_NAME_WINDOW) LogicalWindow window,
+      @JsonProperty(FIELD_NAME_NAMED_WINDOW_PROPERTIES) NamedWindowProperty[] namedWindowProperties,
+      @JsonProperty(FIELD_NAME_NEED_RETRACTION) boolean needRetraction,
+      @JsonProperty(FIELD_NAME_INPUT_PROPERTIES) List<InputProperty> inputProperties,
+      @JsonProperty(FIELD_NAME_OUTPUT_TYPE) RowType outputType,
+      @JsonProperty(FIELD_NAME_DESCRIPTION) String description) {
+    super(id, context, persistedConfig, inputProperties, outputType, description);
+    checkArgument(inputProperties.size() == 1);
+    this.grouping = checkNotNull(grouping);
+    this.aggCalls = checkNotNull(aggCalls);
+    this.window = checkNotNull(window);
+    this.namedWindowProperties = checkNotNull(namedWindowProperties);
+    this.needRetraction = needRetraction;
+  }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  protected Transformation<RowData> translateToPlanInternal(
+      PlannerBase planner, ExecNodeConfig config) {
+    final boolean isCountWindow;
+    System.out.println("Window: " + window);
+    System.out.println("WindowOutput: " + getOutputType());
+    // System.out.println("WindowSpec: " + window.getWindow());
+    if (window instanceof TumblingGroupWindow) {
+      isCountWindow = hasRowIntervalType(((TumblingGroupWindow) window).size());
+    } else if (window instanceof SlidingGroupWindow) {
+      isCountWindow = hasRowIntervalType(((SlidingGroupWindow) window).size());
+    } else {
+      isCountWindow = false;
+    }
+
+    if (isCountWindow && grouping.length > 0 && config.getStateRetentionTime() < 0) {
+      LOGGER.warn(
+          "No state retention interval configured for a query which accumulates state. "
+              + "Please provide a query configuration with valid retention interval to prevent "
+              + "excessive state size. You may specify a retention time of 0 to not clean up the state.");
+    }
+
+    final ExecEdge inputEdge = getInputEdges().get(0);
+    final Transformation<RowData> inputTransform =
+        (Transformation<RowData>) inputEdge.translateToPlan(planner);
+    final RowType inputRowType = (RowType) inputEdge.getOutputType();
+
+    final int inputTimeFieldIndex;
+    if (isRowtimeAttribute(window.timeAttribute())) {
+      inputTimeFieldIndex = window.timeAttribute().getFieldIndex();
+      if (inputTimeFieldIndex < 0) {
+        throw new TableException(
+            "Group window must defined on a time attribute, "
+                + "but the time attribute can't be found.\n"
+                + "This should never happen. Please file an issue.");
+      }
+    } else {
+      inputTimeFieldIndex = -1;
+    }
+
+    final ZoneId shiftTimeZone =
+        TimeWindowUtil.getShiftTimeZone(
+            window.timeAttribute().getOutputDataType().getLogicalType(),
+            TableConfigUtils.getLocalTimeZone(config));

Review Comment:
   `shiftTimeZone` is not actually used. Do we still need it? If not, please remove it.



-- 
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: commits-unsubscribe@gluten.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org