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: Add SQLMesh warning when an exp.Command is parsed #3138

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

VaggelisD
Copy link
Contributor

Public slack context

This PR overrides SQLGlot's _warn_unsupported() to suggest the usage of Jinja on the occasion that the (unsupported) statement is attempting to reference the physical table.

@@ -314,6 +317,13 @@ def _parse_join(
return macro


def _warn_unsupported(self: Parser) -> None:
self.__warn_unsupported() # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think we need to call super

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept it there to maintain the diagnostic message of which syntax is not supported; The following sqlmesh warning will not suffice for that matter. Wdyt, is it not needed anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

you can make the current message more robust

Copy link
Contributor Author

@VaggelisD VaggelisD Sep 16, 2024

Choose a reason for hiding this comment

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

Not sure how to word this best for the average user who will probably not understand SQLGlot's exp.Command, SQLMesh's physical table references etc. Happy to change the message to whatever you prefer.

sql = self._find_sql(self._tokens[0], self._tokens[-1])[: self.error_message_context]

logger.warning(
f"'{sql}' could not be semantically understood as it contains unsupported syntax, falling back to parsing as 'Command'. SQLMesh is unable to resolve any references to the model's "
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of saying falling back to parsing as a command, maybe say SQLMesh is treating the command as is.

@tobymao tobymao merged commit 549a70f into main Sep 17, 2024
23 checks passed
@tobymao tobymao deleted the vaggelisd/cmd_warning branch September 17, 2024 16:22
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