[ 
https://issues.apache.org/jira/browse/PHOENIX-3341?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15543643#comment-15543643
 ] 

Maryann Xue commented on PHOENIX-3341:
--------------------------------------

Just realized that there is already an interface "contentsHaveChangedSince()", 
which is to let CalciteSchema reset or preserve its caching. But the problem is 
that CatalogReader calls add() method and that affects the "tableMap" field in 
CalciteSchema, which is not part of the caching.
{code}
  private RelOptTableImpl getTableFrom(List<String> names,
      List<String> schemaNames) {
    CalciteSchema schema =
        getSchema(Iterables.concat(schemaNames, Util.skipLast(names)));
    if (schema == null) {
      return null;
    }
    final String name = Util.last(names);
    CalciteSchema.TableEntry entry = schema.getTable(name, caseSensitive);
    if (entry == null) {
      entry = schema.getTableBasedOnNullaryFunction(name, caseSensitive);
    }
    if (entry != null) {
      final Table table = entry.getTable();
      final String name2 = entry.name;
      return RelOptTableImpl.create(this, table.getRowType(typeFactory),
          schema.add(name2, table), null);
    }
    return null;
  }
{code}

> Data update is not visible to following statements of the same connection due 
> to CalciteSchema caching.
> -------------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-3341
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3341
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>              Labels: calcite
>
> The TableRef object contains a timestamp which will be used for TableScan. 
> The timestamp should be set at the time of the statement being compiled. Now 
> that the table resolving goes from Calcite and CalciteSchema caches 
> TableEntry through the whole connection, the table will not be re-resolved if 
> any previous statement has already resolved it. If a previous statement did 
> an update, the next statement cannot see the update since it's holding a 
> TableRef object containing the old timestamp.
> The CalciteSchema caching would also be a problem if a table, a view, or a 
> function is modified or dropped.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to