Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4115

Improve the prompt of using SQL keywords for sql parser

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.23.0
    • Fix Version/s: 1.25.0
    • Component/s: core

      Description

      Current when a user uses a reserved-keyword in the SQL, for example:

      select DEFAULT from emp;
      

      the parser would report with error message:

      Encountered "DEFAULT" at line 1, column 8.
      Was expecting one of:
          "ABS" ...
          "ALL" ...
          "ARRAY" ...
          "AVG" ...
          "CARDINALITY" ...
          "CASE" ...
          "CAST" ...
          "CEIL" ...
          "CEILING" ...
          "CHAR_LENGTH" ...
          "CHARACTER_LENGTH" ...
      

      It is hard to infer that the DEFAULT is actually a reserved-keyword, we can promote the message to make it more clear.

      For example, in SQL-SERVER, if you use such a keyword, the server reports "Incorrect syntax near the keyword 'DEFAULT'", which is very clear that the DEFAULT is a keyword.

      Based on the SQL-SERVER message, i would suggest to also report the position with a suggested fix solution, the template is like this:

      Incorrect syntax near the keyword {keyword} at line {line_number},
      column {column_number}.\n
      Either uses a non-reserved keyword or quotes the keyword with
      character: {quoting_character}.
      

      We would tell user that the mistake is a keyword and its position, also how to fix it.

        Attachments

          Activity

            People

            • Assignee:
              danny0405 Danny Chen
              Reporter:
              danny0405 Danny Chen
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 50m
                1h 50m