@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof QualifiedAttributeID) { QualifiedAttributeID other = (QualifiedAttributeID)obj; return (this.attribute.equals(other.attribute) && ((this.relation == other.relation) || ((this.relation != null) && this.relation.equals(other.relation)))); } return false; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof QualifiedAttributeID) { QualifiedAttributeID other = (QualifiedAttributeID)obj; return (this.attribute.equals(other.attribute) && ((this.relation == other.relation) || ((this.relation != null) && this.relation.equals(other.relation)))); } return false; }
public ImmutableMap<QualifiedAttributeID, Term> expandStar(ImmutableMap<QualifiedAttributeID, Term> attributes, Table table) { RelationID id = idfac.createRelationID(table.getSchemaName(), table.getName()); return attributes.entrySet().stream() .filter(e -> e.getKey().getRelation() != null && e.getKey().getRelation().equals(id)) .collect(ImmutableCollectors.toMap( e -> new QualifiedAttributeID(null, e.getKey().getAttribute()), Map.Entry::getValue)); }
private static void extractPrimaryKey(DatabaseRelationDefinition relation, QuotedIDFactory idfac, RelationID id, ResultSet rs) throws SQLException { Map<Integer, String> primaryKeyAttributes = new HashMap<>(); String currentName = null; while (rs.next()) { // TABLE_CAT is ignored for now; assume here that relation has a fully specified name RelationID id2 = RelationID.createRelationIdFromDatabaseRecord(idfac, rs.getString("TABLE_SCHEM"), rs.getString("TABLE_NAME")); if (id2.equals(id)) { currentName = rs.getString("PK_NAME"); // may be null String attr = rs.getString("COLUMN_NAME"); int seq = rs.getShort("KEY_SEQ"); primaryKeyAttributes.put(seq, attr); } } if (!primaryKeyAttributes.isEmpty()) { // use the KEY_SEQ values to restore the correct order of attributes in the PK UniqueConstraint.Builder builder = UniqueConstraint.builder(relation); for (int i = 1; i <= primaryKeyAttributes.size(); i++) { QuotedID attrId = QuotedID.createIdFromDatabaseRecord(idfac, primaryKeyAttributes.get(i)); builder.add(relation.getAttribute(attrId)); } relation.addUniqueConstraint(builder.build(currentName, true)); } }
public ImmutableMap<QualifiedAttributeID, Term> expandStar(ImmutableMap<QualifiedAttributeID, Term> attributes, Table table) { RelationID id = idfac.createRelationID(table.getSchemaName(), table.getName()); return attributes.entrySet().stream() .filter(e -> e.getKey().getRelation() != null && e.getKey().getRelation().equals(id)) .collect(ImmutableCollectors.toMap( e -> new QualifiedAttributeID(null, e.getKey().getAttribute()), Map.Entry::getValue)); }
@Override public void visit(AllTableColumns allTableColumns) { Table table = allTableColumns.getTable(); RelationID id = idfac.createRelationID(table.getSchemaName(), table.getName()); map = attributes.entrySet().stream() .filter(e -> e.getKey().getRelation() != null && e.getKey().getRelation().equals(id)) .collect(ImmutableCollectors.toMap( e -> new QualifiedAttributeID(null, e.getKey().getAttribute()), Map.Entry::getValue)); }
@Override public void visit(AllTableColumns allTableColumns) { Table table = allTableColumns.getTable(); RelationID id = idfac.createRelationID(table.getSchemaName(), table.getName()); map = attributes.entrySet().stream() .filter(e -> e.getKey().getRelation() != null && e.getKey().getRelation().equals(id)) .collect(ImmutableCollectors.toMap( e -> new QualifiedAttributeID(null, e.getKey().getAttribute()), Map.Entry::getValue)); }
if (id2.equals(id)) { currentName = rs.getString("PK_NAME"); // may be null String attr = rs.getString("COLUMN_NAME");
System.out.println(" " + relationId + "." + attributeId); if (currentRelation == null || !currentRelation.getID().equals(relationId)) {
System.out.println(" " + relationId + "." + attributeId); if (currentRelation == null || !currentRelation.getID().equals(relationId)) {
for (Function func : views.keySet()) { RelationID knownViewId = views.get(func); if (knownViewId.equals(relationId)) { table = func.getFunctionSymbol().toString(); break;