final FunctionEntry functionEntry = nullaryFunctionMap.get(tableName);
if (functionEntry != null) {
final Function function = functionEntry.getFunction();
if (function instanceof TableMacro) {
assert function.getParameters().isEmpty();
final Table table = ((TableMacro) function).apply(ImmutableList.of());
return Pair.of(tableName, table);
}
}
for (Function function : schema.getFunctions(tableName)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table = ((TableMacro) function).apply(ImmutableList.of());
return Pair.of(tableName, table);
}
}
} else {
for (Map.Entry<String, FunctionEntry> entry
: find(nullaryFunctionMap, tableName).entrySet()) {
final Function function = entry.getValue().getFunction();
if (function instanceof TableMacro) {
assert function.getParameters().isEmpty();
final Table table = ((TableMacro) function).apply(ImmutableList.of());
return Pair.of(entry.getKey(), table);
}
}
final NavigableSet<String> set =
implicitFunctionCache.get(System.currentTimeMillis());
for (String s : find(set, tableName)) {
for (Function function : schema.getFunctions(s)) {
if (function instanceof TableMacro
&& function.getParameters().isEmpty()) {
final Table table =
((TableMacro) function).apply(ImmutableList.of());
return Pair.of(s, table);
}
}
}