Search in sources :

Example 1 with Wildcard

use of com.wplatform.ddal.command.expression.Wildcard in project jdbc-shards by wplatform.

the class Select method expandColumnList.

private void expandColumnList() {
    Database db = session.getDatabase();
    // the expressions may change within the loop
    for (int i = 0; i < expressions.size(); i++) {
        Expression expr = expressions.get(i);
        if (!expr.isWildcard()) {
            continue;
        }
        String schemaName = expr.getSchemaName();
        String tableAlias = expr.getTableAlias();
        if (tableAlias == null) {
            int temp = i;
            expressions.remove(i);
            for (TableFilter filter : filters) {
                Wildcard c2 = new Wildcard(filter.getTable().getSchema().getName(), filter.getTableAlias());
                expressions.add(i++, c2);
            }
            i = temp - 1;
        } else {
            TableFilter filter = null;
            for (TableFilter f : filters) {
                if (db.equalsIdentifiers(tableAlias, f.getTableAlias())) {
                    if (schemaName == null || db.equalsIdentifiers(schemaName, f.getSchemaName())) {
                        filter = f;
                        break;
                    }
                }
            }
            if (filter == null) {
                throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableAlias);
            }
            Table t = filter.getTable();
            String alias = filter.getTableAlias();
            expressions.remove(i);
            Column[] columns = t.getColumns();
            for (Column c : columns) {
                if (filter.isNaturalJoinColumn(c)) {
                    continue;
                }
                ExpressionColumn ec = new ExpressionColumn(session.getDatabase(), null, alias, c.getName());
                expressions.add(i++, ec);
            }
            i--;
        }
    }
}
Also used : Expression(com.wplatform.ddal.command.expression.Expression) Wildcard(com.wplatform.ddal.command.expression.Wildcard) ExpressionColumn(com.wplatform.ddal.command.expression.ExpressionColumn) Database(com.wplatform.ddal.engine.Database) ExpressionColumn(com.wplatform.ddal.command.expression.ExpressionColumn)

Aggregations

Expression (com.wplatform.ddal.command.expression.Expression)1 ExpressionColumn (com.wplatform.ddal.command.expression.ExpressionColumn)1 Wildcard (com.wplatform.ddal.command.expression.Wildcard)1 Database (com.wplatform.ddal.engine.Database)1