martin-g commented on code in PR #18812:
URL: https://github.com/apache/datafusion/pull/18812#discussion_r2540932675
##########
datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs:
##########
@@ -75,14 +83,29 @@ impl<R: Read> AvroArrowArrayReader<'_, R> {
pub fn schema_lookup(schema: AvroSchema) -> Result<BTreeMap<String,
usize>> {
match schema {
AvroSchema::Record(RecordSchema {
- fields, mut lookup, ..
+ fields,
+ mut lookup,
+ name,
+ ..
}) => {
+ let mut unresolved_names = NamesResolver::default();
+ unresolved_names.in_progress.insert(name.clone());
+
for field in fields {
- Self::child_schema_lookup(&field.name, &field.schema, &mut
lookup)?;
+ Self::child_schema_lookup(
+ &field.name,
+ &field.schema,
+ &mut lookup,
+ &mut unresolved_names,
+ )?;
}
+
+ unresolved_names.in_progress.remove(&name);
+ assert!(unresolved_names.in_progress.is_empty());
Review Comment:
```suggestion
assert!(unresolved_names.in_progress.is_empty(),
format!("Unresolved schema references: {}", unresolved_names.in_progress));
```
Does it need to be an `assert!()` ? Better return an Err like for
self-reference or at least make it `debug_assert!()`
##########
datafusion/datasource-avro/src/avro_to_arrow/arrow_array_reader.rs:
##########
@@ -41,19 +42,24 @@ use arrow::datatypes::{
};
use arrow::datatypes::{Fields, SchemaRef};
use arrow::error::ArrowError;
-use arrow::error::ArrowError::SchemaError;
use arrow::error::Result as ArrowResult;
use arrow::record_batch::RecordBatch;
use arrow::util::bit_util;
-use datafusion_common::arrow_err;
use datafusion_common::error::{DataFusionError, Result};
+use datafusion_common::{arrow_err, HashMap, HashSet};
use num_traits::NumCast;
use std::collections::BTreeMap;
use std::io::Read;
use std::sync::Arc;
type RecordSlice<'a> = &'a [&'a Vec<(String, Value)>];
+#[derive(Default)]
+pub struct NamesResolver {
Review Comment:
```suggestion
pub(crate) struct NamesResolver {
```
or `pub(super)` ?
--
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]