@Override protected Void visitBooleanLiteral(BooleanLiteral node, Integer indentLevel) { print(indentLevel, "Boolean[" + node.getValue() + "]"); return null; }
@Override protected Object visitBooleanLiteral(BooleanLiteral node, Object context) { return node.equals(BooleanLiteral.TRUE_LITERAL); }
@Override public Node visitBooleanValue(SqlBaseParser.BooleanValueContext context) { return new BooleanLiteral(getLocation(context), context.getText()); }
@Override public Node visitBooleanValue(SqlBaseParser.BooleanValueContext context) { return new BooleanLiteral(getLocation(context), context.getText()); }
@Override protected Void visitBooleanLiteral(BooleanLiteral node, Integer indentLevel) { print(indentLevel, "Boolean[" + node.getValue() + "]"); return null; }
private static Expression toExpression(Object value) throws PrestoException { if (value instanceof String) { return new StringLiteral(value.toString()); } if (value instanceof Boolean) { return new BooleanLiteral(value.toString()); } if (value instanceof Long || value instanceof Integer) { return new LongLiteral(value.toString()); } if (value instanceof Double) { return new DoubleLiteral(value.toString()); } if (value instanceof List) { List<?> list = (List<?>) value; return new ArrayConstructor(list.stream() .map(Visitor::toExpression) .collect(toList())); } throw new PrestoException(INVALID_TABLE_PROPERTY, format("Failed to convert object of type %s to expression: %s", value.getClass().getName(), value)); }
@Override protected Object visitBooleanLiteral(BooleanLiteral node, Object context) { return node.equals(BooleanLiteral.TRUE_LITERAL); }
@Override protected Object visitBooleanLiteral(BooleanLiteral node, ConnectorSession session) { return node.getValue(); }
private static Expression booleanConstant(@Nullable Boolean value) { if (value == null) { return new Cast(new NullLiteral(), BOOLEAN.toString()); } return new BooleanLiteral(value.toString()); }
private JoinEnumerationResult getJoinSource(LinkedHashSet<PlanNode> nodes, List<Symbol> outputSymbols) { if (nodes.size() == 1) { PlanNode planNode = getOnlyElement(nodes); ImmutableList.Builder<Expression> predicates = ImmutableList.builder(); predicates.addAll(allFilterInference.generateEqualitiesPartitionedBy(outputSymbols::contains).getScopeEqualities()); stream(nonInferrableConjuncts(allFilter)) .map(conjunct -> allFilterInference.rewriteExpression(conjunct, outputSymbols::contains)) .filter(Objects::nonNull) .forEach(predicates::add); Expression filter = combineConjuncts(predicates.build()); if (!TRUE_LITERAL.equals(filter)) { planNode = new FilterNode(idAllocator.getNextId(), planNode, filter); } return createJoinEnumerationResult(planNode); } return chooseJoinOrder(nodes, outputSymbols); }
@Override protected Object visitBooleanLiteral(BooleanLiteral node, ConnectorSession session) { return node.getValue(); }
private static Expression booleanConstant(@Nullable Boolean value) { if (value == null) { return new Cast(new NullLiteral(), BOOLEAN.toString()); } return new BooleanLiteral(value.toString()); }
private JoinEnumerationResult getJoinSource(LinkedHashSet<PlanNode> nodes, List<Symbol> outputSymbols) { if (nodes.size() == 1) { PlanNode planNode = getOnlyElement(nodes); ImmutableList.Builder<Expression> predicates = ImmutableList.builder(); predicates.addAll(allFilterInference.generateEqualitiesPartitionedBy(outputSymbols::contains).getScopeEqualities()); stream(nonInferrableConjuncts(allFilter)) .map(conjunct -> allFilterInference.rewriteExpression(conjunct, outputSymbols::contains)) .filter(Objects::nonNull) .forEach(predicates::add); Expression filter = combineConjuncts(predicates.build()); if (!TRUE_LITERAL.equals(filter)) { planNode = new FilterNode(idAllocator.getNextId(), planNode, filter); } return createJoinEnumerationResult(planNode); } return chooseJoinOrder(nodes, outputSymbols); }
@Override protected String visitBooleanLiteral(BooleanLiteral node, Void context) { return String.valueOf(node.getValue()); }
private static Expression toExpression(Object value) throws PrestoException { if (value instanceof String) { return new StringLiteral(value.toString()); } if (value instanceof Boolean) { return new BooleanLiteral(value.toString()); } if (value instanceof Long || value instanceof Integer) { return new LongLiteral(value.toString()); } if (value instanceof Double) { return new DoubleLiteral(value.toString()); } if (value instanceof List) { List<?> list = (List<?>) value; return new ArrayConstructor(list.stream() .map(Visitor::toExpression) .collect(toList())); } throw new PrestoException(INVALID_TABLE_PROPERTY, format("Failed to convert object of type %s to expression: %s", value.getClass().getName(), value)); }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<Expression> context) { Expression predicate = simplifyExpression(context.get()); if (!TRUE_LITERAL.equals(predicate)) { return new FilterNode(idAllocator.getNextId(), node, predicate); } return node; }
@Override protected String visitBooleanLiteral(BooleanLiteral node, Void context) { return String.valueOf(node.getValue()); }
private static Row createDescribeOutputRow(Field field, Analysis analysis) { LongLiteral typeSize = new LongLiteral("0"); if (field.getType() instanceof FixedWidthType) { typeSize = new LongLiteral(String.valueOf(((FixedWidthType) field.getType()).getFixedSize())); } String columnName; if (field.getName().isPresent()) { columnName = field.getName().get(); } else { int columnIndex = ImmutableList.copyOf(analysis.getOutputDescriptor().getVisibleFields()).indexOf(field); columnName = "_col" + columnIndex; } Optional<QualifiedObjectName> originTable = field.getOriginTable(); return row( new StringLiteral(columnName), new StringLiteral(originTable.map(QualifiedObjectName::getCatalogName).orElse("")), new StringLiteral(originTable.map(QualifiedObjectName::getSchemaName).orElse("")), new StringLiteral(originTable.map(QualifiedObjectName::getObjectName).orElse("")), new StringLiteral(field.getType().getDisplayName()), typeSize, new BooleanLiteral(String.valueOf(field.isAliased()))); }
@Override public PlanNode visitTableScan(TableScanNode node, RewriteContext<Expression> context) { Expression predicate = simplifyExpression(context.get()); if (!TRUE_LITERAL.equals(predicate)) { return new FilterNode(idAllocator.getNextId(), node, predicate); } return node; }
@Override protected RowExpression visitBooleanLiteral(BooleanLiteral node, Void context) { return constant(node.getValue(), BOOLEAN); }