Cannot read avro schema without the 'avro' feature enabled

use datafusion::arrow::util::pretty;
use datafusion::error::Result;
use datafusion::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
     let ctx = SessionContext::new();
     let avro_file = "binary.avro";
     ctx.register_avro("alltypes_plain", avro_file, AvroReadOptions::default())
         .await?;
     // it warns: Error: NotImplemented("cannot read avro schema without the 'avro' feature enabled")
     Ok(())
}

how to read avro file?

As the error message indicates, you need to enable the "avro" feature on datafusion

Edit your Cargo.toml, replacing the datafusion dependency with

datafusion = { version = "12.0.0", features = ["avro"] }

(the version can be whatever you need it to be)

If you already had features enabled for datafusion, you just need to add "avro" to the list.

1 Like