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

SqlAdvisor.getCompletionHints does not work for nested identifiers sub-match

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.17.0
    • 1.18.0
    • core
    • None

    Description

      Test (SqlAdvisorTest):

        @Test public void testNestSchema() throws Exception {
          String sql;
          sql = "select * from sales.n^";
          assertComplete(
              sql,
          ...);
      }
      

      Expected output: "SALES.NEST" schema and tables inside and so on
      Actual output: empty.

      The thing is it properly uses n for prefix search, however it uses hint.toString() and it fails for multi-name identifiers:

              // Regular identifier. Case-insensitive match.
              for (SqlMoniker hint : completionHints) {
                String cname = hint.toString();
                if ((cname.length() >= word.length())
                    && cname.substring(0, word.length()).equalsIgnoreCase(word)) {
                  result.add(hint);
                }
              }
      

      Hints are like "CATALOG.SALES.NEST", and they fail cname.substring(0, word.length()).equalsIgnoreCase(word) check

      Attachments

        Issue Links

          Activity

            People

              vladimirsitnikov Vladimir Sitnikov
              vladimirsitnikov Vladimir Sitnikov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: