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

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.17.0
    • Fix Version/s: 1.18.0
    • Component/s: core
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: