Skip to content

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Apr 6, 2023

Problem

HogQL gives no errors and you have to play a guessing game to fix your query.

Changes

Instead of nothing, we now get some errors in the events explorer:

2023-04-06 17 38 39

And in full SQL insights.

2023-04-06 17 38 57

Unfortunately errors for "old insights" are still shown just in the network request:

image

I'm out of time to add support for nice errors in the interface for old insights, and it feels like something that will require custom handling with "project data exploration" anyway, so hoping @thmsobrmlr or @Twixes can help get this over the line...

While this could be added, this PR should be fine to merge already as is, because these errors will already help a lot of users.

One final point: Sometimes you can write valid HogQL, but still get a ClickHouse error. In that case, we currently show nothing. This will likely need followup as well. We should also allow-list clickhouse error codes and not send any potentially sensitive information. This closed PR implemented support for ClickHouse errors. It can be used as a starting point when implementing that.

How did you test this code?

Quickly tested in the browser (see screencasts).

@mariusandra mariusandra requested review from thmsobrmlr and Twixes April 6, 2023 15:49
@mariusandra mariusandra marked this pull request as ready for review April 6, 2023 15:52
@@ -32,12 +33,12 @@ def accept(self, visitor):
return visit(self)
if hasattr(visitor, "visit_unknown"):
return visitor.visit_unknown(self)
raise ValueError(f"Visitor has no method {method_name}")
raise HogQLException(f"Visitor has no method {method_name}")
Copy link
Member

Choose a reason for hiding this comment

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

I suppose this should be a NotImplementedException?

@@ -0,0 +1,14 @@
class HogQLException(ValueError):
Copy link
Member

Choose a reason for hiding this comment

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

To be somewaht pedantic, I'm not sure if all HogQL exceptions are ValueErrors in the "Raised when an operation or function receives an argument that has the right type but an inappropriate value" sense – e.g. a "NotImplementedException" results not from an inappropriate value, but from our transient lack of support for a value that is appropriate in principle.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 2)
  • webkit: 0 added, 0 modified, 0 deleted
  • firefox: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

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 good (also made a few tweaks)!

One gripe I have is that we're using HogQLException very broadly, we might want to be more specific, particularly in a "this should be user facing" vs. "this is an internal problem" way. But will leave that for later PRs.

@Twixes Twixes merged commit 100242e into master Apr 12, 2023
@Twixes Twixes deleted the hogql-sql-errors branch April 12, 2023 15:36
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