private static RelationID getRelationIDFromString(String name, QuotedIDFactory idfac) { String[] names = name.split("\\."); if (names.length == 1) return idfac.createRelationID(null, name); else return idfac.createRelationID(names[0], names[1]); } }
private static RelationID getRelationIDFromString(String name, QuotedIDFactory idfac) { String[] names = name.split("\\."); if (names.length == 1) return idfac.createRelationID(null, name); else return idfac.createRelationID(names[0], names[1]); } }
private RelationID createAlias(String predicateName, String suffix, Collection<RelationID> usedAliases) { // escapes the predicate name String safePredicateName = predicateName .replace('.', '_') .replace(':', '_') .replace('/', '_') .replace(' ', '_'); String alias = sqladapter.nameView(VIEW_PREFIX, safePredicateName, suffix, usedAliases); return idFactory.createRelationID(null, alias); }
private RelationID createAlias(String predicateName, String suffix, Collection<RelationID> usedAliases) { // escapes the predicate name String safePredicateName = predicateName .replace('.', '_') .replace(':', '_') .replace('/', '_') .replace(' ', '_'); String alias = sqladapter.nameView(VIEW_PREFIX, safePredicateName, suffix, usedAliases); return idFactory.createRelationID(null, alias); }
@Override public void visit(Table table) { if (!withTCEs.contains(table.getFullyQualifiedName().toLowerCase())) { RelationID relationId = idfac.createRelationID(table.getSchemaName(), table.getName()); relations.add(relationId); } }
@Override public void visit(Table table) { if (!withTCEs.contains(table.getFullyQualifiedName().toLowerCase())) { RelationID relationId = idfac.createRelationID(table.getSchemaName(), table.getName()); relations.add(relationId); } }
/** * Retrieve the normalized list of tables from a given list of RelationIDs */ private static List<RelationID> getTableList(String defaultTableSchema, Set<RelationID> realTables, QuotedIDFactory idfac) throws SQLException { List<RelationID> fks = new LinkedList<>(); for (RelationID table : realTables) { // defaultTableSchema is non-empty only for Oracle and DUAL is a special Oracle table if (table.hasSchema() || (defaultTableSchema == null) || table.getTableName().equals("DUAL")) fks.add(table); else { RelationID qualifiedTableId = idfac.createRelationID(defaultTableSchema, table.getTableNameSQLRendering()); fks.add(qualifiedTableId); } } return fks; }
/** * Retrieve the normalized list of tables from a given list of RelationIDs */ private static List<RelationID> getTableList(String defaultTableSchema, Set<RelationID> realTables, QuotedIDFactory idfac) throws SQLException { List<RelationID> fks = new LinkedList<>(); for (RelationID table : realTables) { // defaultTableSchema is non-empty only for Oracle and DUAL is a special Oracle table if (table.hasSchema() || (defaultTableSchema == null) || table.getTableName().equals("DUAL")) fks.add(table); else { RelationID qualifiedTableId = idfac.createRelationID(defaultTableSchema, table.getTableNameSQLRendering()); fks.add(qualifiedTableId); } } return fks; }
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)); }
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)); }
@Override public void visit(SubSelect subSelect) { if (subSelect.getAlias() == null || subSelect.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-SELECT must have an alias", subSelect); RAExpression current = select(subSelect.getSelectBody()); RelationID aliasId = idfac.createRelationID(null, subSelect.getAlias().getName()); result = RAExpression.alias(current, aliasId, termFactory); }
@Override public void visit(SubSelect subSelect) { if (subSelect.getAlias() == null || subSelect.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-SELECT must have an alias", subSelect); RAExpression current = select(subSelect.getSelectBody()); RelationID aliasId = idfac.createRelationID(null, subSelect.getAlias().getName()); result = RAExpression.alias(current, aliasId); }
@Override public void visit(SubSelect subSelect) { if (subSelect.getAlias() == null || subSelect.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-SELECT must have an alias", subSelect); relationIndex++; SelectBody selectBody = subSelect.getSelectBody(); if (!(selectBody instanceof PlainSelect)) throw new UnsupportedSelectQueryRuntimeException("Complex SELECT statements are not supported", selectBody); RAExpressionAttributes current = select((PlainSelect) selectBody); RelationID aliasId = idfac.createRelationID(null, subSelect.getAlias().getName()); result = RAExpressionAttributes.alias(current, aliasId); }
@Override public void visit(SubSelect subSelect) { if (subSelect.getAlias() == null || subSelect.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-SELECT must have an alias", subSelect); relationIndex++; SelectBody selectBody = subSelect.getSelectBody(); if (!(selectBody instanceof PlainSelect)) throw new UnsupportedSelectQueryRuntimeException("Complex SELECT statements are not supported", selectBody); RAExpressionAttributes current = select((PlainSelect) selectBody); RelationID aliasId = idfac.createRelationID(null, subSelect.getAlias().getName()); result = RAExpressionAttributes.alias(current, aliasId); }
@Override public void visit(SubJoin subjoin) { if (subjoin.getAlias() == null || subjoin.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-JOIN must have an alias", subjoin); RAExpression left = getRelationalExpression(subjoin.getLeft()); RAExpression join; try { join = join(left, subjoin.getJoin()); } catch (IllegalJoinException e) { throw new InvalidSelectQueryRuntimeException(e.toString(), subjoin); } RelationID aliasId = idfac.createRelationID(null, subjoin.getAlias().getName()); result = RAExpression.alias(join, aliasId, termFactory); }
@Override public void visit(SubJoin subjoin) { if (subjoin.getAlias() == null || subjoin.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-JOIN must have an alias", subjoin); RAExpressionAttributes left = getRelationalExpression(subjoin.getLeft()); RAExpressionAttributes join; try { join = join(left, subjoin.getJoin()); } catch (IllegalJoinException e) { throw new InvalidSelectQueryRuntimeException(e.toString(), subjoin); } RelationID aliasId = idfac.createRelationID(null, subjoin.getAlias().getName()); result = RAExpressionAttributes.alias(join, aliasId); }
@Override public void visit(SubJoin subjoin) { if (subjoin.getAlias() == null || subjoin.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-JOIN must have an alias", subjoin); RAExpression left = getRelationalExpression(subjoin.getLeft()); RAExpression join; try { join = join(left, subjoin.getJoin()); } catch (IllegalJoinException e) { throw new InvalidSelectQueryRuntimeException(e.toString(), subjoin); } RelationID aliasId = idfac.createRelationID(null, subjoin.getAlias().getName()); result = RAExpression.alias(join, aliasId); }
@Override public void visit(SubJoin subjoin) { if (subjoin.getAlias() == null || subjoin.getAlias().getName() == null) throw new InvalidSelectQueryRuntimeException("SUB-JOIN must have an alias", subjoin); RAExpressionAttributes left = getRelationalExpression(subjoin.getLeft()); RAExpressionAttributes join; try { join = join(left, subjoin.getJoin()); } catch (IllegalJoinException e) { throw new InvalidSelectQueryRuntimeException(e.toString(), subjoin); } RelationID aliasId = idfac.createRelationID(null, subjoin.getAlias().getName()); result = RAExpressionAttributes.alias(join, aliasId); }