You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "beryllw (via GitHub)" <gi...@apache.org> on 2025/08/05 12:49:29 UTC

[PR] Introduce Union read base interfaces [fluss]

beryllw opened a new pull request, #1480:
URL: https://github.com/apache/fluss/pull/1480

   <!--
   *Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GitHub issue](https://github.com/alibaba/fluss/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
   
     - Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink]). Skip *[component]* if you are unsure about which is the best component.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
   
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
   
   
   **(The sections below can be removed for hotfixes or typos)**
   -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Linked issue: close #1431 
   
   <!-- What is the purpose of the change -->
   
   ### Brief change log
   
   <!-- Please describe the changes made in this pull request and explain how they address the issue -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Union read base interfaces [fluss]

Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on code in PR #1480:
URL: https://github.com/apache/fluss/pull/1480#discussion_r2257012751


##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/SortedRecordReader.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import com.alibaba.fluss.row.InternalRow;
+
+import java.util.Comparator;
+
+/**
+ * A specialized {@link RecordReader} that produces records in a defined sorted order.
+ *
+ * <p>Extends the basic record reading capability with sorting semantics, ensuring that records are
+ * returned according to a specified ordering.
+ *
+ * <p>Implementations must guarantee that the {@link #read()} method returns records in the order
+ * defined by the comparator from {@link #order()}.
+ *
+ * <p>Note: This is mainly used for union read primary key table since we will do sort merge records
+ * in lake and fluss. The records in primary key table for lake may should implement this method for
+ * union read with a better performance.
+ */
+public interface SortedRecordReader extends RecordReader {

Review Comment:
   nit:
   add @since and @PublicEvolving



##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/RecordReader.java:
##########
@@ -0,0 +1,37 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import com.alibaba.fluss.record.LogRecord;
+import com.alibaba.fluss.utils.CloseableIterator;
+
+import java.io.IOException;
+
+/**
+ * An interface for reading records from {@link LakeSplit}.
+ *
+ * <p>Implementations of this interface provide an iterator-style access to records, allowing
+ * efficient sequential reading of potentially large datasets without loading all data into memory
+ * at once. The reading should consider the pushed-down optimizations (project, filters, limits,
+ * etc.) from {@link LakeSource}.
+ */
+public interface RecordReader {

Review Comment:
   add `@since` and `@PublicEvolving`



##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/LakeSource.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import com.alibaba.fluss.lake.serializer.SimpleVersionedSerializer;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A generic interface for lake data sources that defines how to plan splits and read data. Any data
+ * lake format supporting reading from data tiered in lake as Fluss records should implement this
+ * interface.
+ *
+ * <p>This interface provides methods for projection, filtering, limiting to enable query engine to
+ * push to lake source. Implementations must ensure that split planning and record reading
+ * operations properly account for these pushed-down operations during execution.
+ *
+ * @param <Split> The type of data split, which must extend {@link LakeSplit}
+ * @since 0.8
+ */
+public interface LakeSource<Split extends LakeSplit> extends Serializable {
+
+    /**
+     * Applies column projection to the data source. it provides the field index paths that should
+     * be used for a projection. The indices are 0-based and support fields within (possibly nested)
+     * structures.
+     *
+     * <p>For nested, given the following SQL, CREATE TABLE t (i INT, r ROW < d DOUBLE, b BOOLEAN>,
+     * s STRING); SELECT s, r.d FROM t; the project will be [[2], [1, 0]]
+     */
+    void withProject(int[][] project);
+
+    /** Applies a row limit to the data source. */
+    void withLimit(int limit);
+
+    // TODO: Support paimon filter pushdown
+    // FilterPushDownResult withFilters(List<Predicate> predicates);
+
+    /**
+     * Creates a planner for plan splits to be read.
+     *
+     * @param context The planning context providing necessary planning information
+     * @return A planner instance for this data source
+     * @throws IOException if an error occurs during planner creation
+     */
+    Planner<Split> createPlanner(PlannerContext context) throws IOException;
+
+    /**
+     * Creates a record reader for reading data of data lake for the specified split .

Review Comment:
   nit
   ```suggestion
        * Creates a record reader for reading data of data lake for the specified split.
   ```



##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/Planner.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * A planner interface for generating readable splits for lake data sources.
+ *
+ * <p>Implementations of this interface are responsible for determining how to divide the data into
+ * manageable splits that can be read in parallel. The planning should consider the pushed-down
+ * optimizations (filters, limits, etc.) from {@link LakeSource}.
+ *
+ * @param <Split> the type of data split this planner generates, must extend {@link LakeSplit}
+ */
+public interface Planner<Split extends LakeSplit> {

Review Comment:
   nit:
   add `@since` and `@PublicEvolving`



##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/LakeSource.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import com.alibaba.fluss.lake.serializer.SimpleVersionedSerializer;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A generic interface for lake data sources that defines how to plan splits and read data. Any data
+ * lake format supporting reading from data tiered in lake as Fluss records should implement this
+ * interface.
+ *
+ * <p>This interface provides methods for projection, filtering, limiting to enable query engine to
+ * push to lake source. Implementations must ensure that split planning and record reading
+ * operations properly account for these pushed-down operations during execution.
+ *
+ * @param <Split> The type of data split, which must extend {@link LakeSplit}
+ * @since 0.8
+ */

Review Comment:
   nit: add `@PublicEvolving`



##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/LakeSource.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import com.alibaba.fluss.lake.serializer.SimpleVersionedSerializer;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A generic interface for lake data sources that defines how to plan splits and read data. Any data
+ * lake format supporting reading from data tiered in lake as Fluss records should implement this
+ * interface.
+ *
+ * <p>This interface provides methods for projection, filtering, limiting to enable query engine to
+ * push to lake source. Implementations must ensure that split planning and record reading
+ * operations properly account for these pushed-down operations during execution.
+ *
+ * @param <Split> The type of data split, which must extend {@link LakeSplit}
+ * @since 0.8
+ */
+public interface LakeSource<Split extends LakeSplit> extends Serializable {
+
+    /**
+     * Applies column projection to the data source. it provides the field index paths that should
+     * be used for a projection. The indices are 0-based and support fields within (possibly nested)
+     * structures.
+     *
+     * <p>For nested, given the following SQL, CREATE TABLE t (i INT, r ROW < d DOUBLE, b BOOLEAN>,
+     * s STRING); SELECT s, r.d FROM t; the project will be [[2], [1, 0]]
+     */
+    void withProject(int[][] project);
+
+    /** Applies a row limit to the data source. */
+    void withLimit(int limit);
+
+    // TODO: Support paimon filter pushdown

Review Comment:
   FYI: #515 is ready to introduce the Predicate



##########
fluss-common/src/main/java/com/alibaba/fluss/lake/source/LakeSplit.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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 com.alibaba.fluss.lake.source;
+
+import java.util.List;
+
+/** Represents a logical partition or segment of data in data-lake. */

Review Comment:
   add `@since` and `@PublicEvolving`



-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Union read base interfaces [fluss]

Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia merged PR #1480:
URL: https://github.com/apache/fluss/pull/1480


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Union read base interfaces [fluss]

Posted by "beryllw (via GitHub)" <gi...@apache.org>.
beryllw commented on PR #1480:
URL: https://github.com/apache/fluss/pull/1480#issuecomment-3155111934

   Changes built upon luoyuxia's [POC code](https://github.com/luoyuxia/fluss/tree/union-read-abstract). A special thanks to @luoyuxia  for laying the code foundation.
   
   This PR isn't ready for review yet – more unit tests are still being added.


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Union read base interfaces [fluss]

Posted by "beryllw (via GitHub)" <gi...@apache.org>.
beryllw commented on PR #1480:
URL: https://github.com/apache/fluss/pull/1480#issuecomment-3157229769

   @luoyuxia @caozhen1937 Please help review the code. Thanks a lot.


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Introduce Union read base interfaces [fluss]

Posted by "luoyuxia (via GitHub)" <gi...@apache.org>.
luoyuxia commented on PR #1480:
URL: https://github.com/apache/fluss/pull/1480#issuecomment-3162868262

   @beryllw The ci failed
   `Warning:  Rule violated for class com.alibaba.fluss.lake.source.LakeSource.FilterPushDownResult: lines covered ratio is 0.00, but expected minimum is 0.70`
   You can ignore them in `fluss-test-coverage` module


-- 
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: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org