private TypedObject calculateLeafExpression(LeafExpression expression, BulletRecord record) { Value value = expression.getValue(); TypedObject result = null; String valueString = value.getValue(); Type type = value.getType(); switch (value.getKind()) { case FIELD: result = extractTypedObject(valueString, record); if (type != null) { result = result.forceCast(type); } break; case VALUE: result = TypedObject.forceCast(type, valueString); break; } return result; }
protected com.yahoo.bullet.parsing.Expression visitCastExpression(CastExpression node, Void context) throws ParsingException { if (containsCastExpression(node.getExpression())) { throw new ParsingException("Casting of cast expressions is not supported"); } com.yahoo.bullet.parsing.Expression expression = process(node.getExpression()); if (expression instanceof BinaryExpression) { ((BinaryExpression) expression).setType(Type.valueOf(node.getCastType().toUpperCase())); } else { Value value = ((LeafExpression) expression).getValue(); ((LeafExpression) expression).setValue(new Value(value.getKind(), value.getValue(), Type.valueOf(node.getCastType().toUpperCase()))); } return expression; }