super(name, children, info);
}
@Override
public FunctionExpression create(List<Expression> children, StatementContext context) throws SQLException {
PDataType dataType = children.get(0).getDataType();
String formatString = (String)((LiteralExpression)children.get(1)).getValue(); // either date or number format string
Format formatter;
FunctionArgumentType type;
if (dataType.isCoercibleTo(PDataType.TIMESTAMP)) {
if (formatString == null) {
formatString = context.getDateFormat();
formatter = context.getDateFormatter();
} else {
formatter = FunctionArgumentType.TEMPORAL.getFormatter(formatString);
}
type = FunctionArgumentType.TEMPORAL;
}
else if (dataType.isCoercibleTo(PDataType.DECIMAL)) {
if (formatString == null)
formatString = context.getNumberFormat();
formatter = FunctionArgumentType.NUMERIC.getFormatter(formatString);
type = FunctionArgumentType.NUMERIC;
}