Skip to content

Conversation

mariusandra
Copy link
Collaborator

Problem

Deeper JSON access is one of the most requested feature for HogQL

Changes

Implements it, but without property type autodetection --> all deeply accessed properties will be string and you need a manual toInt() around them.

How did you test this code?

Wrote tests, tested in the browser:

image

@aluxian
Copy link

aluxian commented Apr 4, 2023

Awesome!

Copy link
Contributor

@thmsobrmlr thmsobrmlr left a comment

Choose a reason for hiding this comment

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

LGTM

try:
from ee.clickhouse.materialized_columns.analyze import materialize
except:
# EE not available? Assume we're good
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a bit hacky to check for EE availability like this. The test could become a noop when we move things around.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, EE tests just need to be in ee/ rather than posthog/. Hard to trust a test that self-parametrizes itself this way.

Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

Looks awesome, just not sure about that EE-dependent test either

try:
from ee.clickhouse.materialized_columns.analyze import materialize
except:
# EE not available? Assume we're good
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, EE tests just need to be in ee/ rather than posthog/. Hard to trust a test that self-parametrizes itself this way.

@mariusandra
Copy link
Collaborator Author

Ugh, that test is indeed funny. I split out the materialized part into its own test, to make sure the non-materialized part runs always. This way at least we know JSON parsing works.

There's probably an even bigger bug: while test_printer.py was fine, printer.py was importing from ee.clickhouse* directly at the root of python file. I moved that into the function itself.

I'm not that sure I'd like to move just these materialised tests into the ee/ folder now... 🤔

Base automatically changed from hogql-timezone to master April 6, 2023 08:33
@mariusandra mariusandra enabled auto-merge (squash) April 6, 2023 08:49
@mariusandra mariusandra merged commit a097e52 into master Apr 6, 2023
@mariusandra mariusandra deleted the hogql-json branch April 6, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants