Github user jihoonson commented on a diff in the pull request:
https://github.com/apache/tajo/pull/422#discussion_r29862163
--- Diff:
tajo-plan/src/main/java/org/apache/tajo/plan/nameresolver/NameResolver.java ---
@@ -51,30 +70,45 @@
resolverMap.put(NameResolvingMode.LEGACY, new ResolverByLegacy());
}
+ public static Column resolve(LogicalPlan plan, LogicalPlan.QueryBlock
block, ColumnReferenceExpr column,
+ NameResolvingMode mode) throws
PlanningException {
+ if (!resolverMap.containsKey(mode)) {
+ throw new PlanningException("Unsupported name resolving level: " +
mode.name());
+ }
+ return resolverMap.get(mode).resolve(plan, block, column);
+ }
+
abstract Column resolve(LogicalPlan plan, LogicalPlan.QueryBlock block,
ColumnReferenceExpr columnRef)
throws PlanningException;
/**
- * Try to find the database name
+ * Guess a relation from a table name regardless of whether the given
name is qualified or not.
*
* @param block the current block
- * @param tableName The table name
- * @return The found database name
+ * @param tableName The table name which can be either qualified or not.
+ * @return A corresponding relation
* @throws PlanningException
*/
- public static String resolveDatabase(LogicalPlan.QueryBlock block,
String tableName) throws PlanningException {
- List<String> found = new ArrayList<String>();
+ public static RelationNode lookupTable(LogicalPlan.QueryBlock block,
String tableName) throws PlanningException {
+ List<RelationNode> found = TUtil.newList();
+
for (RelationNode relation : block.getRelations()) {
- // check alias name or table name
- if
(CatalogUtil.extractSimpleName(relation.getCanonicalName()).equals(tableName) ||
+
+ // if a table name is qualified
+ if (relation.getCanonicalName().equals(tableName) ||
relation.getTableName().equals(tableName)) {
+ found.add(relation);
+
+ // if a table name is not qualified
+ } else if
(CatalogUtil.extractSimpleName(relation.getCanonicalName()).equals(tableName) ||
CatalogUtil.extractSimpleName(relation.getTableName()).equals(tableName)) {
- // obtain the database name
- found.add(CatalogUtil.extractQualifier(relation.getTableName()));
+ // obtain the a qualified table name
--- End diff --
This comment looks unnecessary.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---