kosiew commented on code in PR #26635:
URL: https://github.com/apache/datafusion/pull/26635#discussion_r4549045650


##########
datafusion/datasource-parquet/src/source.rs:
##########
@@ -1452,6 +1452,40 @@ mod tests {
         assert!(source.filter().is_some());
     }
 
+    #[test]
+    fn parquet_file_reader_factory_downcasts_to_concrete_type() {
+        use crate::CachedParquetFileReaderFactory;
+        use datafusion_execution::cache::cache_manager::FileMetadataCache;
+        use datafusion_execution::cache::default_cache::DefaultCache;
+        use object_store::memory::InMemory;
+
+        let store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
+        let source = ParquetSource::new(Arc::new(Schema::empty()))
+            .with_parquet_file_reader_factory(Arc::new(
+                DefaultParquetFileReaderFactory::new(Arc::clone(&store)),
+            ));
+        let factory = source.parquet_file_reader_factory().unwrap();
+        assert!(factory.is::<DefaultParquetFileReaderFactory>());
+        assert!(
+            factory
+                .downcast_ref::<CachedParquetFileReaderFactory>()
+                .is_none()
+        );
+
+        let cache: Arc<FileMetadataCache> = Arc::new(DefaultCache::new(1024));
+        let source = ParquetSource::new(Arc::new(Schema::empty()))
+            .with_parquet_file_reader_factory(Arc::new(
+                CachedParquetFileReaderFactory::new(store, cache),
+            ));
+        let factory = source.parquet_file_reader_factory().unwrap();
+        assert!(factory.is::<CachedParquetFileReaderFactory>());
+        assert!(
+            factory
+                .downcast_ref::<DefaultParquetFileReaderFactory>()
+                .is_none()

Review Comment:
   As optional issue-specific coverage, consider testing a custom factory whose 
`Debug` output resembles a built-in factory. Assert that both built-in 
`is::<T>()` checks return false and that downcasting to the custom type 
succeeds, documenting the false-positive scenario from issue #26633 without 
requiring file I/O.



##########
datafusion/datasource-parquet/src/source.rs:
##########
@@ -1452,6 +1452,40 @@ mod tests {
         assert!(source.filter().is_some());
     }
 
+    #[test]
+    fn parquet_file_reader_factory_downcasts_to_concrete_type() {
+        use crate::CachedParquetFileReaderFactory;
+        use datafusion_execution::cache::cache_manager::FileMetadataCache;
+        use datafusion_execution::cache::default_cache::DefaultCache;
+        use object_store::memory::InMemory;
+
+        let store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
+        let source = ParquetSource::new(Arc::new(Schema::empty()))
+            .with_parquet_file_reader_factory(Arc::new(
+                DefaultParquetFileReaderFactory::new(Arc::clone(&store)),
+            ));
+        let factory = source.parquet_file_reader_factory().unwrap();
+        assert!(factory.is::<DefaultParquetFileReaderFactory>());

Review Comment:
   Consider adding 
`downcast_ref::<DefaultParquetFileReaderFactory>().is_some()` here, and 
optionally the equivalent cached-factory assertion. The tests currently 
exercise only unsuccessful downcasts, so an implementation that always returns 
`None` would still pass.



##########
docs/source/library-user-guide/upgrading/56.0.0.md:
##########
@@ -1621,3 +1621,18 @@ let return_type: Option<DataType> = definition
 `CreateFunction::try_new` takes `Option<FieldRef>` for the return type.
 
 See [issue #18235](https://github.com/apache/datafusion/issues/18235) for 
details.
+
+### `ParquetFileReaderFactory` adds `Any` as a supertrait

Review Comment:
   Could you move this entry to the 57.0.0 upgrade guide? The workspace is 
already at `57.0.0-dev` (`Cargo.toml:72`), so documenting this API addition 
under 56.0.0 attributes it to the wrong release. The 57 guide does not yet 
exist in this checkout, so it would need to be created and registered using the 
existing upgrade-guide structure.



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