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/03/16 15:20:03 UTC

[GitHub] [arrow-datafusion] matthewmturner opened a new pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

matthewmturner opened a new pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023


   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Part of #1777 reading / registering JSON files
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
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



[GitHub] [arrow-datafusion] alamb commented on pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1073216928


   I agree we should push ahead as is and either check in some small json data directly into datafusion, perhaps in https://github.com/apache/arrow-datafusion/tree/master/datafusion/tests
   
   It isn't clear to me the value of adding to `arrow-testing`
   


-- 
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



[GitHub] [arrow-datafusion] alamb merged pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb merged pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023


   


-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1071119580


   @alamb @houqp @xudong963 any view on whether its worth waiting on getting json data integrated to arrow testing before merging this or if we can just move forward as is (after i hack together some tests)?  im starting to think maybe its just worth moving forward.


-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1073346624


   I was just surprised that there was no standard dataset for json when there was for all the other file formats - so i thought there was value in standardizing that.  But its no big deal.  Ill do locally here.


-- 
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



[GitHub] [arrow-datafusion] alamb commented on pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1076144565


   > I would expect the schema to have the field "mycol" and it be nullable. But instead no fields were picked up.
   
   I guess I don't know what type I would  expect `mycol` to be. `DataType::Null` might be accurate but not likely all that useful. 🤔 


-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1071119580


   @alamb @houqp @xudong963 any view on whether its worth waiting on getting json data integrated to arrow testing before merging this or if we can just move forward as is (after i hack together some tests)?  im starting to think maybe its just worth moving forward.


-- 
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



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#discussion_r832677950



##########
File path: datafusion/tests/sql/avro.rs
##########
@@ -133,7 +133,7 @@ async fn avro_single_nan_schema() {
 }
 
 #[tokio::test]
-async fn avro_explain() {
+async fn json_explain() {

Review comment:
       this should probably still be `avro_explain` I think

##########
File path: datafusion/tests/sql/avro.rs
##########
@@ -133,7 +133,7 @@ async fn avro_single_nan_schema() {
 }
 
 #[tokio::test]
-async fn avro_explain() {
+async fn json_explain() {

Review comment:
       ```suggestion
   async fn avro_explain() {
   ```

##########
File path: datafusion/tests/sql/json.rs
##########
@@ -17,135 +17,76 @@
 
 use super::*;
 
-async fn register_alltypes_avro(ctx: &mut SessionContext) {
-    let testdata = datafusion::test_util::arrow_test_data();
-    ctx.register_avro(
-        "alltypes_plain",
-        &format!("{}/avro/alltypes_plain.avro", testdata),
-        NdJsonReadOptions::default(),
-    )
-    .await
-    .unwrap();
-}
+const TEST_DATA_BASE: &str = "tests/jsons";
 
 #[tokio::test]
-async fn avro_query() {
+async fn json_query() {

Review comment:
       👍 




-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1075405504


   I added `write_json` as well so everything could be tested in a round trip


-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1075742116


   To clarify when i said one null field i meant a single column and record, with that record having a null value.  For example:
   
   ```
   {"mycol": null}
   ```
   
   I would expect the schema to have the field "mycol" and it be nullable.  But instead no fields were picked up.


-- 
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



[GitHub] [arrow-datafusion] alamb commented on pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1076145401


   Thanks again @matthewmturner 


-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1069228505


   I plan on submitting PR to https://github.com/apache/arrow-testing to get JSON test data added to improve testing setup for this.


-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1074028738


   Sorry, i dont know why i over complicated this. I do think this is good to go using the testing thats already there.  Let me know if anyone thinks otherwise.


-- 
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



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #2023: Add `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#discussion_r831447246



##########
File path: datafusion/tests/sql/json.rs
##########
@@ -0,0 +1,162 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use super::*;
+

Review comment:
       these tests seem to be testing `avro` not `json` -- I wonder if you forgot to push a commit @matthewmturner ?




-- 
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



[GitHub] [arrow-datafusion] matthewmturner commented on pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
matthewmturner commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1075503038


   So the current error is when reading a json file with a single record with one field that is null.  the schema is not picked up correctly. i think this would have to be handled on the arrow side.  maybe i could add `#[should_panic]` for now?


-- 
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



[GitHub] [arrow-datafusion] alamb commented on pull request #2023: Add `write_json`, `read_json`, `register_json`, and `JsonFormat` to `CREATE EXTERNAL TABLE` functionality

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #2023:
URL: https://github.com/apache/arrow-datafusion/pull/2023#issuecomment-1075703456


   > So the current error is when reading a json file with a single record with one field that is null. the schema is not picked up correctly. i think this would have to be handled on the arrow side. maybe i could add #[should_panic] for now?
   
   
   I am not sure what the schema of a single record with one null field should be (and doesn't seem all that important of a use case). Adding `#should_panic `sounds good to me and maybe filing a ticket in arrow-rs with whatever is wrong?


-- 
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