Search in sources :

Example 11 with SqlColumn

use of org.apache.jena.sdb.core.sqlexpr.SqlColumn in project jena by apache.

the class SqlNodeTextVisitor method visit.

@Override
public void visit(SqlCoalesce sqlNode) {
    start(sqlNode, "Coalesce", sqlNode.getAliasName());
    boolean first = true;
    SqlJoin join = sqlNode.getJoinNode();
    for (Var v : sqlNode.getCoalesceVars()) {
        if (!first)
            out.print(" ");
        first = false;
        SqlColumn col = sqlNode.getIdScope().findScopeForVar(v).getColumn();
        out.print(v.toString());
        SqlColumn leftCol = join.getLeft().getIdScope().findScopeForVar(v).getColumn();
        SqlColumn rightCol = join.getRight().getIdScope().findScopeForVar(v).getColumn();
        out.print("[" + leftCol + "/" + rightCol + "]");
    }
    for (Var v : sqlNode.getNonCoalesceVars()) {
        if (!first)
            out.print(" ");
        first = false;
        out.print(v.toString());
        // and where is came from.
        SqlColumn col = join.getIdScope().findScopeForVar(v).getColumn();
        out.print("[" + col + "]");
    }
    out.ensureStartOfLine();
    visitJoin(sqlNode.getJoinNode());
    finish();
}
Also used : Var(org.apache.jena.sparql.core.Var) SqlColumn(org.apache.jena.sdb.core.sqlexpr.SqlColumn)

Example 12 with SqlColumn

use of org.apache.jena.sdb.core.sqlexpr.SqlColumn in project jena by apache.

the class SQLBridge1 method buildProject.

@Override
protected void buildProject() {
    for (Var v : getProject()) {
        if (!v.isNamedVar())
            continue;
        // Value scope == IdScope for layout1
        // CHECK
        ScopeEntry e = getSqlExprNode().getIdScope().findScopeForVar(v);
        if (e == null)
            continue;
        SqlColumn c = e.getColumn();
        String sqlVarName = allocSqlName(v);
        addProject(c, sqlVarName);
        addAnnotation(sqlVarName + "=" + v.toString());
    }
    setAnnotation();
}
Also used : ScopeEntry(org.apache.jena.sdb.core.ScopeEntry) Var(org.apache.jena.sparql.core.Var) SqlColumn(org.apache.jena.sdb.core.sqlexpr.SqlColumn)

Example 13 with SqlColumn

use of org.apache.jena.sdb.core.sqlexpr.SqlColumn in project jena by apache.

the class SQLBridge2 method buildProject.

@Override
protected void buildProject() {
    for (Var v : getProject()) {
        if (!v.isNamedVar())
            continue;
        ScopeEntry e = getSqlNode().getNodeScope().findScopeForVar(v);
        if (e == null) {
            // Should be a column mentioned in the SELECT which is not mentioned in this block
            continue;
        }
        SqlColumn vCol = e.getColumn();
        SqlTable table = vCol.getTable();
        String sqlVarName = allocSqlName(v);
        // Need to allocate aliases because otherwise we need to access
        // "table.column" as a label and "." is illegal in a label
        String vLex = SQLUtils.gen(sqlVarName, "lex");
        // Call overrideable helper method for lex column (Oracle)
        SqlColumn cLex = getLexSqlColumn(table);
        String vLexNChar = SQLUtils.gen(sqlVarName, "lexNChar");
        // Call overrideable helper method for lex column (Oracle)
        SqlColumn cLexNChar = getLexNCharSqlColumn(table);
        String vDatatype = SQLUtils.gen(sqlVarName, "datatype");
        SqlColumn cDatatype = new SqlColumn(table, "datatype");
        String vLang = SQLUtils.gen(sqlVarName, "lang");
        SqlColumn cLang = new SqlColumn(table, "lang");
        String vType = SQLUtils.gen(sqlVarName, "type");
        SqlColumn cType = new SqlColumn(table, "type");
        addProject(cLex, vLex);
        // Oracle NCLOB support
        if (cLexNChar != null) {
            addProject(cLexNChar, vLexNChar);
        }
        addProject(cDatatype, vDatatype);
        addProject(cLang, vLang);
        addProject(cType, vType);
        addAnnotation(sqlVarName + "=" + v.toString());
    }
    setAnnotation();
}
Also used : ScopeEntry(org.apache.jena.sdb.core.ScopeEntry) Var(org.apache.jena.sparql.core.Var) SqlTable(org.apache.jena.sdb.core.sqlnode.SqlTable) SqlColumn(org.apache.jena.sdb.core.sqlexpr.SqlColumn)

Aggregations

SqlColumn (org.apache.jena.sdb.core.sqlexpr.SqlColumn)13 Var (org.apache.jena.sparql.core.Var)9 ScopeEntry (org.apache.jena.sdb.core.ScopeEntry)4 SqlExpr (org.apache.jena.sdb.core.sqlexpr.SqlExpr)3 SqlTable (org.apache.jena.sdb.core.sqlnode.SqlTable)3 S_Equal (org.apache.jena.sdb.core.sqlexpr.S_Equal)2 SqlNode (org.apache.jena.sdb.core.sqlnode.SqlNode)2 Node (org.apache.jena.graph.Node)1 Scope (org.apache.jena.sdb.core.Scope)1 SqlExprList (org.apache.jena.sdb.core.sqlexpr.SqlExprList)1 TableDescQuads (org.apache.jena.sdb.layout2.TableDescQuads)1 SDBInternalError (org.apache.jena.sdb.shared.SDBInternalError)1