vstring.putString(column.getDefaultValue(), null);
value.getType().typeClass().fromObject(te, vstring, value);
values[ci] = value;
}
this.expressions = new TEvaluatableExpression[evalColumns.length];
TypesRegistryService registry = null;
if (evalColumns.length > 0) {
registry = queryContext.getServiceManager().getServiceByClass(TypesRegistryService.class);
}
for (int fi = 0; fi < evalColumns.length; fi++) {
int ci = evalColumns[fi];
Column column = functionColumns.get(fi);
TInstance columnType = column.getType();
String functionName;
List<TPreptimeValue> input;
List<TPreparedExpression> arguments;
if (column.getIdentityGenerator() != null) {
Sequence sequence = column.getIdentityGenerator();
TableName sequenceName = sequence.getSequenceName();
functionName = "NEXTVAL";
input = new ArrayList<>(2);
input.add(ValueSources.fromObject(sequenceName.getSchemaName(), typesTranslator.typeForString(sequenceName.getSchemaName())));
input.add(ValueSources.fromObject(sequenceName.getTableName(), typesTranslator.typeForString(sequenceName.getTableName())));
arguments = new ArrayList<>(input.size());
for (TPreptimeValue tpv : input) {
arguments.add(new TPreparedLiteral(tpv.type(), tpv.value()));
}
}
else {
functionName = column.getDefaultFunction();
assert (functionName != null) : column;
input = Collections.<TPreptimeValue>emptyList();
arguments = Collections.<TPreparedExpression>emptyList();
}
TValidatedScalar overload = registry.getScalarsResolver().get(functionName, input).getOverload();
TInstance functionType = overload.resultStrategy().fixed(column.getNullable());
TPreparedExpression expr = new TPreparedFunction(overload, functionType, arguments);
if (!functionType.equals(columnType)) {
TCast tcast = registry.getCastsResolver().cast(functionType.typeClass(), columnType.typeClass());
expr = new TCastExpression(expr, tcast, columnType);
}
TEvaluatableExpression eval = expr.build();
eval.with(queryContext);
expressions[fi] = eval;