-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(scheduler): add csv support for get_file_metadata grpc method #1011
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
008a95d
feat(scheduler): add csv support for get_file_metadata grpc method
etolbakov b5a6e5e
fix(scheduler): adjust failing tests
etolbakov abe5118
chore(scheduler): adjust per clippy
etolbakov 4557143
chore(scheduler): more clippy
etolbakov f6fcfda
chore(scheduler): apply another clippy suggestion
etolbakov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ use ballista_core::serde::protobuf::{ | |
}; | ||
use ballista_core::serde::scheduler::ExecutorMetadata; | ||
|
||
use datafusion::datasource::file_format::csv::CsvFormat; | ||
use datafusion::datasource::file_format::parquet::ParquetFormat; | ||
use datafusion::datasource::file_format::FileFormat; | ||
use datafusion_proto::logical_plan::AsLogicalPlan; | ||
|
@@ -297,13 +298,24 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> SchedulerGrpc | |
// TODO shouldn't this take a ListingOption object as input? | ||
|
||
let GetFileMetadataParams { path, file_type } = request.into_inner(); | ||
let file_format: Arc<dyn FileFormat> = match file_type.as_str() { | ||
let file_format: Result<Arc<dyn FileFormat>, Status> = match file_type.as_str() { | ||
"parquet" => Ok(Arc::new(ParquetFormat::default())), | ||
// TODO implement for CSV | ||
"csv" => { | ||
let format = CsvFormat::default() | ||
.with_delimiter(b',') | ||
.with_has_header(true); | ||
Ok(Arc::new(format)) | ||
} | ||
"tbl" => { | ||
let format = CsvFormat::default() | ||
.with_delimiter(b'|') | ||
.with_has_header(false); | ||
Ok(Arc::new(format)) | ||
} | ||
_ => Err(tonic::Status::unimplemented( | ||
"get_file_metadata unsupported file type", | ||
)), | ||
}?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to drop the "short circuit" from here to resolve the rust compilation error: Type mismatch [E0308] expected `Result<Arc<CsvFormat>, Status>`, but found `Result<Arc<ParquetFormat>, Status>` please let me know if there's a better way of doing it? |
||
}; | ||
|
||
let path = Path::from(path.as_str()); | ||
let file_metas: Vec<_> = obj_store | ||
|
@@ -316,7 +328,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> SchedulerGrpc | |
tonic::Status::internal(msg) | ||
})?; | ||
|
||
let schema = file_format | ||
let schema = file_format? | ||
.infer_schema(&state, &obj_store, &file_metas) | ||
.await | ||
.map_err(|e| { | ||
|
@@ -641,15 +653,17 @@ mod test { | |
|
||
use datafusion_proto::protobuf::LogicalPlanNode; | ||
use datafusion_proto::protobuf::PhysicalPlanNode; | ||
use tonic::Request; | ||
use object_store::path::Path; | ||
use tempfile::NamedTempFile; | ||
use tonic::{Code, Request}; | ||
|
||
use crate::config::SchedulerConfig; | ||
use crate::metrics::default_metrics_collector; | ||
use ballista_core::error::BallistaError; | ||
use ballista_core::serde::protobuf::{ | ||
executor_registration::OptionalHost, executor_status, ExecutorRegistration, | ||
ExecutorStatus, ExecutorStoppedParams, HeartBeatParams, PollWorkParams, | ||
RegisterExecutorParams, | ||
ExecutorStatus, ExecutorStoppedParams, GetFileMetadataParams, | ||
GetFileMetadataResult, HeartBeatParams, PollWorkParams, RegisterExecutorParams, | ||
}; | ||
use ballista_core::serde::scheduler::ExecutorSpecification; | ||
use ballista_core::serde::BallistaCodec; | ||
|
@@ -832,6 +846,68 @@ mod test { | |
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_get_file_metadata() -> Result<(), BallistaError> { | ||
let cluster = test_cluster_context(); | ||
let config = SchedulerConfig::default(); | ||
let mut scheduler: SchedulerServer<LogicalPlanNode, PhysicalPlanNode> = | ||
SchedulerServer::new( | ||
"localhost:50050".to_owned(), | ||
cluster, | ||
BallistaCodec::default(), | ||
Arc::new(config), | ||
default_metrics_collector().unwrap(), | ||
); | ||
scheduler.init().await?; | ||
|
||
let test_file = NamedTempFile::new()?; | ||
let source_location_str = | ||
Path::from(test_file.as_ref().to_str().unwrap()).to_string(); | ||
|
||
let requests = vec![ | ||
Request::new(GetFileMetadataParams { | ||
path: source_location_str.clone(), | ||
file_type: "parquet".to_string(), | ||
}), | ||
Request::new(GetFileMetadataParams { | ||
path: source_location_str.clone(), | ||
file_type: "csv".to_string(), | ||
}), | ||
Request::new(GetFileMetadataParams { | ||
path: source_location_str.clone(), | ||
file_type: "tbl".to_string(), | ||
}), | ||
]; | ||
for request in requests { | ||
let response = scheduler | ||
.get_file_metadata(request) | ||
.await | ||
.expect("Received error response") | ||
.into_inner(); | ||
assert_eq!( | ||
response, | ||
GetFileMetadataResult { | ||
schema: Some(datafusion_proto::protobuf::Schema { | ||
columns: vec![], | ||
metadata: Default::default(), | ||
}), | ||
} | ||
); | ||
} | ||
|
||
let request: Request<GetFileMetadataParams> = | ||
Request::new(GetFileMetadataParams { | ||
path: source_location_str, | ||
file_type: "avro".to_string(), | ||
}); | ||
let avro_response = scheduler | ||
.get_file_metadata(request) | ||
.await | ||
.expect_err("get_file_metadata unsupported file type"); | ||
assert_eq!(avro_response.code(), Code::Unimplemented); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_register_executor_in_heartbeat_service() -> Result<(), BallistaError> { | ||
let cluster = test_cluster_context(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that in the benchmark there's slightly different
default
for parquet:I wonder if we need consistency or it's ok to leave it as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think pruning is default already, so in practice it will be the same.