Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,43 @@ async fn test_json_get_union() {
assert_batches_eq!(expected, &batches);
}

#[tokio::test]
async fn test_union_is_null_column() {
let batches = run_query("select name, json_get(json_data, 'foo') is null from test")
.await
.unwrap();

let expected = [
"+------------------+----------------------------------------------+",
"| name | json_get(test.json_data,Utf8(\"foo\")) IS NULL |",
"+------------------+----------------------------------------------+",
"| object_foo | false |",
"| object_foo_array | false |",
"| object_foo_obj | false |",
"| object_foo_null | false |",
"| object_bar | false |", // THIS IS WRONG!
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see the test immediately above this for the repr of the union.

"| list_foo | false |", // THIS IS WRONG!
"| invalid_json | false |", // THIS IS WRONG!
"+------------------+----------------------------------------------+",
];
assert_batches_eq!(expected, &batches);
}

#[tokio::test]
async fn test_union_is_null_scalar() {
let expected = [
"+-------------------------------------------------------+",
"| json_get(Utf8(\"{\"foo\": \"bar\"}\"),Utf8(\"spam\")) IS NULL |",
"+-------------------------------------------------------+",
"| true |",
"+-------------------------------------------------------+",
];

let sql = r#"select json_get('{"foo": "bar"}', 'spam') is null"#;
let batches = run_query(sql).await.unwrap();
assert_batches_eq!(expected, &batches);
}

#[tokio::test]
async fn test_json_get_array() {
let sql = "select json_get('[1, 2, 3]', 2)";
Expand Down