DataFusion to run SQL queries on Parquet files with error No suitable object store found for file

43 Views Asked by At

I have a parquet file in a directory called /resource/user inside the project directory.

--project root
  --resources
    --user
      --user1.parquet
      --user2.parquet
      --user3.parquet
  --main.rs

I use this directory as the data source for query, then use Apache DataFusion to run SQL queries on Parquet files

code in the main.rs

  let ctx = SessionContext::new();

  // Configure listing options
  let file_format = ParquetFormat::default().with_enable_pruning(Some(true));
  let listing_options = ListingOptions::new(Arc::new(file_format))
  .with_table_partition_cols(vec![])
  .with_file_extension(".parquet")
  .with_collect_stat(true);

  ctx.register_listing_table(
      "my_table",
      &format!("file://{}","./resources/user"),
      listing_options,
      None,
      None,
  )
  .await
  .unwrap();

  // execute the query
  let df = ctx.sql("SELECT * FROM my_table LIMIT 1",)
      .await?;

  // print the results
  df.show().await?;

running the code gives me an error saying:

called `Result::unwrap()` on an `Err` value: Internal("No suitable object store found for file://./resources/user")
0

There are 0 best solutions below