(expression.getSQLtype() != null) &&
(expression.getSQLtype().isNullable())) {
// With an outer join, the column can still be nullable.
columnInstance = columnInstance.withNullable(true);
}
expression.setPreptimeValue(new TPreptimeValue(columnInstance));
}
else if (columnSource instanceof AggregateSource) {
AggregateSource aggTable = (AggregateSource) columnSource;
TPreptimeValue ptv = aggTable.getField(expression.getPosition()).getPreptimeValue();
expression.setPreptimeValue(ptv);
}
else if (columnSource instanceof SubquerySource) {
TPreptimeValue tpv;
Subquery subquery = ((SubquerySource)columnSource).getSubquery();
TypedPlan typedSubquery = findTypedPlanNode(subquery.getInput());
if (typedSubquery != null) {
tpv = new TPreptimeValue(typedSubquery.getTypeAt(expression.getPosition()));
}
else {
logger.warn("no Project found for subquery: {}", columnSource);
tpv = new TPreptimeValue(typesTranslator.typeForSQLType(expression.getSQLtype()));
}
expression.setPreptimeValue(tpv);
return expression;
}
else if (columnSource instanceof NullSource) {
expression.setPreptimeValue(new TPreptimeValue(null, null));
return expression;
}
else if (columnSource instanceof Project) {
Project pTable = (Project) columnSource;
TPreptimeValue ptv = pTable.getFields().get(expression.getPosition()).getPreptimeValue();
expression.setPreptimeValue(ptv);
}
else if (columnSource instanceof ExpressionsSource) {
ExpressionsSource exprsTable = (ExpressionsSource) columnSource;
List<List<ExpressionNode>> expressions = exprsTable.getExpressions();
TPreptimeValue tpv;
if (expressions.size() == 1) {
// get the TPV straight from the expression, since there's just one row
tpv = expressions.get(0).get(expression.getPosition()).getPreptimeValue();
}
else {
TInstance type = exprsTable.getTypeAt(expression.getPosition());
tpv = new TPreptimeValue(type);
}
expression.setPreptimeValue(tpv);
}
else if (columnSource instanceof CreateAs){
expression.setPreptimeValue(new TPreptimeValue(null, null));
return expression;
}
else {
throw new AssertionError(columnSource + "(" + columnSource.getClass() + ")");
}