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): type class refactor, field to constant type resolving #15129

Merged
merged 26 commits into from
Apr 18, 2023

Conversation

mariusandra
Copy link
Collaborator

Changes

  • Create classes like UUIDType or IntegerType or ArrayType for all supported datatypes.
  • Create a combined TableOrSelectType and refactor some more
  • Extract type information from database fields when creating a CallType

Out of scope: correct type arguments and return types for functions. Lots more incoming.

How did you test this code?

  • Updated tests
  • Added a test to check that a database fields resolves to a DateTime type. More tests in the next PRs when we build a come complete type system.

@mariusandra mariusandra requested a review from a team April 18, 2023 10:20
Base automatically changed from hogql-ref-types to master April 18, 2023 13:12

# https://github.com/ClickHouse/ClickHouse/issues/23194 - "Describe how identifiers in SELECT queries are resolved"


def resolve_refs(node: ast.Expr, database: Database, scope: Optional[ast.SelectQueryRef] = None):
def resolve_constant_data_type(constant: Any) -> ConstantType:
Copy link
Contributor

Choose a reason for hiding this comment

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

are NULL constants a thing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are still some decisions to take here... and I'd love to have someone with whom to talk this through.

My understanding so far:

  • null is a value that fits everywhere, and not a special data type
  • you can have a field with with the value null, but its type would still be "uint8" or "float64" or "bool" or whatever, but with a "nullable" modifier
  • I needed an "unknown" type, which is now also the default given to any "autodetected" constant type
  • this type system still needs a lot of work and some unification across the board (the work touches clickhouse types, but properties are identified as "number" and need to be split to "int" and "float"... and "decimal"?) - so more PRs to come...

@mariusandra mariusandra merged commit bc8726b into master Apr 18, 2023
@mariusandra mariusandra deleted the hogql-types-improved branch April 18, 2023 20:21
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.

3 participants