You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/12 16:12:43 UTC

[GitHub] [arrow-datafusion-python] larskarg commented on a diff in pull request #56: Add `read_json` to `SessionContext`

larskarg commented on code in PR #56:
URL: https://github.com/apache/arrow-datafusion-python/pull/56#discussion_r993662323


##########
src/context.rs:
##########
@@ -264,4 +264,38 @@ impl PySessionContext {
     fn session_id(&self) -> PyResult<String> {
         Ok(self.ctx.session_id())
     }
+
+    #[allow(clippy::too_many_arguments)]
+    #[args(
+        schema = "None",
+        schema_infer_max_records = "1000",
+        file_extension = "\".json\"",
+        table_partition_cols = "vec![]",
+    )]
+    fn read_json(
+        &mut self,
+        path: PathBuf,
+        schema: Option<Schema>,
+        schema_infer_max_records: usize,
+        file_extension: &str,
+        table_partition_cols: Vec<String>,
+        py: Python
+    ) -> PyResult<PyDataFrame> {
+        let path = path
+            .to_str()
+            .ok_or_else(|| PyValueError::new_err("Unable to convert path to a string"))?;
+
+        let mut options = NdJsonReadOptions::default()
+            .table_partition_cols(table_partition_cols);
+        options.schema = match schema {

Review Comment:
   Fixed.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org