@Override public DatabaseRelationDefinition getDatabaseRelation(RelationID id) { DatabaseRelationDefinition def = tables.get(id); if (def == null && id.hasSchema()) { def = tables.get(id.getSchemalessID()); } return def; }
@Override public DatabaseRelationDefinition getDatabaseRelation(RelationID id) { DatabaseRelationDefinition def = tables.get(id); if (def == null && id.hasSchema()) { def = tables.get(id.getSchemalessID()); } return def; }
@Override public RelationDefinition getRelation(RelationID name) { RelationDefinition def = relations.get(name); if (def == null && name.hasSchema()) { def = relations.get(name.getSchemalessID()); } return def; }
@Override public RelationDefinition getRelation(RelationID name) { RelationDefinition def = relations.get(name); if (def == null && name.hasSchema()) { def = relations.get(name.getSchemalessID()); } return def; }
/** * Inserts a new data definition to this metadata object. * * @param td * The data definition. It can be a {@link DatabaseRelationDefinition} or a * {@link ParserViewDefinition} object. */ protected <T extends RelationDefinition> void add(T td, Map<RelationID, T> schema) { if (!isStillMutable) { throw new IllegalStateException("Too late, cannot add a schema"); } schema.put(td.getID(), td); if (td.getID().hasSchema()) { RelationID noSchemaID = td.getID().getSchemalessID(); if (!schema.containsKey(noSchemaID)) { schema.put(noSchemaID, td); } else { LOGGER.warn("DUPLICATE TABLE NAMES, USE QUALIFIED NAMES:\n" + td + "\nAND\n" + schema.get(noSchemaID)); //schema.remove(noSchemaID); // TODO (ROMAN 8 Oct 2015): think of a better way of resolving ambiguities } } }
/** * Inserts a new data definition to this metadata object. * * @param td * The data definition. It can be a {@link DatabaseRelationDefinition} or a * {@link ParserViewDefinition} object. */ protected <T extends RelationDefinition> void add(T td, Map<RelationID, T> schema) { if (!isStillMutable) { throw new IllegalStateException("Too late, cannot add a schema"); } schema.put(td.getID(), td); if (td.getID().hasSchema()) { RelationID noSchemaID = td.getID().getSchemalessID(); if (!schema.containsKey(noSchemaID)) { schema.put(noSchemaID, td); } else { LOGGER.warn("DUPLICATE TABLE NAMES, USE QUALIFIED NAMES:\n" + td + "\nAND\n" + schema.get(noSchemaID)); //schema.remove(noSchemaID); // TODO (ROMAN 8 Oct 2015): think of a better way of resolving ambiguities } } }
if ((tableName.getAlias() == null) && relation.getID().getSchemaName() != null && metadata.getDatabaseRelation(relation.getID().getSchemalessID()).equals(relation)) attrs = RAExpressionAttributes.create(attributes.build(), alias, relation.getID().getSchemalessID()); else attrs = RAExpressionAttributes.create(attributes.build(), alias);
if ((tableName.getAlias() == null) && relation.getID().getSchemaName() != null && metadata.getDatabaseRelation(relation.getID().getSchemalessID()).equals(relation)) attrs = RAExpressionAttributes.create(attributes.build(), alias, relation.getID().getSchemalessID()); else attrs = RAExpressionAttributes.create(attributes.build(), alias);
@Override public void visit(Table tableName) { RelationID id = idfac.createRelationID(tableName.getSchemaName(), tableName.getName()); // construct the predicate using the table name DatabaseRelationDefinition relation = metadata.getDatabaseRelation(id); if (relation == null) throw new InvalidSelectQueryRuntimeException("Table " + id + " not found in metadata", tableName); relationIndex++; RelationID alias = (tableName.getAlias() != null) ? idfac.createRelationID(null, tableName.getAlias().getName()) : relation.getID(); ImmutableMap<QuotedID, Term> attributes = relation.getAttributes().stream() .collect(ImmutableCollectors.toMap(Attribute::getID, attribute -> createVariable(attribute.getID()))); // DEFAULT SCHEMA // TODO: to be improved if ((tableName.getAlias() == null) && relation.getID().getSchemaName() != null && metadata.getDatabaseRelation(relation.getID().getSchemalessID()).equals(relation)) result = RAExpressionAttributes.create(attributes, alias, relation.getID().getSchemalessID()); else result = RAExpressionAttributes.create(attributes, alias); }
@Override public void visit(Table tableName) { RelationID id = idfac.createRelationID(tableName.getSchemaName(), tableName.getName()); // construct the predicate using the table name DatabaseRelationDefinition relation = metadata.getDatabaseRelation(id); if (relation == null) throw new InvalidSelectQueryRuntimeException("Table " + id + " not found in metadata", tableName); relationIndex++; RelationID alias = (tableName.getAlias() != null) ? idfac.createRelationID(null, tableName.getAlias().getName()) : relation.getID(); ImmutableMap<QuotedID, Term> attributes = relation.getAttributes().stream() .collect(ImmutableCollectors.toMap(Attribute::getID, attribute -> createVariable(attribute.getID()))); // DEFAULT SCHEMA // TODO: to be improved if ((tableName.getAlias() == null) && relation.getID().getSchemaName() != null && metadata.getDatabaseRelation(relation.getID().getSchemalessID()).equals(relation)) result = RAExpressionAttributes.create(attributes, alias, relation.getID().getSchemalessID()); else result = RAExpressionAttributes.create(attributes, alias); }