wuchong commented on code in PR #2167: URL: https://github.com/apache/fluss/pull/2167#discussion_r2644704177
########## fluss-flink/fluss-flink-2.2/src/main/java/org/apache/fluss/flink/adapter/FlinkSinkAdapter.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.fluss.flink.adapter; + +import org.apache.flink.api.common.operators.MailboxExecutor; +import org.apache.flink.api.connector.sink2.Sink; +import org.apache.flink.api.connector.sink2.SinkWriter; +import org.apache.flink.api.connector.sink2.WriterInitContext; +import org.apache.flink.metrics.groups.SinkWriterMetricGroup; + +import java.io.IOException; + +/** + * Flink sink adapter which hide the different version of createWriter method. + * + * <p>TODO: remove this class when no longer support all the Flink 1.x series. + */ +public abstract class FlinkSinkAdapter<InputT> implements Sink<InputT> { Review Comment: Rename to `SinkAdapter` to avoid naming confusion with `FlinkSink`. ########## fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/source/Flink22TableSourceBatchITCase.java: ########## @@ -0,0 +1,78 @@ +/* + * 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.fluss.flink.source; + +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.util.Collections; +import java.util.List; + +import static org.apache.fluss.flink.source.testutils.FlinkRowAssertionsUtils.collectRowsWithTimeout; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** IT case for batch source in Flink 2.2. */ +public class Flink22TableSourceBatchITCase extends FlinkTableSourceBatchITCase { + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + @Override + void testCountPushDown(boolean partitionTable) throws Exception { + String tableName = partitionTable ? preparePartitionedLogTable() : prepareLogTable(); + int expectedRows = partitionTable ? 10 : 5; + // normal scan + String query = String.format("SELECT COUNT(*) FROM %s", tableName); + assertThat(tEnv.explainSql(query)) + .contains( + String.format( + "TableSourceScan(table=[[testcatalog, defaultdb, %s, " + + "aggregates=[grouping=[], aggFunctions=[Count1AggFunction()]]]], " + + "fields=[count1$0])", + tableName)); Review Comment: Let’s avoid overriding the entire test method if possible. Full overrides can create maintenance friction. For example, if the base method is updated but the override isn’t synchronized accordingly. As I understand it, this override was only introduced for Flink 2.2 to accommodate the removal of the `project=[id]` field from the plan string. Instead, we can maintain compatibility by extract the `TableSourceScan(` line from the plan and asserting this line contains: `aggregates=[grouping=[], aggFunctions=[Count1AggFunction()]], fields=[count1$0]` to verify that the `COUNT` aggregation has been correctly pushed down. ########## fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalog22Test.java: ########## @@ -17,35 +17,22 @@ package org.apache.fluss.flink.catalog; -import org.apache.fluss.flink.lake.LakeFlinkCatalog; - import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.Schema; +import org.apache.flink.table.catalog.CatalogMaterializedTable; import org.apache.flink.table.catalog.Column; import org.apache.flink.table.catalog.DefaultIndex; +import org.apache.flink.table.catalog.IntervalFreshness; +import org.apache.flink.table.catalog.ResolvedCatalogMaterializedTable; import org.apache.flink.table.catalog.ResolvedSchema; import org.apache.flink.table.catalog.UniqueConstraint; import java.util.Arrays; import java.util.Collections; +import java.util.Map; -/** Test for {@link Flink21Catalog}. */ -public class FlinkCatalog21Test extends FlinkCatalogTest { - - @Override - protected FlinkCatalog initCatalog( - String catalogName, - String databaseName, - String bootstrapServers, - LakeFlinkCatalog lakeFlinkCatalog) { - return new Flink21Catalog( - catalogName, - databaseName, - bootstrapServers, - Thread.currentThread().getContextClassLoader(), - Collections.emptyMap(), - Collections::emptyMap, - lakeFlinkCatalog); - } +/** Test for {@link FlinkCatalog}. */ +public class FlinkCatalog22Test extends FlinkCatalogTest { Review Comment: Rename to `Flink22CatalogTest` to comply with other multi-version names. ########## fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalog22Test.java: ########## @@ -59,4 +46,30 @@ protected ResolvedSchema createSchema() { DefaultIndex.newIndex( "INDEX_first_third", Arrays.asList("first", "third")))); } + + protected CatalogMaterializedTable newCatalogMaterializedTable( + ResolvedSchema resolvedSchema, + CatalogMaterializedTable.RefreshMode refreshMode, + Map<String, String> options) { + CatalogMaterializedTable origin = + CatalogMaterializedTable.newBuilder() + .schema(Schema.newBuilder().fromResolvedSchema(resolvedSchema).build()) + .comment("test comment") + .options(options) + .partitionKeys(Collections.emptyList()) + .definitionQuery("select first, second, third from t") + .freshness(IntervalFreshness.of("5", IntervalFreshness.TimeUnit.SECOND)) + .logicalRefreshMode( + refreshMode == CatalogMaterializedTable.RefreshMode.CONTINUOUS + ? CatalogMaterializedTable.LogicalRefreshMode.CONTINUOUS + : CatalogMaterializedTable.LogicalRefreshMode.FULL) + .refreshMode(refreshMode) + .refreshStatus(CatalogMaterializedTable.RefreshStatus.INITIALIZING) + .build(); + return new ResolvedCatalogMaterializedTable( + origin, + resolvedSchema, + refreshMode, + IntervalFreshness.of("5", IntervalFreshness.TimeUnit.SECOND)); Review Comment: no override method, use adapter for compatibility. ########## fluss-test-coverage/pom.xml: ########## @@ -68,12 +68,6 @@ <scope>compile</scope> </dependency> - <dependency> - <groupId>org.apache.fluss</groupId> - <artifactId>fluss-flink-2.1</artifactId> - <version>${project.version}</version> - <scope>compile</scope> - </dependency> Review Comment: Should update to flink 2.2 to include the coverage. ########## fluss-flink/fluss-flink-2.2/src/test/java/org/apache/fluss/flink/source/Flink22TableSourceITCase.java: ########## @@ -0,0 +1,311 @@ +/* + * 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.fluss.flink.source; + +import org.apache.fluss.metadata.TablePath; +import org.apache.fluss.row.InternalRow; + +import org.apache.flink.table.api.config.ExecutionConfigOptions; +import org.apache.flink.table.api.config.OptimizerConfigOptions; +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; + +import static org.apache.fluss.flink.source.testutils.FlinkRowAssertionsUtils.assertResultsIgnoreOrder; +import static org.apache.fluss.flink.utils.FlinkTestBase.writeRows; +import static org.apache.fluss.testutils.DataTestUtils.row; +import static org.assertj.core.api.Assertions.assertThat; + +/** IT case for {@link FlinkTableSource} in Flink 2.2. */ +public class Flink22TableSourceITCase extends FlinkTableSourceITCase { Review Comment: It seems this missed to copy the `testDeltaJoinWithProjectionAndFilter` and `testDeltaJoinWithLookupCache` from `Flink21TableSourceITCase`. -- 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]
