forked from ibis-project/ibis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes ibis-project#1944. This does *not* add support for JSON, JSONB, and UUID PostgreSQL types. Instead, it marks them as having `dt.Any` type, allowing the tables to be loaded, and those columns mostly ignored. There is also some black formatting on some lines I didn't touch... Author: Ian Rose <ian.r.rose@gmail.com> Author: Ivan Ogasawara <ivan.ogasawara@gmail.com> Closes ibis-project#1962 from ian-r-rose/json-uuid-any and squashes the following commits: 6a878b0 [Ian Rose] Merge pull request #1 from Quansight/json-uuid-any 298efc2 [Ivan Ogasawara] Added JSON JSONB and UUID data types. 79bab94 [Ian Rose] Move test to postgres client test suite. 3748ef9 [Ian Rose] Add some light type testing for json, jsonb, uuid. b514069 [Ian Rose] Allow postgres client to read tables with UUID, JSON, JSONB types.
- Loading branch information
1 parent
a57ac5f
commit e8e1397
Showing
6 changed files
with
208 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" Tests for json data types""" | ||
import json | ||
|
||
import pytest | ||
from pytest import param | ||
|
||
import ibis | ||
from ibis.tests.backends import PostgreSQL | ||
|
||
# add here backends that support json types | ||
all_db_geo_supported = [PostgreSQL] | ||
|
||
|
||
@pytest.mark.parametrize('data', [param({'status': True}, id='status')]) | ||
@pytest.mark.only_on_backends(all_db_geo_supported) | ||
def test_json(backend, con, data, alltypes): | ||
json_value = json.dumps(data) | ||
lit = ibis.literal(json_value, type='json').name('tmp') | ||
expr = alltypes[[alltypes.id, lit]].head(1) | ||
df = expr.execute() | ||
assert df['tmp'].iloc[0] == json_value | ||
|
||
|
||
@pytest.mark.parametrize('data', [param({'status': True}, id='status')]) | ||
@pytest.mark.only_on_backends(all_db_geo_supported) | ||
def test_jsonb(backend, con, data, alltypes): | ||
jsonb_value = json.dumps(data).encode('utf8') | ||
lit = ibis.literal(jsonb_value, type='jsonb').name('tmp') | ||
expr = alltypes[[alltypes.id, lit]].head(1) | ||
df = expr.execute() | ||
assert df['tmp'].iloc[0] == jsonb_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters