Skip to content

Commit

Permalink
fix some problems, now it can run!
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia committed Jan 8, 2023
1 parent 52d11e1 commit 8219fb0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
8 changes: 8 additions & 0 deletions datafusion-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ pub async fn exec_from_repl(
ctx: &mut SessionContext,
print_options: &mut PrintOptions,
) -> std::result::Result<(), ()> {
loop {
print!("> :");
let mut query = String::new();
std::io::stdin().read_line(&mut query).unwrap();
println!("echo: {query}");
exec_and_print(ctx, print_options, query).await;
}

Ok(())
}

Expand Down
25 changes: 16 additions & 9 deletions datafusion-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ pub async fn main() -> Result<()> {
println!("DataFusion CLI v{}", DATAFUSION_CLI_VERSION);
}

if let Some(ref path) = args.data_path {
let p = Path::new(path);
env::set_current_dir(p).unwrap();
};
// if let Some(ref path) = args.data_path {
// let p = Path::new(path);
// env::set_current_dir(p).unwrap();
// };

let mut session_config = SessionConfig::from_env()?.with_information_schema(true);

Expand All @@ -118,6 +118,12 @@ pub async fn main() -> Result<()> {
quiet: args.quiet,
};

println!("starting!");

exec::exec_from_repl(&mut ctx, &mut print_options)
.await
.unwrap();

let files = args.file;
let rc = match args.rc {
Some(file) => file,
Expand Down Expand Up @@ -151,11 +157,12 @@ pub async fn main() -> Result<()> {
}

fn create_runtime_env() -> Result<RuntimeEnv> {
let object_store_provider = DatafusionCliObjectStoreProvider {};
let object_store_registry =
ObjectStoreRegistry::new_with_provider(Some(Arc::new(object_store_provider)));
let rn_config =
RuntimeConfig::new().with_object_store_registry(Arc::new(object_store_registry));
// let object_store_provider = DatafusionCliObjectStoreProvider {};
// let object_store_registry =
// ObjectStoreRegistry::new_with_provider(Some(Arc::new(object_store_provider)));
// let rn_config =
// RuntimeConfig::new().with_object_store_registry(Arc::new(object_store_registry));
let rn_config = RuntimeConfig::default();
RuntimeEnv::new(rn_config)
}

Expand Down
12 changes: 6 additions & 6 deletions datafusion/core/src/datasource/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ impl ObjectStoreRegistry {
/// may be explicity registered with calls to [`ObjectStoreRegistry::register_store`] or
/// created lazily, on-demand by the provided [`ObjectStoreProvider`]
pub fn new_with_provider(provider: Option<Arc<dyn ObjectStoreProvider>>) -> Self {
// let object_stores: DashMap<String, Arc<dyn ObjectStore>> = DashMap::new();
let object_stores: DashMap<String, Arc<dyn ObjectStore>> = DashMap::new();
// object_stores.insert("file://".to_string(), Arc::new(LocalFileSystem::new()));
// Self {
// object_stores,
// provider,
// }
todo!()
Self {
object_stores,
provider,
}
// todo!()
}

/// Adds a new store to this registry.
Expand Down

0 comments on commit 8219fb0

Please sign in to comment.