public StatementContext(PhoenixStatement statement, ColumnResolver resolver, Scan scan, SequenceManager seqManager, boolean isRequestMetricsEnabled) { this.statement = statement; this.resolver = resolver; this.scan = scan; this.sequences = seqManager; this.binds = new BindManager(statement.getParameters()); this.aggregates = new AggregationManager(); this.expressions = new ExpressionManager(); PhoenixConnection connection = statement.getConnection(); ReadOnlyProps props = connection.getQueryServices().getProps(); String timeZoneID = props.get(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, DateUtil.DEFAULT_TIME_ZONE_ID); this.dateFormat = props.get(QueryServices.DATE_FORMAT_ATTRIB, DateUtil.DEFAULT_DATE_FORMAT); this.dateFormatter = DateUtil.getDateFormatter(dateFormat, timeZoneID); this.timeFormat = props.get(QueryServices.TIME_FORMAT_ATTRIB, DateUtil.DEFAULT_TIME_FORMAT); this.timeFormatter = DateUtil.getTimeFormatter(timeFormat, timeZoneID); this.timestampFormat = props.get(QueryServices.TIMESTAMP_FORMAT_ATTRIB, DateUtil.DEFAULT_TIMESTAMP_FORMAT); this.timestampFormatter = DateUtil.getTimestampFormatter(timestampFormat, timeZoneID); this.dateFormatTimeZone = DateUtil.getTimeZone(timeZoneID); this.numberFormat = props.get(QueryServices.NUMBER_FORMAT_ATTRIB, NumberUtil.DEFAULT_NUMBER_FORMAT); this.tempPtr = new ImmutableBytesWritable(); this.currentTable = resolver != null && !resolver.getTables().isEmpty() ? resolver.getTables().get(0) : null; this.whereConditionColumns = new ArrayList<Pair<byte[], byte[]>>(); this.dataColumns = this.currentTable == null ? Collections.<PColumn, Integer> emptyMap() : Maps .<PColumn, Integer> newLinkedHashMap(); this.subqueryResults = Maps.<SelectStatement, Object> newHashMap(); this.readMetricsQueue = new ReadMetricQueue(isRequestMetricsEnabled,connection.getLogLevel()); this.overAllQueryMetrics = new OverAllQueryMetrics(isRequestMetricsEnabled,connection.getLogLevel()); this.retryingPersistentCache = Maps.<Long, Boolean> newHashMap(); }
private void addBindParamMetaData(ParseNode lhsNode, ParseNode rhsNode, Expression lhsExpr, Expression rhsExpr) throws SQLException { if (lhsNode instanceof BindParseNode) { context.getBindManager().addParamMetaData((BindParseNode)lhsNode, rhsExpr); } if (rhsNode instanceof BindParseNode) { context.getBindManager().addParamMetaData((BindParseNode)rhsNode, lhsExpr); } }
@Override public Void visit(BindParseNode node) throws SQLException { // This is for static evaluation in SubselectRewriter. if (context == null) return null; Object value = context.getBindManager().getBindValue(node); context.getBindManager().addParamMetaData(node, LIMIT_DATUM); // Resolve the bind value, create a LiteralParseNode, and call the visit method for it. // In this way, we can deal with just having a literal on one side of the expression. visit(NODE_FACTORY.literal(value, LIMIT_DATUM.getDataType())); return null; }
public LiteralResultIterationPlan(Iterable<Tuple> tuples, StatementContext context, FilterableStatement statement, TableRef tableRef, RowProjector projection, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory) throws SQLException { super(context, statement, tableRef, projection, context.getBindManager().getParameterMetaData(), limit, offset, orderBy, GroupBy.EMPTY_GROUP_BY, parallelIteratorFactory, null, null); this.tuples = tuples; }
@Override public Expression visit(BindParseNode node) throws SQLException { Object value = context.getBindManager().getBindValue(node); return LiteralExpression.newConstant(value, Determinism.ALWAYS); }
@Override public ParameterMetaData getParameterMetaData() { return context.getBindManager().getParameterMetaData(); }
@Override public Expression visit(BindParseNode node) throws SQLException { Object value = context.getBindManager().getBindValue(node); return LiteralExpression.newConstant(value, Determinism.ALWAYS); }
@Override public Expression visitLeave(IsNullParseNode node, List<Expression> children) throws SQLException { ParseNode childNode = node.getChildren().get(0); Expression child = children.get(0); if (childNode instanceof BindParseNode) { // TODO: valid/possibe? context.getBindManager().addParamMetaData((BindParseNode)childNode, child); } return wrapGroupByExpression(IsNullExpression.create(child, node.isNegate(), context.getTempPtr())); }
@Override public ParameterMetaData getParameterMetaData() { return context.getBindManager().getParameterMetaData(); }
@Override public Void visit(BindParseNode node) throws SQLException { // This is for static evaluation in SubselectRewriter. if (context == null) return null; Object value = context.getBindManager().getBindValue(node); context.getBindManager().addParamMetaData(node, OFFSET_DATUM); // Resolve the bind value, create a LiteralParseNode, and call the // visit method for it. // In this way, we can deal with just having a literal on one side // of the expression. visit(NODE_FACTORY.literal(value, OFFSET_DATUM.getDataType())); return null; }
@Override public Expression visit(BindParseNode node) throws SQLException { Object value = context.getBindManager().getBindValue(node); return LiteralExpression.newConstant(value, Determinism.ALWAYS); }
this.scan = scan; this.sequences = seqManager; this.binds = new BindManager(statement.getParameters()); this.aggregates = new AggregationManager(); this.expressions = new ExpressionManager();
@Override public Expression visitLeave(CaseParseNode node, List<Expression> l) throws SQLException { final Expression caseExpression = CaseExpression.create(l); for (int i = 0; i < node.getChildren().size(); i+=2) { ParseNode childNode = node.getChildren().get(i); if (childNode instanceof BindParseNode) { context.getBindManager().addParamMetaData((BindParseNode)childNode, new DelegateDatum(caseExpression)); } } return wrapGroupByExpression(caseExpression); }
@Override public ParameterMetaData getParameterMetaData() { return context.getBindManager().getParameterMetaData(); }
@Override public Expression visit(BindParseNode node) throws SQLException { if (isTopLevel()) { context.getBindManager().addParamMetaData(node, column); Object value = context.getBindManager().getBindValue(node); return LiteralExpression.newConstant(value, column.getDataType(), column.getSortOrder(), Determinism.ALWAYS); } return super.visit(node); }
public StatementContext(PhoenixStatement statement, ColumnResolver resolver, Scan scan, SequenceManager seqManager, boolean isRequestMetricsEnabled) { this.statement = statement; this.resolver = resolver; this.scan = scan; this.sequences = seqManager; this.binds = new BindManager(statement.getParameters()); this.aggregates = new AggregationManager(); this.expressions = new ExpressionManager(); PhoenixConnection connection = statement.getConnection(); ReadOnlyProps props = connection.getQueryServices().getProps(); this.dateFormat = props.get(QueryServices.DATE_FORMAT_ATTRIB, DateUtil.DEFAULT_DATE_FORMAT); this.dateFormatter = DateUtil.getDateFormatter(dateFormat); this.timeFormat = props.get(QueryServices.TIME_FORMAT_ATTRIB, DateUtil.DEFAULT_TIME_FORMAT); this.timeFormatter = DateUtil.getTimeFormatter(timeFormat); this.timestampFormat = props.get(QueryServices.TIMESTAMP_FORMAT_ATTRIB, DateUtil.DEFAULT_TIMESTAMP_FORMAT); this.timestampFormatter = DateUtil.getTimestampFormatter(timestampFormat); this.dateFormatTimeZone = DateUtil.getTimeZone(props.get(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, DateUtil.DEFAULT_TIME_ZONE_ID)); this.numberFormat = props.get(QueryServices.NUMBER_FORMAT_ATTRIB, NumberUtil.DEFAULT_NUMBER_FORMAT); this.tempPtr = new ImmutableBytesWritable(); this.currentTable = resolver != null && !resolver.getTables().isEmpty() ? resolver.getTables().get(0) : null; this.whereConditionColumns = new ArrayList<Pair<byte[], byte[]>>(); this.dataColumns = this.currentTable == null ? Collections.<PColumn, Integer> emptyMap() : Maps .<PColumn, Integer> newLinkedHashMap(); this.subqueryResults = Maps.<SelectStatement, Object> newHashMap(); this.readMetricsQueue = new ReadMetricQueue(isRequestMetricsEnabled,connection.getLogLevel()); this.overAllQueryMetrics = new OverAllQueryMetrics(isRequestMetricsEnabled,connection.getLogLevel()); }
@Override public Expression visitLeave(InListParseNode node, List<Expression> l) throws SQLException { List<Expression> inChildren = l; Expression firstChild = inChildren.get(0); ImmutableBytesWritable ptr = context.getTempPtr(); PDataType firstChildType = firstChild.getDataType(); ParseNode firstChildNode = node.getChildren().get(0); if (firstChildNode instanceof BindParseNode) { PDatum datum = firstChild; if (firstChildType == null) { datum = inferBindDatum(inChildren); } context.getBindManager().addParamMetaData((BindParseNode)firstChildNode, datum); } for (int i = 1; i < l.size(); i++) { ParseNode childNode = node.getChildren().get(i); if (childNode instanceof BindParseNode) { context.getBindManager().addParamMetaData((BindParseNode)childNode, firstChild); } } return wrapGroupByExpression(InListExpression.create(inChildren, node.isNegate(), ptr, context.getCurrentTable().getTable().rowKeyOrderOptimizable())); }
@Override public ParameterMetaData getParameterMetaData() { return context.getBindManager().getParameterMetaData(); }
@Override public Void visit(BindParseNode node) throws SQLException { // This is for static evaluation in SubselectRewriter. if (context == null) return null; Object value = context.getBindManager().getBindValue(node); context.getBindManager().addParamMetaData(node, LIMIT_DATUM); // Resolve the bind value, create a LiteralParseNode, and call the visit method for it. // In this way, we can deal with just having a literal on one side of the expression. visit(NODE_FACTORY.literal(value, LIMIT_DATUM.getDataType())); return null; }
@Override public Expression visitLeave(NotParseNode node, List<Expression> children) throws SQLException { ParseNode childNode = node.getChildren().get(0); Expression child = children.get(0); if (!PBoolean.INSTANCE.isCoercibleTo(child.getDataType())) { throw TypeMismatchException.newException(PBoolean.INSTANCE, child.getDataType(), node.toString()); } if (childNode instanceof BindParseNode) { // TODO: valid/possibe? context.getBindManager().addParamMetaData((BindParseNode)childNode, child); } return wrapGroupByExpression(NotExpression.create(child, context.getTempPtr())); }