Skip to content

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Apr 17, 2023

Problem

The concept of a "ref" in HogQL is confusing and prone to lead to bugs in the future.

Changes

The "refs" were previously called "symbols" and were inspired by TypeScript's AST. However both names seem bad in retrospect. I was anyway planning on extending this system to support actual type resolution (e.g. "error: argument must be int"), hence I started to refactor refs into types.

  • Change the name "ref" to "type" to see if that improves clarity. I think it does.
  • Added basic support for data types (bool, string, etc). This will be extended further and used for e.g. call arguments, error messages, array/tuple access, etc.
  • Renamed many fields in the "*Type" classes to better reflect their contents (e.g. name -> alias, table -> table_type, etc).
  • The previous "SelectQueryRef", which was actually a variable scope, actually makes sense as "SelectQueryType". It does contain information on the types of fields exported by this type.
  • The types seem to make more sense than "refs" when used in e.g. "FieldType", "PropertyType", "LazyTableType", etc.

Next up:

  • Types for call arguments and return types.
  • Errors if you're calling any function wrong
  • Array and tuple types and access.

How did you test this code?

Updated tests

@mariusandra mariusandra changed the title feal(hogql): rename "ref"-s to "type"-s, introduce types feat(hogql): rename "ref"-s to "type"-s, introduce types Apr 17, 2023
@mariusandra mariusandra marked this pull request as ready for review April 17, 2023 15:20
@mariusandra mariusandra merged commit 9019923 into master Apr 18, 2023
@mariusandra mariusandra deleted the hogql-ref-types branch April 18, 2023 13:12
@Twixes Twixes restored the hogql-ref-types branch April 18, 2023 14:02
@Twixes Twixes deleted the hogql-ref-types branch April 18, 2023 14:04
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