danny0405 commented on code in PR #8102:
URL: https://github.com/apache/hudi/pull/8102#discussion_r1144213813
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/ExpressionUtils.java:
##########
@@ -177,4 +183,119 @@ public static Object
getValueFromLiteral(ValueLiteralExpression expr) {
throw new UnsupportedOperationException("Unsupported type: " +
logicalType);
}
}
+
+ public static List<ResolvedExpression>
filterSimpleCallExpression(List<ResolvedExpression> exprs) {
+ return exprs.stream()
+ .filter(ExpressionUtils::isSimpleCallExpression)
+ .collect(Collectors.toList());
+ }
+
+ public static Tuple2<List<ResolvedExpression>, List<ResolvedExpression>>
extractPartitionPredicateList(
Review Comment:
Give some documents to this method
##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/table/ITTestHoodieContinuousPartitionSource.java:
##########
@@ -0,0 +1,262 @@
+/*
+ * 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.hudi.table;
+
+import org.apache.hudi.common.model.HoodieTableType;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.utils.FlinkMiniCluster;
+import org.apache.hudi.utils.TestConfigurations;
+import org.apache.hudi.utils.TestData;
+import org.apache.hudi.utils.factory.CollectSinkTableFactory;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.execution.JobClient;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.TableResult;
+import org.apache.flink.table.api.config.ExecutionConfigOptions;
+import org.apache.flink.table.api.internal.TableEnvironmentImpl;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.types.Row;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.apache.hudi.utils.TestConfigurations.sql;
+import static org.apache.hudi.utils.TestData.assertRowsEquals;
+import static org.apache.hudi.utils.TestData.insertRow;
+
+/**
+ * IT cases for Hoodie table source and sink.
+ */
+@ExtendWith(FlinkMiniCluster.class)
+public class ITTestHoodieContinuousPartitionSource {
+
+ private static List<RowData> DATA_SET_NEW_PARTITIONS = Arrays.asList(
+ insertRow(StringData.fromString("id9"), StringData.fromString("LiLi"),
24,
+ TimestampData.fromEpochMillis(9), StringData.fromString("par5")),
+ insertRow(StringData.fromString("id10"),
StringData.fromString("Guoguo"), 34,
Review Comment:
Can we write a SQL test in `ITTestHoodieDataSource` instead of adding this
class?
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/prune/StaticPartitionPruner.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.hudi.source.prune;
+
+import java.util.Collection;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Static partition pruner for hoodie table source which partitions list is
available in compile phase.
+ * After applied this partition pruner, hoodie source could not read the data
from other partitions during runtime.
+ * Note: the data of new partitions created after the job starts would never
be read.
+ */
+public class StaticPartitionPruner implements PartitionPruner {
+
+ private static final long serialVersionUID = 1L;
Review Comment:
Can we merge the PartitionPruner into one, it can cache a list of candidate
partitions which have higher priority always.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/HoodieContinuousPartitionTableSource.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.hudi.table;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.exception.HoodieValidationException;
+import org.apache.hudi.source.ExpressionEvaluators;
+import org.apache.hudi.source.FileIndex;
+import org.apache.hudi.source.prune.DynamicPartitionPruner;
+import org.apache.hudi.source.prune.PartitionPruner;
+import org.apache.hudi.table.format.InternalSchemaManager;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.catalog.Column;
+import org.apache.flink.table.catalog.ResolvedSchema;
+import org.apache.flink.table.connector.source.DynamicTableSource;
+import
org.apache.flink.table.connector.source.abilities.SupportsFilterPushDown;
+import org.apache.flink.table.expressions.ResolvedExpression;
+import org.apache.flink.table.types.DataType;
+import org.apache.hadoop.fs.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringJoiner;
+import java.util.stream.Collectors;
+
+import static
org.apache.hudi.util.ExpressionUtils.extractPartitionPredicateList;
+import static org.apache.hudi.util.ExpressionUtils.filterSimpleCallExpression;
+
+/**
+ * Hoodie stream table source which performs partition prune based on the
filter conditions in the
+ * runtime. Unlike {@link HoodieTableSource}, the satisfied partitions are
determine in the
+ * optimization phase and never change in the runtime.
+ *
+ */
+public class HoodieContinuousPartitionTableSource
+ extends AbstractHoodieTableSource {
+ private static final Logger LOG =
LoggerFactory.getLogger(HoodieTableSource.class);
+
+ private List<ResolvedExpression> partitionFilters;
Review Comment:
There is no need to bring in another kind of `HoodieTableSource`, try to add
changes to the existing `HoodieTableSource`
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/source/prune/DataPruner.java:
##########
@@ -7,17 +7,19 @@
* "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
+ * 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.
Review Comment:
why this change?
--
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]