public static LogicalExpression getNumericExpression(String sign, String s, ExpressionPosition ep) { String numStr = (sign == null) ? s : sign+s; try { int a = Integer.parseInt(numStr); return new IntExpression(a, ep); } catch (Exception e) { } try { long l = Long.parseLong(numStr); return new LongExpression(l, ep); } catch (Exception e) { } try { double d = Double.parseDouble(numStr); return new DoubleExpression(d, ep); } catch (Exception e) { } throw new IllegalArgumentException(String.format("Unable to parse string %s as integer or floating point number.", numStr)); }
public static LogicalExpression getNumericExpression(String sign, String s, ExpressionPosition ep) { String numStr = (sign == null) ? s : sign+s; try { int a = Integer.parseInt(numStr); return new IntExpression(a, ep); } catch (Exception e) { } try { long l = Long.parseLong(numStr); return new LongExpression(l, ep); } catch (Exception e) { } try { double d = Double.parseDouble(numStr); return new DoubleExpression(d, ep); } catch (Exception e) { } throw new IllegalArgumentException(String.format("Unable to parse string %s as integer or floating point number.", numStr)); }
public static LogicalExpression toDrill(AggregateCall call, List<String> fn, DrillImplementor implementor) { List<LogicalExpression> args = Lists.newArrayList(); for(Integer i : call.getArgList()) { args.add(new FieldReference(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1L)); } return FunctionCallFactory.createExpression(call.getAggregation().getName().toLowerCase(), ExpressionPosition.UNKNOWN, args); }
newArgs.add(new ValueExpressions.IntExpression(type.getScale(), null)); } else if (!Types.isFixedWidthType(type)) { //VarLen type newArgs.add(new ValueExpressions.LongExpression(type.getPrecision(), null));
castArgs.add(new ValueExpressions.LongExpression(Types.MAX_VARCHAR_LENGTH, null));
private List<NamedExpression> getExpressionList() { if (popConfig.getExprs() != null) { return popConfig.getExprs(); } final List<NamedExpression> exprs = Lists.newArrayList(); for (final MaterializedField field : incoming.getSchema()) { String fieldName = field.getName(); if (Types.isComplex(field.getType()) || Types.isRepeated(field.getType())) { final LogicalExpression convertToJson = FunctionCallFactory.createConvert(ConvertExpression.CONVERT_TO, "JSON", SchemaPath.getSimplePath(fieldName), ExpressionPosition.UNKNOWN); final String castFuncName = FunctionReplacementUtils.getCastFunc(MinorType.VARCHAR); final List<LogicalExpression> castArgs = Lists.newArrayList(); castArgs.add(convertToJson); //input_expr // implicitly casting to varchar, since we don't know actual source length, cast to undefined length, which will preserve source length castArgs.add(new ValueExpressions.LongExpression(Types.MAX_VARCHAR_LENGTH, null)); final FunctionCall castCall = new FunctionCall(castFuncName, castArgs, ExpressionPosition.UNKNOWN); exprs.add(new NamedExpression(castCall, new FieldReference(fieldName))); } else { exprs.add(new NamedExpression(SchemaPath.getSimplePath(fieldName), new FieldReference(fieldName))); } } return exprs; }
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { DrillParseContext context = new DrillParseContext(PrelUtil.getSettings(getCluster())); List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { final int indexInConstants = i - fn.size(); if (i < fn.size()) { args.add(new FieldReference(fn.get(i))); } else { final RexLiteral constant = constants.get(indexInConstants); LogicalExpression expr = DrillOptiq.toDrill(context, getInput(), constant); args.add(expr); } } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1l)); } return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); }
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { args.add(new FieldReference(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1l)); } LogicalExpression expr = new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); return expr; } }
public static LogicalExpression getBigInt(long l){ return new LongExpression(l); }
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { args.add(FieldReference.getWithQuotedRef(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1L)); } return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); }
public static LogicalExpression getBigInt(long l){ return new LongExpression(l); }