@Override public boolean equals(Object o) { if (o instanceof RelationVertex) { RelationVertex other = (RelationVertex) o; return this.relationNode.equals(other.relationNode) && this.topLogicalNode.equals(other.topLogicalNode); } return false; }
public void addRelation(RelationNode relation) { if (relation.hasAlias()) { TUtil.putToNestedList(relationAliasMap, relation.getTableName(), relation.getCanonicalName()); } canonicalNameToRelationMap.put(relation.getCanonicalName(), relation); relationList.add(relation); relNodePidAccessPathMap.put(relation.getPID(), new ArrayList<AccessPathInfo>()); }
@Override public Schema getSchema() { return relationNode.getOutSchema(); }
if (rel.isNameResolveBase()) { Column found = rel.getLogicalSchema().getColumn(columnName); if (found != null) { candidates.add(found); return guessColumn(IdentifierUtil.buildFQName(candidateRels.get(0).getCanonicalName(), columnName)); } else if (candidateRels.size() > 1) { throw new AmbiguousColumnException(columnName);
/** * Find relations such that its schema contains a given column * * @param block the current block * @param columnName The column name to find relation * @return relations including a given column */ public static Collection<RelationNode> lookupTableByColumns(LogicalPlan.QueryBlock block, String columnName) { Set<RelationNode> found = new HashSet<>(); for (RelationNode rel : block.getRelations()) { if (rel.getLogicalSchema().contains(columnName)) { found.add(rel); } } return found; }
/** * 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 which can be either qualified or not. * @return A corresponding relation */ public static RelationNode lookupTable(LogicalPlan.QueryBlock block, String tableName) throws AmbiguousTableException { List<RelationNode> found = new ArrayList<>(); for (RelationNode relation : block.getRelations()) { // 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 (IdentifierUtil.extractSimpleName(relation.getCanonicalName()).equals(tableName) || IdentifierUtil.extractSimpleName(relation.getTableName()).equals(tableName)) { found.add(relation); } } if (found.size() == 0) { return null; } else if (found.size() > 1) { throw new AmbiguousTableException(tableName); } return found.get(0); }
Schema schema = relationOp.getLogicalSchema(); Column[] resolvedColumns = new Column[schema.size()]; return schema.getRootColumns().toArray(resolvedColumns); if (relationOp.isNameResolveBase()) { schema = relationOp.getLogicalSchema(); resolvedColumns.addAll(schema.getRootColumns());
LogicalPlan.QueryBlock parentBlock = plan.getParentBlock(current); for (RelationNode relationNode : parentBlock.getRelations()) { if (relationNode.getLogicalSchema().containsByQualifiedName(columnRef.getCanonicalName())) { throw new TajoRuntimeException(new NotImplementedException("Correlated subquery")); CatalogUtil.buildFQName(relationOp.getCanonicalName(), CatalogUtil.extractSimpleName(canonicalName)); Schema schema = relationOp.getLogicalSchema(); column = schema.getColumn(canonicalName);
@Override public String toString() { return relationNode.getCanonicalName(); }
@Override public Object clone() throws CloneNotSupportedException { TableSubQueryNode newTableSubQueryNode = (TableSubQueryNode) super.clone(); newTableSubQueryNode.tableName = tableName; newTableSubQueryNode.subQuery = (LogicalNode) subQuery.clone(); if (hasTargets()) { newTableSubQueryNode.targets = new ArrayList<>(); for (Target t : targets) { newTableSubQueryNode.targets.add((Target) t.clone()); } } return newTableSubQueryNode; }
public List<AccessPathInfo> getAccessInfos(RelationNode relation) { return Collections.unmodifiableList(relNodePidAccessPathMap.get(relation.getPID())); }
@Override public int hashCode() { return relationNode.hashCode(); }
@Override public boolean isEligible(LogicalPlanRewriteRuleContext context) { for (LogicalPlan.QueryBlock block : context.getPlan().getQueryBlocks()) { for (RelationNode relation : block.getRelations()) { if (relation.getType() == NodeType.SCAN) { TableDesc table = ((ScanNode)relation).getTableDesc(); if (table.hasPartition()) { return true; } } } } return false; }
if (rel.isNameResolveBase()) { Column found = rel.getLogicalSchema().getColumn(columnName); if (found != null) { candidates.add(found); return guessColumn(CatalogUtil.buildFQName(candidateRels.get(0).getCanonicalName(), columnName)); } else if (candidateRels.size() > 1) { throw new AmbiguousColumnException(columnName);
/** * Find relations such that its schema contains a given column * * @param block the current block * @param columnName The column name to find relation * @return relations including a given column */ public static Collection<RelationNode> lookupTableByColumns(LogicalPlan.QueryBlock block, String columnName) { Set<RelationNode> found = TUtil.newHashSet(); for (RelationNode rel : block.getRelations()) { if (rel.getLogicalSchema().contains(columnName)) { found.add(rel); } } return found; }
/** * 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 which can be either qualified or not. * @return A corresponding relation */ public static RelationNode lookupTable(LogicalPlan.QueryBlock block, String tableName) throws AmbiguousTableException { List<RelationNode> found = TUtil.newList(); for (RelationNode relation : block.getRelations()) { // 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)) { found.add(relation); } } if (found.size() == 0) { return null; } else if (found.size() > 1) { throw new AmbiguousTableException(tableName); } return found.get(0); }
Schema schema = relationOp.getLogicalSchema(); Column[] resolvedColumns = new Column[schema.size()]; return schema.getRootColumns().toArray(resolvedColumns); if (relationOp.isNameResolveBase()) { schema = relationOp.getLogicalSchema(); resolvedColumns.addAll(schema.getRootColumns());
LogicalPlan.QueryBlock parentBlock = plan.getParentBlock(current); for (RelationNode relationNode : parentBlock.getRelations()) { if (relationNode.getLogicalSchema().containsByQualifiedName(columnRef.getCanonicalName())) { throw new TajoRuntimeException(new NotImplementedException("Correlated subquery")); IdentifierUtil.buildFQName(relationOp.getCanonicalName(), IdentifierUtil.extractSimpleName(canonicalName)); Schema schema = relationOp.getLogicalSchema(); column = schema.getColumn(canonicalName);
@Override public String toString() { return relationNode.getCanonicalName(); }
@Override public Object clone() throws CloneNotSupportedException { TableSubQueryNode newTableSubQueryNode = (TableSubQueryNode) super.clone(); newTableSubQueryNode.tableName = tableName; newTableSubQueryNode.subQuery = (LogicalNode) subQuery.clone(); if (hasTargets()) { newTableSubQueryNode.targets = new Target[targets.length]; for (int i = 0; i < targets.length; i++) { newTableSubQueryNode.targets[i] = (Target) targets[i].clone(); } } return newTableSubQueryNode; }