You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "loserwang1024 (via GitHub)" <gi...@apache.org> on 2026/08/03 08:34:28 UTC
Re: [PR] [flink] Support projection and filter pushdown for $changelog and $binlog virtual tables [fluss]
loserwang1024 commented on code in PR #3759:
URL: https://github.com/apache/fluss/pull/3759#discussion_r3702428738
##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/deserializer/BinlogDeserializationSchema.java:
##########
@@ -46,14 +44,33 @@ public class BinlogDeserializationSchema implements FlussDeserializationSchema<R
*/
private transient BinlogRowConverter converter;
- /** Creates a new BinlogDeserializationSchema. */
- public BinlogDeserializationSchema() {}
+ /**
+ * Optional top-level projection over the binlog row {@code [_change_type, _log_offset,
+ * _commit_timestamp, before, after]}, or {@code null} for no projection.
+ */
+ @Nullable private final int[] projectedTopLevel;
+
+ /** The produced row type, already computed by the table source honoring the projection. */
+ private final org.apache.flink.table.types.logical.RowType producedRowType;
+
+ /**
+ * Creates a new BinlogDeserializationSchema.
+ *
+ * @param projectedTopLevel top-level projection over the binlog row, or {@code null} for none
+ * @param producedRowType the produced row type computed by the table source
+ */
+ public BinlogDeserializationSchema(
+ @Nullable int[] projectedTopLevel,
+ org.apache.flink.table.types.logical.RowType producedRowType) {
+ this.projectedTopLevel = projectedTopLevel;
+ this.producedRowType = producedRowType;
+ }
/** Initializes the deserialization schema. */
@Override
public void open(InitializationContext context) throws Exception {
if (converter == null) {
- this.converter = new BinlogRowConverter(context.getRowSchema());
+ this.converter = new BinlogRowConverter(context.getRowSchema(), projectedTopLevel);
Review Comment:
I agree that the explicit projection is required with the current FlinkSource contract, but I think it exposes a deeper issue: sourceOutputType is currently used for two different meanings.
For normal tables, the schema of LogRecord#getRow() and the produced source row type happen to be the same. For $changelog/$binlog they are not. The reader/scanner needs the physical row schema, while Flink's ResultTypeQueryable should describe the virtual produced row schema.
So instead of making BinlogDeserializationSchema/ChangelogDeserializationSchema own final projection arrays, I think we should split the FlinkSource contract into physical scan row type and produced row type. The deserialization context can still receive the physical LogRecord row schema, but getProducedType should use the virtual produced row type. The remaining projection from constructed virtual row to planner output can then be modeled explicitly at the virtual source layer, rather than leaking as baseRowProjection into the deserialization schema.
then,
```java
$binlog:
scanRowType = full physical data row
producedRowType = projected virtual binlog row
virtual projection = applied after constructing [_change_type, _log_offset, _commit_timestamp, before, after]
```
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org