You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently whenever a SQLParseException is returned to the client, we only return the line:column, this is often confusing as the user might just ignore this information as counting lines and characters is annoying.
In some scenarios, like using the admin ui, this is even a worse experience, e.g.
Latest versions of modern languages made special advancements in this developer experience part, for example Python, where errors are typically underlined in ^ chars, e.g.
Include the query with the offending token underlined with ^ characters, perhaps under a flag? ie: http://localhost:4200/_sql?verbose_errors=true
I tested the modification myself in my Python parser of CrateDB.
classExceptionErrorListener(ErrorListener):
""" Error listener that raises antlr4 errors as a Python exceptions. """defsyntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
query=offendingSymbol.source[1].strdataoffending_token_text: str=query[offendingSymbol.start: offendingSymbol.stop+1]
query_lines: list=query.split('\n')
offending_line: str=query_lines[line-1]
# White spaces from the beginning of the offending line to the offending text, so the '^'# chars are correctly placed below the offending token.newline_offset=offending_line.index(offending_token_text)
newline=offending_line+'\n'+ (' '*newline_offset+'^'* (offendingSymbol.stop-offendingSymbol.start+1))
query_lines[line-1] =newlinemsg=msg+"\n\n"+"\n".join(query_lines)
raiseParsingError(f'line {line}:{column}{msg}')
raiseParsingError(f'line {line}:{column}{msg}')
cratedb_sqlparse.parser.parser.ParsingError: line1:89noviablealternativeatinput'SELECT ended FROM "sys"."jobs_log" WHERE classification['type'] = 'INSERT' AND stmt LIKE %'SELECTendedFROM"sys"."jobs_log"WHEREclassification['type'] ='INSERT'ANDstmtLIKE%%table_schema.%table_name%'
^
I think having these literal pointers to where the error might be is a great help.
The antlr4 compile targets are extremely similar between languages, I would say it would be fairly easy to just port this to our Java implementation of the error listener or serve as inspiration for a solution.
Considered Alternatives
No response
The text was updated successfully, but these errors were encountered:
Problem Statement
Currently whenever a SQLParseException is returned to the client, we only return the line:column, this is often confusing as the user might just ignore this information as counting lines and characters is annoying.
In some scenarios, like using the admin ui, this is even a worse experience, e.g.
Latest versions of modern languages made special advancements in this developer experience part, for example Python, where errors are typically underlined in ^ chars, e.g.
Possible Solutions
Include the query with the offending token underlined with ^ characters, perhaps under a flag? ie:
http://localhost:4200/_sql?verbose_errors=true
I tested the modification myself in my Python parser of CrateDB.
These are some examples:
I think having these literal pointers to where the error might be is a great help.
The antlr4 compile targets are extremely similar between languages, I would say it would be fairly easy to just port this to our Java implementation of the error listener or serve as inspiration for a solution.
Considered Alternatives
No response
The text was updated successfully, but these errors were encountered: