andygrove commented on code in PR #119:
URL: https://github.com/apache/datafusion-java/pull/119#discussion_r4654206416


##########
core/src/main/java/org/apache/datafusion/TableProvider.java:
##########
@@ -54,6 +67,35 @@ public interface TableProvider {
    * equal {@link #schema()}. The reader's buffers MUST be allocated from 
{@code allocator} (or from
    * a child of it) — the framework needs the reader's allocator hierarchy to 
share a root with the
    * one it passes here. The allocator contract mirrors the one on {@link 
ScalarFunction#evaluate}.
+   *
+   * <p>Providers that implement only {@link #scanWithArgs(ScanArgs)} may 
leave this method
+   * unsupported.
+   */
+  default ArrowReader scan(BufferAllocator allocator) {

Review Comment:
   Making `scan` a default that throws means a provider that forgets to 
implement it compiles fine and only fails at query time. It also leaves 
`schema()` as the only abstract method, so `TableProvider` becomes accidentally 
lambda-compatible. Rust's trait keeps `scan` required and makes 
`scan_with_args` the default. What do you think about keeping `scan` abstract 
here too? A provider that only wants `scanWithArgs` would then have one extra 
method to stub, but the common case keeps its compile-time check.



##########
core/src/main/java/org/apache/datafusion/ScanArgs.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.datafusion;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.OptionalLong;
+
+import org.apache.datafusion.protobuf.LogicalExprNode;
+
+/**
+ * A physical scan request using DataFusion's projection, expression and limit 
semantics.
+ *
+ * <p>Projection indices refer to the registered table schema. An absent 
projection means all
+ * columns; a present empty list means no columns (for example, {@code 
COUNT(*)}), not no rows.
+ * Filters use the same expression protobufs as DataFusion logical plans, not 
SQL strings.
+ *
+ * <p>The optional limit is the value supplied by DataFusion's planner. 
Sources may return more
+ * rows; they must not return fewer than requested when that many matching 
rows are available.
+ * DataFusion retains responsibility for deciding whether a limit can safely 
cross a residual
+ * filter. Limits outside the non-negative Java {@code long} range are not 
forwarded; DataFusion
+ * still applies the query's limit.
+ */
+public record ScanArgs(

Review Comment:
   This exposes the generated `LogicalExprNode` as public API. That type tracks 
DataFusion's `datafusion.proto` for the bundled version, and its package is 
excluded from our Javadoc. Pushdown code that matches on `BinaryExpr` ops and 
literal variants, like the test's `SelectiveSource`, could break when we bump 
DataFusion. I think passing the proto is a reasonable first step, but should we 
say in `table-provider.md` that the expression format follows DataFusion's 
proto and may change between DataFusion versions? It would be good to agree on 
that compatibility story before this ships in a release.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to