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.
Added JSON JSONB and UUID data types.
- Loading branch information
Showing
6 changed files
with
171 additions
and
13 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