Description
The current implementation (ever since its first version) of SimpleCalciteSchema.getImplicitTableBasedOnNullaryFunction() is wrong, but it was not revealed until julianhyde's check-in for CALCITE-1563.
The implementation 1) did not use "tableName" in finding the functions at all; 2) was caching based.
protected TableEntry getImplicitTableBasedOnNullaryFunction(String tableName, boolean caseSensitive) { for (String s : schema.getFunctionNames()) { for (Function function : schema.getFunctions(s)) { if (function instanceof TableMacro && function.getParameters().isEmpty()) { final Table table = ((TableMacro) function).apply(ImmutableList.of()); return tableEntry(tableName, table); } } } return null; }