luoyuxia commented on code in PR #21676: URL: https://github.com/apache/flink/pull/21676#discussion_r1071864297
########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/batch/sql/DeleteTableITCase.java: ########## @@ -0,0 +1,89 @@ +/* + * 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.table.planner.runtime.batch.sql; + +import org.apache.flink.table.data.GenericRowData; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.data.StringData; +import org.apache.flink.table.planner.factories.TestUpdateDeleteTableFactory; +import org.apache.flink.table.planner.runtime.utils.BatchTestBase; +import org.apache.flink.types.Row; +import org.apache.flink.util.CollectionUtil; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** The IT case for DELETE statement in batch mode. */ +public class DeleteTableITCase extends BatchTestBase { + private static final int ROW_NUM = 5; + + @Test + public void testDeletePushDown() throws Exception { + String dataId = registerData(); + tEnv().executeSql( + String.format( + "CREATE TABLE t (a int, b string, c double) WITH" + + " ('connector' = 'test-update-delete'," + + " 'data-id' = '%s'," + + " 'only-accept-empty-filter' = 'true'" + + ")", + dataId)); + List<Row> rows = + CollectionUtil.iteratorToList(tEnv().executeSql("DELETE FROM t").collect()); + assertThat(rows.toString()).isEqualTo(String.format("[+I[%d], +I[OK]]", ROW_NUM)); + rows = CollectionUtil.iteratorToList(tEnv().executeSql("SELECT * FROM t").collect()); + assertThat(rows).isEmpty(); + + // should throw exception for non-empty filter + assertThatThrownBy(() -> tEnv().executeSql("DELETE FROM t where a = 1")) Review Comment: Yes, we can. But I think there's no need for in here I'm intended to test the case that although the table support delete pushdown, but it can't accept the filter, it should throw exception if it haven't implemented `SupportsRowLevelDelete` interface. -- 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]
