etolbakov commented on code in PR #1011:
URL: 
https://github.com/apache/datafusion-ballista/pull/1011#discussion_r1582857496


##########
ballista/scheduler/src/scheduler_server/grpc.rs:
##########
@@ -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",
             )),
-        }?;

Review Comment:
   I had to drop the "short circuit"  from here to resolve the rust compilation 
error:
   ```sh
   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 things?



##########
ballista/scheduler/src/scheduler_server/grpc.rs:
##########
@@ -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",
             )),
-        }?;

Review Comment:
   I had to drop the "short circuit"  from here to resolve the rust compilation 
error:
   ```sh
   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?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to