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();
}
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();
}
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();
}
Aggregations