@Override public Void visit(LiteralExpr l, Integer step) { Literal lc = l.getValue(); if (lc.getLiteralType().equals(Literal.Type.TRUE) || lc.getLiteralType().equals(Literal.Type.FALSE) || lc.getLiteralType().equals(Literal.Type.NULL) || lc.getLiteralType().equals(Literal.Type.MISSING)) { out.println(skip(step) + "LiteralExpr [" + l.getValue().getLiteralType() + "]"); } else { out.println(skip(step) + "LiteralExpr [" + l.getValue().getLiteralType() + "] [" + l.getValue().getStringValue() + "]"); } return null; }
public static Literal exprToStringLiteral(Expression expr) throws CompilationException { if (expr.getKind() != Expression.Kind.LITERAL_EXPRESSION) { throw new CompilationException(ErrorCode.PARSE_ERROR, "Expected expression can only be of type %1$s", Expression.Kind.LITERAL_EXPRESSION); } LiteralExpr keyLiteralExpr = (LiteralExpr) expr; Literal keyLiteral = keyLiteralExpr.getValue(); if (keyLiteral.getLiteralType() != Literal.Type.STRING) { throw new CompilationException(ErrorCode.PARSE_ERROR, "Expected Literal can only be of type %1$s", Literal.Type.STRING); } return keyLiteral; }
public static List<List<List<String>>> getFunctionDependencies(IQueryRewriter rewriter, Expression expression, MetadataProvider metadataProvider) throws CompilationException { Set<CallExpr> functionCalls = rewriter.getFunctionCalls(expression); //Get the List of used functions and used datasets List<List<String>> datasourceDependencies = new ArrayList<>(); List<List<String>> functionDependencies = new ArrayList<>(); for (CallExpr functionCall : functionCalls) { FunctionSignature signature = functionCall.getFunctionSignature(); FunctionIdentifier fid = new FunctionIdentifier(signature.getNamespace(), signature.getName(), signature.getArity()); if (fid.equals(BuiltinFunctions.DATASET)) { Pair<String, String> path = DatasetUtil.getDatasetInfo(metadataProvider, ((LiteralExpr) functionCall.getExprList().get(0)).getValue().getStringValue()); datasourceDependencies.add(Arrays.asList(path.first, path.second)); } else if (BuiltinFunctions.isBuiltinCompilerFunction(signature, false)) { continue; } else { functionDependencies.add(Arrays.asList(signature.getNamespace(), signature.getName(), Integer.toString(signature.getArity()))); } } List<List<List<String>>> dependencies = new ArrayList<>(); dependencies.add(datasourceDependencies); dependencies.add(functionDependencies); return dependencies; }
private Map<Expression, ColumnAliasBinding> mapRecordConstructor(RecordConstructor rc) { Map<Expression, ColumnAliasBinding> exprMap = new HashMap<>(); for (FieldBinding binding : rc.getFbList()) { Expression leftExpr = binding.getLeftExpr(); // We only need to deal with the case that the left expression (for a field name) is // a string literal. Otherwise, it is different from a column alias in a projection // (e.g., foo.name AS name) in regular SQL SELECT. if (leftExpr.getKind() != Kind.LITERAL_EXPRESSION) { continue; } LiteralExpr literalExpr = (LiteralExpr) leftExpr; if (literalExpr.getValue().getLiteralType() == Literal.Type.STRING) { String fieldName = SqlppVariableUtil.toInternalVariableName(literalExpr.getValue().getStringValue()); exprMap.put(new VariableExpr(new VarIdentifier(fieldName)), ColumnAliasBinding.of(binding)); } } return exprMap; }
@Override public Void visit(LiteralExpr l, Integer step) { Literal lc = l.getValue(); if (lc.getLiteralType().equals(Literal.Type.TRUE) || lc.getLiteralType().equals(Literal.Type.FALSE) || lc.getLiteralType().equals(Literal.Type.NULL) || lc.getLiteralType().equals(Literal.Type.MISSING)) { out.print(lc.getLiteralType().toString().toLowerCase()); } else if (lc.getLiteralType().equals(Literal.Type.STRING)) { out.print(revertStringToLiteral(lc.getStringValue())); } else { if (lc.getLiteralType().equals(Literal.Type.FLOAT)) { out.printf("%ff", lc.getValue()); } else if (lc.getLiteralType().equals(Literal.Type.DOUBLE)) { DecimalFormat df = new DecimalFormat("#.#"); df.setMinimumFractionDigits(1); df.setMaximumFractionDigits(16); out.print(df.format(lc.getValue())); } else { out.print(lc.getStringValue()); } } return null; }
@Override public Void visit(CallExpr callExpr, Integer step) throws CompilationException { FunctionSignature signature = callExpr.getFunctionSignature(); if (signature.getNamespace() != null && signature.getNamespace().equals("Metadata") && signature.getName().equals("dataset") && signature.getArity() == 1) { LiteralExpr expr = (LiteralExpr) callExpr.getExprList().get(0); out.print(normalize(expr.getValue().getStringValue())); } else { printHints(callExpr.getHints(), step); out.print(generateFullName(callExpr.getFunctionSignature().getNamespace(), callExpr.getFunctionSignature().getName()) + "("); printDelimitedExpressions(callExpr.getExprList(), COMMA, step); out.print(")"); } return null; }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(LiteralExpr l, Mutable<ILogicalOperator> tupSource) { SourceLocation sourceLoc = l.getSourceLocation(); LogicalVariable var = context.newVar(); AsterixConstantValue cValue = new AsterixConstantValue(ConstantHelper.objectFromLiteral(l.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(sourceLoc); AssignOperator a = new AssignOperator(var, new MutableObject<>(cExpr)); a.setSourceLocation(sourceLoc); if (tupSource != null) { a.getInputs().add(tupSource); } return new Pair<>(a, var); }
switch (itemExpr.getKind()) { case LITERAL_EXPRESSION: inValue = ConstantHelper.objectFromLiteral(((LiteralExpr) itemExpr).getValue()); break; case VARIABLE_EXPRESSION:
private static IAdmNode toNode(LiteralExpr literalExpr) throws CompilationException { final Literal value = literalExpr.getValue(); final Literal.Type literalType = value.getLiteralType(); switch (literalType) { case DOUBLE: return new AdmDoubleNode(((DoubleLiteral) value).getDoubleValue()); case FALSE: case TRUE: return AdmBooleanNode.get((Boolean) value.getValue()); case LONG: return new AdmBigIntNode(((LongIntegerLiteral) value).getLongValue()); case NULL: return AdmNullNode.INSTANCE; case STRING: return new AdmStringNode(((StringLiteral) value).getValue()); default: throw new CompilationException(ErrorCode.LITERAL_TYPE_NOT_SUPPORTED_IN_CONSTANT_RECORD, literalType); } }
if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION) Literal lit = ((LiteralExpr)expr).getValue(); if(lit.getLiteralType() != Literal.Type.INTEGER && lit.getLiteralType() != Literal.Type.LONG) {
if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION) Literal lit = ((LiteralExpr)expr).getValue(); if(lit.getLiteralType() != Literal.Type.INTEGER && lit.getLiteralType() != Literal.Type.LONG) {
private static IAdmNode parseLiteral(LiteralExpr objectExpr) throws HyracksDataException { Literal value = objectExpr.getValue(); switch (value.getLiteralType()) { case DOUBLE: case FLOAT: return new AdmDoubleNode((Double) value.getValue()); case TRUE: return AdmBooleanNode.TRUE; case FALSE: return AdmBooleanNode.FALSE; case INTEGER: return new AdmBigIntNode((Integer) value.getValue()); case LONG: return new AdmBigIntNode((Long) value.getValue()); case NULL: return AdmNullNode.INSTANCE; case STRING: return new AdmStringNode((String) value.getValue()); default: throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "Unknown Literal Type %1$s", value.getLiteralType()); } }
LiteralExpr val = (LiteralExpr) expr; AsterixConstantValue cValue = new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(expr.getSourceLocation());
if (argumentExpression1.getKind() == Expression.Kind.LITERAL_EXPRESSION) Literal lit = ((LiteralExpr)argumentExpression1).getValue(); if (lit.getLiteralType() != Literal.Type.INTEGER && lit.getLiteralType() != Literal.Type.LONG) { argumentExpression2 = Expression(); if (argumentExpression2.getKind() == Expression.Kind.LITERAL_EXPRESSION) { Literal lit = ((LiteralExpr)argumentExpression2).getValue(); if (lit.getLiteralType() != Literal.Type.INTEGER && lit.getLiteralType() != Literal.Type.LONG) {
LiteralExpr val = (LiteralExpr) expr; AsterixConstantValue cValue = new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(sourceLoc);
ISerializerDeserializer serde; Literal l = ((LiteralExpr) item).getValue(); try { switch (l.getLiteralType()) {