andygrove commented on code in PR #115:
URL:
https://github.com/apache/arrow-datafusion-python/pull/115#discussion_r1060180171
##########
src/context.rs:
##########
@@ -348,12 +348,16 @@ impl PySessionContext {
.ok_or_else(|| PyValueError::new_err("Unable to convert path to a
string"))?;
let mut options = NdJsonReadOptions::default()
.table_partition_cols(convert_table_partition_cols(table_partition_cols)?);
- options.schema = schema.map(|s| Arc::new(s.0));
options.schema_infer_max_records = schema_infer_max_records;
options.file_extension = file_extension;
-
- let result = self.ctx.read_json(path, options);
- let df = wait_for_future(py, result).map_err(DataFusionError::from)?;
+ let df = if let Some(schema) = schema {
+ options.schema = Some(&schema.0);
+ let result = self.ctx.read_json(path, options);
+ wait_for_future(py, result).map_err(DataFusionError::from)?
+ } else {
+ let result = self.ctx.read_json(path, options);
+ wait_for_future(py, result).map_err(DataFusionError::from)?
+ };
Review Comment:
This was necessary because `options.schema` holds a reference to a schema
now so we need to wait for the future to complete before ownership can be
released.
--
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]