john-bodley commented on code in PR #27858: URL: https://github.com/apache/superset/pull/27858#discussion_r1548658251
########## superset/sql_parse.py: ########## @@ -752,11 +752,21 @@ def _extract_tables_from_sql(self) -> set[Table]: statements = parse(self.stripped(), dialect=self._dialect) except SqlglotError as ex: logger.warning("Unable to parse SQL (%s): %s", self._dialect, self.sql) - dialect = self._dialect or "generic" + + if isinstance(ex, ParseError): + error = ex.errors[0] + suffix = "Check the {dialect}manual for the right syntax to use near '{highlight}' at line {line}".format( Review Comment: Simply doing `str(ex)` doesn't work as `SQLGlot` [includes](https://github.com/tobymao/sqlglot/blob/e5e5ba0c4921f99e063e6d1f47ffaa2181bf26e1/sqlglot/parser.py#L1264-L1273) ANSI codes which are helpful when printing in the terminal, but simply render as `[4m` and `[0m` in HTML. ########## superset/sql_parse.py: ########## @@ -752,11 +752,21 @@ def _extract_tables_from_sql(self) -> set[Table]: statements = parse(self.stripped(), dialect=self._dialect) except SqlglotError as ex: logger.warning("Unable to parse SQL (%s): %s", self._dialect, self.sql) - dialect = self._dialect or "generic" + + if isinstance(ex, ParseError): + error = ex.errors[0] + suffix = "Check the {dialect}manual for the right syntax to use near '{highlight}' at line {line}".format( # pylint: disable=consider-using-f-string,line-too-long Review Comment: Simply doing `str(ex)` doesn't work as `SQLGlot` [includes](https://github.com/tobymao/sqlglot/blob/e5e5ba0c4921f99e063e6d1f47ffaa2181bf26e1/sqlglot/parser.py#L1264-L1273) ANSI codes which are helpful when printing in the terminal, but simply render as `[4m` and `[0m` in HTML. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org