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

chore(python): upgrade pydantic and datamodel-code-generator #17477

Merged
merged 18 commits into from
Sep 18, 2023

Conversation

thmsobrmlr
Copy link
Contributor

@thmsobrmlr thmsobrmlr commented Sep 15, 2023

Problem

pydantic and datamodel-code-generator are outdated.

Changes

This PR upgrades them, so we start on the current version with our port of insights to HogQL. Pydantic v2 brings a couple of useful changes for us, including improved performance and more options for serializing (important for a somewhat stable cache key).

How did you test this code?

CI run


The “Validate Django migrations” step is failing, because the migrations are run with requirement files from master, and Django can't boot up with these. This should only be a CI problem, so I'd like to force-merge this.

It would be possible to split up this PR in two (a. upgrade dependencies b. update schema to pydantic v2) to resolve the CI problem as well.

@PostHog PostHog deleted a comment from posthog-bot Sep 15, 2023
@@ -1446,7 +1446,7 @@ def test_hogql_query_filters(self):
)
query = "SELECT event, distinct_id from events WHERE distinct_id={distinct_id} and {filters}"
filters = HogQLFilters(
properties=[EventPropertyFilter(key="index", operator="exact", value=4, type="event")]
properties=[EventPropertyFilter(key="index", operator="exact", value="4", type="event")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was erroring with a ClickHouse exception, due to different behaviour in Pydantic v1 and v2.

ClickHouse Error

DB::Exception: There is no supertype for types String, Float64 because some of them are String/FixedString and some of them are not: while executing 'FUNCTION equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties, 'index'), ''), 'null'), '^"|"$', '') : 17, 4. : 10) -> equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(properties, 'index'), ''), 'null'), '^"|"$', ''), 4.) Nullable(UInt8) : 18'. Stack trace:9

Pydantic

See the populated value property (right at the end).

Pydantic v1

EventPropertyFilter(key="index", operator="exact", value=4, type="event")
> EventPropertyFilter(key='index', label=None, operator=<PropertyOperator.exact: 'exact'>, type='event', value='4')

Pydantic v2

EventPropertyFilter(key="index", operator="exact", value=4, type="event")
> EventPropertyFilter(key='index', label=None, operator=<PropertyOperator.exact: 'exact'>, type='event', value=4.0)

@thmsobrmlr thmsobrmlr changed the title wip: extend query schema chore(python): upgrade pydantic and datamodel-code-generator Sep 16, 2023
@PostHog PostHog deleted a comment from posthog-bot Sep 18, 2023
@PostHog PostHog deleted a comment from posthog-bot Sep 18, 2023
# Conflicts:
#	frontend/__snapshots__/scenes-app-recordings--recordings-play-list-no-pinned-recordings.png
@PostHog PostHog deleted a comment from posthog-bot Sep 18, 2023
@thmsobrmlr thmsobrmlr marked this pull request as ready for review September 18, 2023 10:55
@mariusandra mariusandra merged commit 26f29f1 into master Sep 18, 2023
62 of 63 checks passed
@mariusandra mariusandra deleted the hogql-extend-schema branch September 18, 2023 13:05
daibhin added a commit that referenced this pull request Sep 18, 2023
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.

2 participants