}
private SqlCoalesce(SDBRequest request, String alias, SqlJoin join, Set<Var> coalesceVars)
{
this(alias, join, coalesceVars) ;
Annotation1 annotation = new Annotation1(true) ;
// ScopeCoalesce needed
// Scope is:
// new ScopeRename(oldScope, renames) ;
// And ScopeBase ==> ScopeTable.
idScope = new ScopeRename(join.getIdScope()) ;
nodeScope = new ScopeRename(join.getNodeScope()) ;
SqlTable table = new SqlTable(alias) ;
nonCoalesceVars = SetUtils.difference(join.getIdScope().getVars(),
coalesceVars) ;
// In layout1, NodeScope is the same as IdScope
// if ( join.getNodeScope().getVars().size() != 0 )
// LoggerFactory.getLogger(SqlCoalesce.class).warn("NodeScope is not empty") ;
for ( Var v : coalesceVars )
{
String sqlColName = request.genId(AliasBase) ;
SqlColumn col = new SqlColumn(table, sqlColName) ;
idScope.setAlias(v, col) ;
annotation.addAnnotation(v+" as "+col) ;
// TODO Value
}
// Aliases.
// Not coalesce variables.
for ( Var v : nonCoalesceVars )
{
if ( coalesceVars.contains(v) )
{
LoggerFactory.getLogger(SqlCoalesce.class).warn("Variable in coalesce and non-coalesce sets: "+v) ;
continue ;
}
String sqlColName = request.genId(AliasBase) ;
SqlColumn col = new SqlColumn(table, sqlColName) ;
idScope.setAlias(v, col) ;
annotation.addAnnotation(v+" as "+col) ;
// TODO Value
}
annotation.setAnnotation(this) ;
}