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


##########
native/src/table_provider.rs:
##########
@@ -216,41 +355,28 @@ impl ExecutionPlan for JavaScanExec {
             )
         };
 
-        // 3. Surface any Java exception.
-        if env.exception_check().unwrap_or(false) {
-            let throwable = env.exception_occurred().map_err(|e| {
-                DataFusionError::Execution(format!("exception_occurred failed: 
{}", e))
-            })?;
-            env.exception_clear().ok();
-            return Err(DataFusionError::Execution(jthrowable_to_string(
-                &mut env,
-                &throwable,
-                "TableProvider",
-                &self.name,
-            )));
-        }
-
-        call_result.map_err(|e| DataFusionError::Execution(format!("JNI call 
failed: {}", e)))?;
+        checked_call(&mut env, call_result, &self.name)?;
 
         // 4. Reclaim the FFI struct and import as a RecordBatchReader.
         let ffi_stream: FFI_ArrowArrayStream = *ffi_box;
         let reader = ArrowArrayStreamReader::try_new(ffi_stream)
             .map_err(|e| DataFusionError::ArrowError(Box::new(e), None))?;
 
-        // 5. Verify the producer's declared schema matches our registered 
schema.
+        // 5. A plan can push projection into its reader or return the 
registered full schema,
+        // as the default Java scanWithArgs implementation does for legacy 
providers.
         let reader_schema = reader.schema();
-        // Schema::PartialEq compares fields AND metadata. If IPC / FFI 
round-trips
-        // ever normalise metadata differently between the registration path 
and the
-        // scan path, switch to comparing `.fields()` only.
-        if reader_schema.as_ref() != self.full_schema.as_ref() {
+        let projection = if reader_schema == self.projected_schema {

Review Comment:
   One thing I noticed is that the new mismatch branch here, where a plan 
returns a schema that is neither the projection nor the full schema, doesn't 
have a test yet. The guide says projected readers must use the requested order. 
What do you think about adding a case to `TableProviderScanArgsTest` where 
`execute` returns the projected columns reversed, and asserting the query fails 
with the "expected projected schema" message? That would keep the contract 
enforced if this code changes later.



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