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(hogql): automatic event and person property types #14795

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

mariusandra
Copy link
Collaborator

Problem

All properties were always returned as strings

Changes

Not any more! We now wrap all columns specified as Numeric with toFloat64OrNull, all DateTime colums with parseDateTimeBestEffort and all Boolean columns with col = 'true'

image

I think we should split Numeric up into Integer and Float for accuracy, as treating everything as a float is weird... and ClickHouse's Decimal requires a fixed precision which seems like too big of a decision to make.

How did you test this code?

Wrote tests. Checked in the UI. Checking CI now for all the extra queries this makes.

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

some thinking out loud but this does what is says on the tin

Comment on lines +17 to +37
event_property_values = (
PropertyDefinition.objects.filter(
name__in=property_finder.event_properties,
team_id=context.team_id,
type__in=[None, PropertyDefinition.Type.EVENT],
).values_list("name", "property_type")
if property_finder.event_properties
else []
)
event_properties = {name: property_type for name, property_type in event_property_values if property_type}

person_property_values = (
PropertyDefinition.objects.filter(
name__in=property_finder.person_properties,
team_id=context.team_id,
type=PropertyDefinition.Type.PERSON,
).values_list("name", "property_type")
if property_finder.person_properties
else []
)
person_properties = {name: property_type for name, property_type in person_property_values if property_type}
Copy link
Member

Choose a reason for hiding this comment

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

Might be quicker for me to ask than figure it out #Lazy

How often do we call this?

Might be early-optimizing but the property types change infrequently so we can cache seen properties relatively aggressively. Makes me wonder how well our tracing covers this code 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will just be called once per query in most cases. In case of non-hogql insights, it'll be called once per filter. This is where caching could make the biggest difference, but I didn't feel like overoptimising yet.

@mariusandra mariusandra merged commit aab03ed into database Mar 17, 2023
@mariusandra mariusandra deleted the property-types-hogql branch March 17, 2023 09:51
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