ggjh-159 commented on code in PR #13735:
URL: https://github.com/apache/gluten/pull/13735#discussion_r4703853401
##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecDeduplicate.java:
##########
@@ -169,60 +168,67 @@ protected Transformation<RowData> translateToPlanInternal(
final RowType inputRowType = (RowType) inputEdge.getOutputType();
final InternalTypeInfo<RowData> rowTypeInfo =
(InternalTypeInfo<RowData>) inputTransform.getOutputType();
- final TypeSerializer<RowData> rowSerializer =
-
rowTypeInfo.createSerializer(planner.getExecEnv().getConfig().getSerializerConfig());
final OneInputStreamOperator operator;
long stateRetentionTime =
StateMetadata.getStateTtlForOneInputOperator(config,
stateMetadataList);
// --- Begin Gluten-specific code changes ---
+ // Gluten executes deduplicate per record and does not implement mini-batch
+ // compaction. Mini-batch without compaction keeps the same downstream
changes as the
+ // non-batched path, so it is accepted. The combination with
compact-changes changes
+ // the changelog (only the latest change per key per batch is emitted),
which we do not
+ // implement, so reject it instead of silently producing a different
changelog.
+ checkArgument(
Review Comment:
Mini-batch without compact-changes is accepted here. The comment says it
produces the same changelog as the non-batched path. That is wrong for
proc-time keep-last. In Flink, the mini-batch proc-time keep-last function
keeps only the last row of each key in a bundle
(ProcTimeMiniBatchDeduplicateKeepLastRowFunction.addInput replaces the buffered
row with every input). It emits at most one change per key per bundle. This
translation emits every INSERT / UPDATE_BEFORE / UPDATE_AFTER. So with
table.exec.mini-batch.enabled the gluten changelog differs from Flink's. Please
reject mini-batch for proc-time keep-last with the same fail-loud message, or
implement the bundle semantics, and correct the comment.
##########
gluten-flink/runtime/src/main/java/org/apache/gluten/table/runtime/operators/GlutenOneInputOperator.java:
##########
@@ -69,6 +75,8 @@ public class GlutenOneInputOperator<IN, OUT> extends
TableStreamOperator<OUT>
private final Class<OUT> outClass;
private transient VectorInputBridge<IN> inputBridge;
private transient VectorOutputBridge<OUT> outputBridge;
+ private transient ListState<byte[]> checkpointState;
Review Comment:
Please revert the GlutenOneInputOperator changes. This PR turns the shared
base class of every native stateful one-input operator into an operator-state
checkpoint carrier: a ListState<byte[]> written on snapshot, restored in
initializeState, plus the key-group range parameters. The carrier is the wrong
home for keyed state (see the first item), and the base class change spreads it
to the group aggregation, rank and window operators that this PR does not
touch. With the keyed-state design the base class needs none of this plumbing.
Please restore the previous base class and keep this PR to the deduplicate
translation.
##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecDeduplicate.java:
##########
@@ -169,60 +168,67 @@ protected Transformation<RowData> translateToPlanInternal(
final RowType inputRowType = (RowType) inputEdge.getOutputType();
final InternalTypeInfo<RowData> rowTypeInfo =
(InternalTypeInfo<RowData>) inputTransform.getOutputType();
- final TypeSerializer<RowData> rowSerializer =
-
rowTypeInfo.createSerializer(planner.getExecEnv().getConfig().getSerializerConfig());
final OneInputStreamOperator operator;
long stateRetentionTime =
StateMetadata.getStateTtlForOneInputOperator(config,
stateMetadataList);
// --- Begin Gluten-specific code changes ---
+ // Gluten executes deduplicate per record and does not implement mini-batch
+ // compaction. Mini-batch without compaction keeps the same downstream
changes as the
+ // non-batched path, so it is accepted. The combination with
compact-changes changes
+ // the changelog (only the latest change per key per batch is emitted),
which we do not
+ // implement, so reject it instead of silently producing a different
changelog.
+ checkArgument(
+ !(config.get(TABLE_EXEC_MINIBATCH_ENABLED)
+ &&
config.get(TABLE_EXEC_DEDUPLICATE_MINIBATCH_COMPACT_CHANGES_ENABLED)),
+ "Gluten deduplicate does not support mini-batch with compact-changes
enabled. "
+ + "Disable
table.exec.deduplicate.mini-batch.compact-changes-enabled.");
io.github.zhztheplayer.velox4j.type.RowType inputType =
(io.github.zhztheplayer.velox4j.type.RowType)
LogicalTypeConverter.toVLType(inputRowType);
io.github.zhztheplayer.velox4j.type.RowType outputType =
(io.github.zhztheplayer.velox4j.type.RowType)
LogicalTypeConverter.toVLType(getOutputType());
+ boolean generateInsert =
+
config.get(TABLE_EXEC_DEDUPLICATE_INSERT_UPDATE_AFTER_SENSITIVE_ENABLED);
+ int rowtimeIndex = -1;
Review Comment:
For proc-time deduplicate the operator input is the input row type as is, so
the PROCTIME() column arrives as the unix_timestamp() seconds value, while in
Flink the proctime indicator field inside the row is null (ExprCodeGenerator
generates a null literal for PROCTIME and materializes the timestamp only when
an expression needs it). The keep-last same-value suppression therefore
compares a column Flink never compares: two rows with equal user columns that
arrive in different seconds emit UPDATE_BEFORE / UPDATE_AFTER here and nothing
in Flink (the same-value test passes only because the bounded source emits
every row within one second). Please feed the deduplicate operator a null
proctime column the way Flink does (project the PROCTIME() column as null for
the dedup input) or have the operator skip that column, and make the same-value
test cover rows with different proctime values.
##########
gluten-flink/planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecDeduplicate.java:
##########
@@ -169,60 +168,67 @@ protected Transformation<RowData> translateToPlanInternal(
final RowType inputRowType = (RowType) inputEdge.getOutputType();
final InternalTypeInfo<RowData> rowTypeInfo =
(InternalTypeInfo<RowData>) inputTransform.getOutputType();
- final TypeSerializer<RowData> rowSerializer =
-
rowTypeInfo.createSerializer(planner.getExecEnv().getConfig().getSerializerConfig());
final OneInputStreamOperator operator;
long stateRetentionTime =
StateMetadata.getStateTtlForOneInputOperator(config,
stateMetadataList);
// --- Begin Gluten-specific code changes ---
+ // Gluten executes deduplicate per record and does not implement mini-batch
+ // compaction. Mini-batch without compaction keeps the same downstream
changes as the
+ // non-batched path, so it is accepted. The combination with
compact-changes changes
+ // the changelog (only the latest change per key per batch is emitted),
which we do not
+ // implement, so reject it instead of silently producing a different
changelog.
+ checkArgument(
+ !(config.get(TABLE_EXEC_MINIBATCH_ENABLED)
+ &&
config.get(TABLE_EXEC_DEDUPLICATE_MINIBATCH_COMPACT_CHANGES_ENABLED)),
+ "Gluten deduplicate does not support mini-batch with compact-changes
enabled. "
+ + "Disable
table.exec.deduplicate.mini-batch.compact-changes-enabled.");
io.github.zhztheplayer.velox4j.type.RowType inputType =
(io.github.zhztheplayer.velox4j.type.RowType)
LogicalTypeConverter.toVLType(inputRowType);
io.github.zhztheplayer.velox4j.type.RowType outputType =
(io.github.zhztheplayer.velox4j.type.RowType)
LogicalTypeConverter.toVLType(getOutputType());
+ boolean generateInsert =
+
config.get(TABLE_EXEC_DEDUPLICATE_INSERT_UPDATE_AFTER_SENSITIVE_ENABLED);
+ int rowtimeIndex = -1;
if (isRowtime) {
- int rowtimeIndex = -1;
for (int i = 0; i < inputRowType.getFieldCount(); ++i) {
if (TypeCheckUtils.isRowTime(inputRowType.getTypeAt(i))) {
rowtimeIndex = i;
break;
}
}
- boolean generateInsert =
-
config.get(TABLE_EXEC_DEDUPLICATE_INSERT_UPDATE_AFTER_SENSITIVE_ENABLED);
- PlanNode deduplicateNode =
- new DeduplicateNode(
- PlanNodeIdGenerator.newId(),
- List.of(new EmptyNode(inputType)), // sources
- outputType,
- stateRetentionTime,
- rowtimeIndex,
- generateUpdateBefore,
- generateInsert,
- keepLastRow);
- List<Integer> keyIndexes =
Arrays.stream(uniqueKeys).boxed().collect(Collectors.toList());
- PartitionFunctionSpec keySelectorSpec = new
HashPartitionFunctionSpec(inputType, keyIndexes);
- final PlanNode streamRankNode =
- new StreamRankNode(
- PlanNodeIdGenerator.newId(),
- List.of(new EmptyNode(inputType)), // sources
- keySelectorSpec,
- deduplicateNode,
- outputType);
- operator =
- new GlutenOneInputOperator(
- new StatefulPlanNode(streamRankNode.getId(), streamRankNode),
- PlanNodeIdGenerator.newId(),
- inputType,
- Map.of(streamRankNode.getId(), outputType),
- RowData.class,
- RowData.class,
- "StreamExecDeduplicate");
- } else {
- throw new RuntimeException("ProcTime in deduplicate is not supported.");
+ checkArgument(rowtimeIndex >= 0, "Rowtime column is not found for
deduplicate");
}
+ List<Integer> keyIndexes =
Arrays.stream(uniqueKeys).boxed().collect(Collectors.toList());
Review Comment:
When uniqueKeys is empty (global deduplicate), the translation emits a
HashPartitionFunctionSpec with no key channels, and the operator serves it with
a synthetic constant key. Please reject the global shape at translation with
VELOX_UNSUPPORTED until the backend's global-state contract (a KeyedStateSpec
with no key channels, as Flink keys global deduplicate by the empty row) lands.
--
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]