pola-rs/polars · error
init must be called first
Error message
init must be called first
What it means
get_schema on the IPC Flight reader requires init() to have been called first so self.footer is populated. The error fires when get_schema (or another accessor) is invoked before the reader parsed the file footer, because footer-dependent state is None.
Solutions
- Call init() (or finish connecting) before accessing schema, record batches, or dictionary blocks
- Ensure the Flight endpoint returned data before reading the schema
- Restructure code to only construct dependent readers after successful initialization
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/polars-arrow/src/io/ipc/read/flight.rs:227 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/fb2d022478c629dc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-arrow/src/io/ipc/read/flight.rs:227
let footer = Box::new(footer);
#[allow(clippy::unnecessary_cast)]
let ptr = Box::leak(footer) as *const _ as *const FooterRef<'static>;
self.footer = Some(ptr);
let footer = &unsafe { **self.footer.as_ref().unwrap() };
self.data_blocks = Some(Box::new(iter_recordbatch_blocks_from_footer(*footer)?)
as Box<dyn SendableIterator<Item = _>>);
self.dict_blocks = iter_dictionary_blocks_from_footer(*footer)?
.map(|i| Box::new(i) as Box<dyn SendableIterator<Item = _>>);
Ok(())
}
pub fn get_schema(self: &Pin<Box<Self>>) -> PolarsResult<EncodedData> {
let footer = &unsafe { **self.footer.as_ref().expect("init must be called first") };
let schema_ref = deserialize_schema_ref_from_footer(*footer)?;
let schema = schema_to_raw_message(schema_ref);
Ok(schema)
}
pub async fn next_dict(
self: &mut Pin<Box<Self>>,
encoded_data: &mut EncodedData,
) -> PolarsResult<Option<()>> {
assert!(self.data_blocks.is_some(), "init must be called first");
encoded_data.ipc_message.clear();
encoded_data.arrow_data.clear();
if let Some(iter) = &mut self.dict_blocks {
let Some(value) = iter.next() else {
return Ok(None);View on GitHub (pinned to fe841f959e)