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

Improve error message when table or column not found

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.12.0
    • Component/s: None
    • Labels:
      None

      Description

      When a table is not found in a query, the current message makes it difficult to tell among several possibilities: the schema was incorrect, the schema was correct but had wrong case, the table was incorrect, the table was correct but had wrong case. Given a query, say

      select * from schema1.table1, schema2.table2, table3
      

      we should give an error that discriminates between those possibilities for "schema1.table1", and also for "table3" looking in the default schema.

        Issue Links

          Activity

          Hide
          julianhyde Julian Hyde added a comment -

          Resolved in release 1.12.0 (2017-03-24).

          Show
          julianhyde Julian Hyde added a comment - Resolved in release 1.12.0 (2017-03-24).
          Hide
          julianhyde Julian Hyde added a comment -

          Well, maybe. But it is detecting a problem that should have been detected (and prevented) at DDL time. And it would make some already complex logic more complex.

          Show
          julianhyde Julian Hyde added a comment - Well, maybe. But it is detecting a problem that should have been detected (and prevented) at DDL time. And it would make some already complex logic more complex.
          Hide
          maryannxue Maryann Xue added a comment -

          Oh, I see. We'll apply a fix on Phoenix side then, and eventually Phoenix will require all schemas to be created explicitly. Anyway, would it help to detect this kind of object name conflict in Calcite and report more detailed message?

          Show
          maryannxue Maryann Xue added a comment - Oh, I see. We'll apply a fix on Phoenix side then, and eventually Phoenix will require all schemas to be created explicitly. Anyway, would it help to detect this kind of object name conflict in Calcite and report more detailed message?
          Hide
          julianhyde Julian Hyde added a comment -

          That's messed up. The names of objects within a schema (sub-schemas and tables) need to be distinct. If the provider does not ensure that, behavior is unspecified.

          Show
          julianhyde Julian Hyde added a comment - That's messed up. The names of objects within a schema (sub-schemas and tables) need to be distinct. If the provider does not ensure that, behavior is unspecified.
          Hide
          maryannxue Maryann Xue added a comment -

          Julian Hyde, could you please look at https://github.com/apache/calcite/pull/366?
          The reason was that in EmptyScope.resolve_, if a sub-schema has the same name of the table being resolved, it will not be able to resolve that table.
          And the trigger was that Phoenix did not have explicit schema creation (now it does but still supports implicit schemas) and thus PhoenixSchema (implementation of calcite's Schema) would return an empty sub-schema for any identifier enquired.

          Show
          maryannxue Maryann Xue added a comment - Julian Hyde , could you please look at https://github.com/apache/calcite/pull/366? The reason was that in EmptyScope.resolve_ , if a sub-schema has the same name of the table being resolved, it will not be able to resolve that table. And the trigger was that Phoenix did not have explicit schema creation (now it does but still supports implicit schemas) and thus PhoenixSchema (implementation of calcite's Schema) would return an empty sub-schema for any identifier enquired.
          Hide
          maryannxue Maryann Xue added a comment -

          I'm looking at it. Will submit a patch soon.

          Show
          maryannxue Maryann Xue added a comment - I'm looking at it. Will submit a patch soon.
          Hide
          julianhyde Julian Hyde added a comment - - edited

          I don't fully understand PHOENIX-3635 but it looks as this case changed some assumptions that Phoenix was relying on but is not a "bad" change overall. If I am mistaken, and we need to change Calcite again, please let me know.

          Show
          julianhyde Julian Hyde added a comment - - edited I don't fully understand PHOENIX-3635 but it looks as this case changed some assumptions that Phoenix was relying on but is not a "bad" change overall. If I am mistaken, and we need to change Calcite again, please let me know.
          Hide
          rajeshbabu Rajeshbabu Chintaguntla added a comment -

          Julian Hyde Maryann Xue This issue introduced the regression in Phoenix tests. PHOENIX-3635 has more details.

          Show
          rajeshbabu Rajeshbabu Chintaguntla added a comment - Julian Hyde Maryann Xue This issue introduced the regression in Phoenix tests. PHOENIX-3635 has more details.
          Hide
          julianhyde Julian Hyde added a comment -

          Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/5f9c0190.

          New errors include:

          • Object 'SALEX' not found (usually for schemas)
          • Object 'SALES' not found; did you mean 'Sales'? (if you got the case of a schema wrong)
          • Object 'EMPX' not found in 'SALES' (if you got a table wrong, or possibly a sub-schema)
          • Object 'EMP' not found in 'SALES'; did you mean 'Emp'? (if you got the case of a table wrong)
          • Table 'E' not found (if you got a table alias wrong)
          • Column 'SALX' not found in table 'EMP' (if you got a column wrong)
          • Column 'SAL' not found in table 'EMP'; did you mean 'Sal' (if you got the case of a column wrong)

          We switch terminology from 'table' to 'object' because we're not sure whether you intended a table, view, schema or something else.

          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/5f9c0190 . New errors include: Object 'SALEX' not found (usually for schemas) Object 'SALES' not found; did you mean 'Sales'? (if you got the case of a schema wrong) Object 'EMPX' not found in 'SALES' (if you got a table wrong, or possibly a sub-schema) Object 'EMP' not found in 'SALES'; did you mean 'Emp'? (if you got the case of a table wrong) Table 'E' not found (if you got a table alias wrong) Column 'SALX' not found in table 'EMP' (if you got a column wrong) Column 'SAL' not found in table 'EMP'; did you mean 'Sal' (if you got the case of a column wrong) We switch terminology from 'table' to 'object' because we're not sure whether you intended a table, view, schema or something else.

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              julianhyde Julian Hyde
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development