/** * Check if a tuple attribute reference is valid. Disambiguate if needed. Also set the * RelationSchema for the TupleAttribute. * */ boolean analyzeTupleAttribute(TupleAttribute ta) { if (ta.tableName == null) { BaseRelationSchema found_in = null; for (BaseRelationSchema rs : query_relations) { // System.out.println("searching for " + ta.attributeName + " in " + rs); if (rs.hasAttribute(ta.attributeName)) { if (found_in == null) { found_in = rs; } else { System.out.println("=========> Attribute " + ta.attributeName + " ambiguous"); return false; } } } if (found_in != null) { ta.tableName = found_in.getName(); ta.setRelationSchema(found_in); return true; } else { System.out.println( "=========> Attribute " + ta.attributeName + " not found in any of the tables in the FROM clause"); return false; } } else { if (!checkRelationContainedInFromClause(ta.tableName)) { System.out.println("=========> Relation " + ta.tableName + " not in the From Clause"); return false; } ta.setRelationSchema(Globals.getRelationSchema(ta.tableName)); if (!ta.rs.hasAttribute(ta.attributeName)) { System.out.println( "=========> Attribute " + ta.attributeName + " not present in the relation " + ta.tableName); return false; } return true; } }