Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add JSON getitem support #4525

Merged
merged 5 commits into from
Sep 20, 2022
Merged

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Sep 17, 2022

This PR adds the ability to extract object values or array elements of a JSON-typed column.

Notable things:

  • ClickHouse support for this is experimental, and doesn't seem to work in ClickHouse itself and is also broken/unsupported in clickhouse_driver.
  • PySpark works, but since we're not handling result conversion at all really the test fails.
  • The SQLAlchemy backends basically all "just work", the main differences being how the JSON type is return in Python. We handle this here by trying to parse the JSON and if that fails assuming the value is already deserialized.

@cpcloud cpcloud added this to the 4.0.0 milestone Sep 17, 2022
@cpcloud cpcloud added backends Issues related to all backends feature Features or general enhancements expressions Issues or PRs related to the expression API ux User experience related issues labels Sep 17, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 17, 2022

Test Results

       35 files         35 suites   1h 18m 35s ⏱️
  9 806 tests   7 735 ✔️ 2 071 💤 0
35 821 runs  27 842 ✔️ 7 979 💤 0

Results for commit 2dce0a1.

♻️ This comment has been updated with latest results.

@codecov
Copy link

codecov bot commented Sep 17, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@e629633). Click here to learn what that means.
The diff coverage is 96.00%.

❗ Current head 2dce0a1 differs from pull request most recent head d3206f0. Consider uploading reports for the commit d3206f0 to get more accurate results

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4525   +/-   ##
=========================================
  Coverage          ?   92.52%           
=========================================
  Files             ?      184           
  Lines             ?    19922           
  Branches          ?     2935           
=========================================
  Hits              ?    18432           
  Misses            ?     1116           
  Partials          ?      374           
Impacted Files Coverage Δ
ibis/backends/dask/execution/strings.py 68.47% <ø> (ø)
ibis/backends/pandas/execution/constants.py 100.00% <ø> (ø)
ibis/backends/pandas/execution/strings.py 82.27% <83.33%> (ø)
ibis/backends/base/sql/alchemy/datatypes.py 91.12% <100.00%> (ø)
ibis/backends/base/sql/alchemy/registry.py 97.01% <100.00%> (ø)
ibis/backends/base/sql/alchemy/translator.py 96.36% <100.00%> (ø)
ibis/backends/conftest.py 91.72% <100.00%> (ø)
ibis/backends/mysql/compiler.py 100.00% <100.00%> (ø)
ibis/backends/mysql/registry.py 95.83% <100.00%> (ø)
ibis/backends/pandas/client.py 96.77% <100.00%> (ø)
... and 6 more

@cpcloud cpcloud force-pushed the json-getitem branch 7 times, most recently from c1a439f to 2dce0a1 Compare September 18, 2022 13:53
class JSONValue(StringValue):
pass # noqa: E701,E302
class JSONValue(Value):
def __getitem__(self, key):
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a follow-up to provide .get(key, default) API similar to maps?

@@ -27,6 +27,7 @@ class TestConf(UnorderedComparator, BackendTest, RoundHalfToEven):
supported_to_timestamp_units = {'s'}
supports_floating_modulus = False
bool_is_int = True
supports_json = False
Copy link
Member

Choose a reason for hiding this comment

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

Please add a follow-up issue to investigate it further.

@kszucs kszucs enabled auto-merge (rebase) September 20, 2022 12:48
@kszucs kszucs merged commit 381d805 into ibis-project:master Sep 20, 2022
@cpcloud cpcloud deleted the json-getitem branch October 23, 2022 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backends Issues related to all backends expressions Issues or PRs related to the expression API feature Features or general enhancements ux User experience related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants