public NamedTableNode namedTable(String alias, TableName name, List<ColumnDef> dyn_columns, LiteralParseNode tableSampleNode) { Double tableSamplingRate; if(tableSampleNode==null||tableSampleNode.getValue()==null){ tableSamplingRate=ConcreteTableNode.DEFAULT_TABLE_SAMPLING_RATE; }else if(tableSampleNode.getValue() instanceof Integer){ tableSamplingRate=(double)((int)tableSampleNode.getValue()); }else{ tableSamplingRate=((BigDecimal) tableSampleNode.getValue()).doubleValue(); } return new NamedTableNode(alias, name, dyn_columns, tableSamplingRate); }
@Override public Expression visit(LiteralParseNode node) throws SQLException { return LiteralExpression.newConstant(node.getValue(), node.getType(), Determinism.ALWAYS); }
@Override public Void visit(LiteralParseNode node) throws SQLException { Object offsetValue = node.getValue(); if (offsetValue != null) { Integer offset = (Integer)OFFSET_DATUM.getDataType().toObject(offsetValue, node.getType()); if (offset.intValue() >= 0) { this.offset = offset; } } return null; }
@Override public Void visit(LiteralParseNode node) throws SQLException { Object limitValue = node.getValue(); // If limit is null, leave this.limit set to zero // This means that we've bound limit to null for the purpose of // collecting parameter metadata. if (limitValue != null) { Integer limit = (Integer)LIMIT_DATUM.getDataType().toObject(limitValue, node.getType()); if (limit.intValue() >= 0) { // TODO: handle LIMIT 0 this.limit = limit; } } return null; }
@Override public MutationState execute() throws SQLException { String dynamicJarsDir = stmt.getConnection().getQueryServices().getProps().get(QueryServices.DYNAMIC_JARS_DIR_KEY); if(dynamicJarsDir == null) { throw new SQLException(QueryServices.DYNAMIC_JARS_DIR_KEY+" is not configured for placing the jars."); } dynamicJarsDir = dynamicJarsDir.endsWith("/") ? dynamicJarsDir : dynamicJarsDir + '/'; Configuration conf = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); Path dynamicJarsDirPath = new Path(dynamicJarsDir); for (LiteralParseNode jarPath : getJarPaths()) { String jarPathStr = (String)jarPath.getValue(); if(!jarPathStr.endsWith(".jar")) { throw new SQLException(jarPathStr + " is not a valid jar file path."); } } try { FileSystem fs = dynamicJarsDirPath.getFileSystem(conf); List<LiteralParseNode> jarPaths = getJarPaths(); for (LiteralParseNode jarPath : jarPaths) { File f = new File((String) jarPath.getValue()); fs.copyFromLocalFile(new Path(f.getAbsolutePath()), new Path( dynamicJarsDir + f.getName())); } } catch(IOException e) { throw new SQLException(e); } return new MutationState(0, 0, context.getConnection()); } };
@Override public MutationState execute() throws SQLException { String dynamicJarsDir = stmt.getConnection().getQueryServices().getProps().get(QueryServices.DYNAMIC_JARS_DIR_KEY); if (dynamicJarsDir == null) { throw new SQLException(QueryServices.DYNAMIC_JARS_DIR_KEY + " is not configured."); } dynamicJarsDir = dynamicJarsDir.endsWith("/") ? dynamicJarsDir : dynamicJarsDir + '/'; Configuration conf = HBaseFactoryProvider.getConfigurationFactory().getConfiguration(); Path dynamicJarsDirPath = new Path(dynamicJarsDir); try { FileSystem fs = dynamicJarsDirPath.getFileSystem(conf); String jarPathStr = (String)getJarPath().getValue(); if(!jarPathStr.endsWith(".jar")) { throw new SQLException(jarPathStr + " is not a valid jar file path."); } Path p = new Path(jarPathStr); if(fs.exists(p)) { fs.delete(p, false); } } catch(IOException e) { throw new SQLException(e); } return new MutationState(0, 0, context.getConnection()); } };
public LiteralParseNode coerce(LiteralParseNode literalNode, PDataType expectedType) throws SQLException { PDataType actualType = literalNode.getType(); if (actualType != null) { Object before = literalNode.getValue(); checkTypeMatch(expectedType, actualType); Object after = expectedType.toObject(before, actualType); if (before != after) { literalNode = literal(after); } } return literalNode; }
@Override public Expression visit(LiteralParseNode node) throws SQLException { if (isTopLevel()) { return LiteralExpression.newConstant(node.getValue(), column.getDataType(), column.getSortOrder(), Determinism.ALWAYS); } return super.visit(node); } }
private LiteralExpression getExpFromConstant(String strValue) { LiteralExpression exp = null; if (strValue.length() > 0) { SQLParser parser = new SQLParser(strValue); try { LiteralParseNode node = parser.parseLiteral(); LiteralExpression defaultValue = LiteralExpression.newConstant(node.getValue(), PDataTypeFactory.getInstance().instanceFromClass( allowedTypes[0]), Determinism.ALWAYS); if (this.getAllowedTypes().length > 0) { for (Class<? extends PDataType> type : this.getAllowedTypes()) { if (defaultValue.getDataType() == null || defaultValue.getDataType().isCoercibleTo( PDataTypeFactory.getInstance().instanceFromClass(type), node.getValue())) { return LiteralExpression.newConstant(node.getValue(), PDataTypeFactory.getInstance().instanceFromClass(type), Determinism.ALWAYS); } } throw new IllegalStateException("Unable to coerce default value " + strValue + " to any of the allowed types of " + Arrays.toString(this.getAllowedTypes())); } exp = defaultValue; } catch (SQLException e) { throw new RuntimeException(e); } } return exp; }
state._fsp--; if (state.failed) return ret; if ( state.backtracking==0 ) { ret = l.getValue(); }
factory.literal(listFiles.next().getPath().toString()); LiteralExpression expression = LiteralExpression.newConstant(literal.getValue(), PVarchar.INSTANCE, Determinism.ALWAYS); expression.evaluate(null, ptr);
if ( state.backtracking==0 ) {ret = factory.trace(Tracing.isTraceOn(flag.getText()), s == null ? Tracing.isTraceOn(flag.getText()) ? 1.0 : 0.0 : (((BigDecimal)s.getValue())).doubleValue());}
FunctionArgument arg = new FunctionArgument(type.getString(), isArrayType, isConstant, defaultValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(defaultValue)).getValue()), minValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(minValue)).getValue()), maxValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(maxValue)).getValue()), argPosition); arguments.add(arg);
public NamedTableNode namedTable(String alias, TableName name, List<ColumnDef> dyn_columns, LiteralParseNode tableSampleNode) { Double tableSamplingRate; if(tableSampleNode==null||tableSampleNode.getValue()==null){ tableSamplingRate=ConcreteTableNode.DEFAULT_TABLE_SAMPLING_RATE; }else if(tableSampleNode.getValue() instanceof Integer){ tableSamplingRate=(double)((int)tableSampleNode.getValue()); }else{ tableSamplingRate=((BigDecimal) tableSampleNode.getValue()).doubleValue(); } return new NamedTableNode(alias, name, dyn_columns, tableSamplingRate); }
String maxValue = arg.hasMaxValue()?arg.getMaxValue():null; args.add(new FunctionArgument(argType, isArrayType, isConstant, defaultValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(defaultValue))).getValue()), minValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(minValue))).getValue()), maxValue == null ? null : LiteralExpression.newConstant((new LiteralParseNode(dataType.toObject(maxValue))).getValue())));
factory.literal(traceScope.getSpan().getTraceId()); LiteralExpression expression = LiteralExpression.newConstant(literal.getValue(), PLong.INSTANCE, Determinism.ALWAYS); expression.evaluate(null, ptr);
Expression expression = null; if (parseNode instanceof LiteralParseNode && ((LiteralParseNode)parseNode).getType() == PInteger.INSTANCE){ Integer index = (Integer)((LiteralParseNode)parseNode).getValue(); int size = rowProjector.getColumnProjectors().size(); if (index > size || index <= 0 ) {
@Override public Void visit(LiteralParseNode node) throws SQLException { Object offsetValue = node.getValue(); if (offsetValue != null) { Integer offset = (Integer)OFFSET_DATUM.getDataType().toObject(offsetValue, node.getType()); if (offset.intValue() >= 0) { this.offset = offset; } } return null; }