Copilot commented on code in PR #4503:
URL: https://github.com/apache/flink-cdc/pull/4503#discussion_r3764566276
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/TransformFilterProcessor.java:
##########
@@ -229,7 +236,8 @@ private TransformExpressionKey
generateTransformExpressionKey(
columns,
udfDescriptors,
supportedMetadataColumns,
- transformFilter.getColumnNameMap());
+ transformFilter.getColumnNameMap(),
+ decimalPrecisionMode);
Review Comment:
`TransformParser.translateFilterExpressionToJaninoExpression(...)` expects a
`SupportedMetadataColumn[]`, but this call passes `supportedMetadataColumns`
which (in this class) is a `Map<String, SupportedMetadataColumn>`. This is a
compile-time type mismatch (or will become one if generics are enforced).
Consider either storing the original `SupportedMetadataColumn[]` alongside the
map, or converting the map values back to an array when calling the parser.
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/FlinkCdcTypeSystem.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.cdc.runtime.parser;
+
+import org.apache.flink.cdc.common.pipeline.DecimalPrecisionMode;
+
+import org.apache.calcite.rel.type.RelDataTypeSystemImpl;
+
+/** A customized version of {@link
org.apache.calcite.rel.type.RelDataTypeSystem}. */
+public class FlinkCdcTypeSystem extends RelDataTypeSystemImpl {
+
+ public static final FlinkCdcTypeSystem UP_TO_38 = new
FlinkCdcTypeSystem(38);
+ public static final FlinkCdcTypeSystem UP_TO_19 = new
FlinkCdcTypeSystem(19);
+
+ private final int maxPrecision;
+
+ private FlinkCdcTypeSystem(int maxPrecision) {
+ this.maxPrecision = maxPrecision;
+ }
+
+ public static FlinkCdcTypeSystem of(DecimalPrecisionMode mode) {
+ switch (mode) {
+ case UP_TO_38:
+ return UP_TO_38;
+ case UP_TO_19:
+ return UP_TO_19;
+ default:
+ throw new IllegalArgumentException("Unexpected decimal
precision mode: " + mode);
+ }
+ }
Review Comment:
If `mode` is ever `null`, the `switch` will throw a `NullPointerException`
before reaching the `default` branch, yielding a less actionable error. A small
improvement is to validate `mode` explicitly at the top (and throw an
`IllegalArgumentException` with a clear message) so failures are easier to
diagnose.
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/TransformParser.java:
##########
@@ -575,6 +606,22 @@ public static String
translateFilterExpressionToJaninoExpression(
List<UserDefinedFunctionDescriptor> udfDescriptors,
SupportedMetadataColumn[] supportedMetadataColumns,
Map<String, String> columnNameMap) {
+ return translateFilterExpressionToJaninoExpression(
+ filterExpression,
+ columns,
+ udfDescriptors,
+ supportedMetadataColumns,
+ columnNameMap,
+ DecimalPrecisionMode.UP_TO_19);
+ }
+
+ public static String translateFilterExpressionToJaninoExpression(
+ String filterExpression,
+ List<Column> columns,
+ List<UserDefinedFunctionDescriptor> udfDescriptors,
+ SupportedMetadataColumn[] supportedMetadataColumns,
+ Map<String, String> columnNameMap,
+ DecimalPrecisionMode decimalPrecisionMode) {
if (isNullOrWhitespaceOnly(filterExpression)) {
return "";
}
Review Comment:
This overload introduces new behavior (filter translation/type deduction
depends on `decimalPrecisionMode`), but the added unit test coverage in
`TransformParserTest` only asserts projection type inference. Consider adding a
focused unit test for `translateFilterExpressionToJaninoExpression(...,
UP_TO_38)` (or the underlying type-deduction path used by filters) to ensure
DECIMAL precision > 19 is preserved in filter evaluation as well.
--
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]