reswqa commented on code in PR #123:
URL:
https://github.com/apache/flink-connector-pulsar/pull/123#discussion_r3526157381
##########
flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/sink/writer/PulsarWriter.java:
##########
@@ -139,7 +140,8 @@ public PulsarWriter(
}
@Override
- public void write(IN element, Context context) throws IOException,
InterruptedException {
+ public void write(IN element, SinkWriter.Context context)
Review Comment:
static import `SinkWriter.Context`.
##########
flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/table/TableDataTypeUtils.java:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.connector.pulsar.table;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.types.FieldsDataType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.LogicalTypeRoot;
+import org.apache.flink.table.types.logical.RowType;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Utility methods for working with table {@link DataType}s.
+ *
+ * <p>This class contains methods that were removed from Flink's {@code
DataTypeUtils} in Flink 2.x.
+ * They are copied here to maintain the connector's functionality.
+ */
+@Internal
+public class TableDataTypeUtils {
+
+ private TableDataTypeUtils() {}
+
+ /**
+ * Removes a prefix from all field names in a row data type.
+ *
+ * @param dataType The row data type whose field names should be stripped.
+ * @param prefix The prefix to remove from each field name.
+ * @return A new data type with the prefix removed from field names.
+ */
+ public static DataType stripRowPrefix(DataType dataType, String prefix) {
+ if (!dataType.getLogicalType().is(LogicalTypeRoot.ROW)) {
+ throw new IllegalArgumentException("Row data type expected.");
+ }
+
+ final RowType rowType = (RowType) dataType.getLogicalType();
+ final List<String> newFieldNames =
+ rowType.getFieldNames().stream()
+ .map(
+ s -> {
+ if (s.startsWith(prefix)) {
+ return s.substring(prefix.length());
+ }
+ return s;
+ })
+ .collect(Collectors.toList());
+ final LogicalType newRowType = renameRowFields(rowType, newFieldNames);
+ return new FieldsDataType(
+ newRowType, dataType.getConversionClass(),
dataType.getChildren());
+ }
+
+ /**
+ * Renames the fields in a {@link RowType}.
+ *
+ * @param rowType The row type to rename fields in.
+ * @param newFieldNames The new field names to use.
+ * @return A new row type with the renamed fields.
+ */
+ public static RowType renameRowFields(RowType rowType, List<String>
newFieldNames) {
Review Comment:
This method is still lives in
`org.apache.flink.table.types.logical.utils.LogicalTypeUtils#renameRowFields`
##########
.github/workflows/push_pr.yml:
##########
@@ -28,14 +28,14 @@ jobs:
compile_and_test:
strategy:
matrix:
- flink: [ 1.20.4 ]
- jdk: [ '8, 11, 17' ]
+ flink: [ 2.2.1 ]
Review Comment:
Could we upgrade to `2.3.0` and add `2.0.x, 2.1.x, 2.2.x, 2.3.0` to weekly
ci matrix.
And for this PR, I think It should run all the versions mentioned above
first, and change to the `2.3.0` only if the ci is green.
##########
flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/table/PulsarTableTestBase.java:
##########
@@ -58,7 +57,6 @@ public void beforeAll() throws Exception {
// run env
env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(DEFAULT_PARALLELISM);
- env.getConfig().setRestartStrategy(RestartStrategies.noRestart());
Review Comment:
```java
Configuration conf = new Configuration();
conf.set(RestartStrategyOptions.RESTART_STRATEGY,
NO_RESTART_STRATEGY.getMainValue());
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment(conf);
```
##########
flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/testutils/function/ControlSource.java:
##########
@@ -25,7 +25,7 @@
import org.apache.flink.runtime.state.FunctionInitializationContext;
import org.apache.flink.runtime.state.FunctionSnapshotContext;
import org.apache.flink.streaming.api.checkpoint.CheckpointedFunction;
-import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.apache.flink.streaming.api.functions.source.legacy.SourceFunction;
Review Comment:
legacy import shouldn't be allowed for 2.x flink connector.
##########
flink-connector-pulsar/src/test/java/org/apache/flink/connector/pulsar/table/PulsarTableITCase.java:
##########
@@ -22,7 +22,7 @@
import org.apache.flink.connector.pulsar.table.testutils.TestingUser;
import org.apache.flink.core.execution.JobClient;
import org.apache.flink.streaming.api.datastream.DataStream;
-import org.apache.flink.streaming.api.functions.sink.SinkFunction;
+import org.apache.flink.streaming.api.functions.sink.legacy.SinkFunction;
Review Comment:
legacy import shouldn't be allowed for 2.x flink connector.
##########
flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/deserializer/PulsarDeserializationSchema.java:
##########
@@ -70,7 +70,7 @@ default void open(PulsarInitializationContext context,
SourceConfiguration confi
/** An interface for providing extra schema initial context for users. */
@PublicEvolving
- public interface PulsarInitializationContext extends InitializationContext
{
+ interface PulsarInitializationContext extends InitializationContext {
Review Comment:
What's the purpose of changing this modifier?
--
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]