Skip to content

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

@helxsz

Description

@helxsz

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions