Package com.facebook.presto.sql.tree

Examples of com.facebook.presto.sql.tree.StringLiteral


        private Regex getConstantPattern(LikePredicate node)
        {
            Regex result = likePatternCache.get(node);

            if (result == null) {
                StringLiteral pattern = (StringLiteral) node.getPattern();
                StringLiteral escape = (StringLiteral) node.getEscape();

                if (escape == null) {
                    result = LikeFunctions.likePattern(pattern.getSlice());
                }
                else {
                    result = LikeFunctions.likePattern(pattern.getSlice(), escape.getSlice());
                }

                likePatternCache.put(node, result);
            }
View Full Code Here


            }
        }

        if (type.equals(VARCHAR)) {
            if (object instanceof Slice) {
                return new StringLiteral(((Slice) object).toString(UTF_8));
            }

            if (object instanceof String) {
                return new StringLiteral((String) object);
            }
        }

        if (type.equals(BOOLEAN)) {
            return new BooleanLiteral(object.toString());
View Full Code Here

            schemaName = schema.getSuffix();
        }

        // TODO: throw SemanticException if schema does not exist

        Expression predicate = equal(nameReference("table_schema"), new StringLiteral(schemaName));

        String likePattern = showTables.getLikePattern();
        if (likePattern != null) {
            Expression likePredicate = new LikePredicate(nameReference("table_name"), new StringLiteral(likePattern), null);
            predicate = logicalAnd(predicate, likePredicate);
        }

        Query query = new Query(
                Optional.<With>absent(),
View Full Code Here

                                aliasedYesNoToBoolean("is_nullable", "Null"),
                                aliasedYesNoToBoolean("is_partition_key", "Partition Key"),
                                aliasedNullToEmpty("comment", "Comment")),
                        table(QualifiedName.of(tableName.getCatalogName(), TABLE_COLUMNS.getSchemaName(), TABLE_COLUMNS.getTableName())),
                        Optional.of(logicalAnd(
                                equal(nameReference("table_schema"), new StringLiteral(tableName.getSchemaName())),
                                equal(nameReference("table_name"), new StringLiteral(tableName.getTableName())))),
                        ImmutableList.<Expression>of(),
                        Optional.<Expression>absent(),
                        ImmutableList.of(ascending("ordinal_position")),
                        Optional.<String>absent()
                ),
View Full Code Here

    }

    private static SelectItem aliasedYesNoToBoolean(String column, String alias)
    {
        Expression expression = new IfExpression(
                equal(nameReference(column), new StringLiteral("YES")),
                BooleanLiteral.TRUE_LITERAL,
                BooleanLiteral.FALSE_LITERAL);
        return new SingleColumn(expression, alias);
    }
View Full Code Here

        return new SingleColumn(expression, alias);
    }

    private static SelectItem aliasedNullToEmpty(String column, String alias)
    {
        return new SingleColumn(new CoalesceExpression(nameReference(column), new StringLiteral("")), alias);
    }
View Full Code Here

        selectList.add(unaliasedName("partition_number"));
        for (ColumnMetadata column : metadata.getTableMetadata(tableHandle.get()).getColumns()) {
            if (!column.isPartitionKey()) {
                continue;
            }
            Expression key = equal(nameReference("partition_key"), new StringLiteral(column.getName()));
            Expression value = caseWhen(key, nameReference("partition_value"));
            value = new Cast(value, column.getType().getName());
            Expression function = functionCall("max", value);
            selectList.add(new SingleColumn(function, column.getName()));
            wrappedList.add(unaliasedName(column.getName()));
        }

        Query query = new Query(
                Optional.<With>absent(),
                new QuerySpecification(
                        selectAll(selectList.build()),
                        table(QualifiedName.of(table.getCatalogName(), TABLE_INTERNAL_PARTITIONS.getSchemaName(), TABLE_INTERNAL_PARTITIONS.getTableName())),
                        Optional.of(logicalAnd(
                                equal(nameReference("table_schema"), new StringLiteral(table.getSchemaName())),
                                equal(nameReference("table_name"), new StringLiteral(table.getTableName())))),
                        ImmutableList.of(nameReference("partition_number")),
                        Optional.<Expression>absent(),
                        ImmutableList.<SortItem>of(),
                        Optional.<String>absent()),
                ImmutableList.<SortItem>of(),
View Full Code Here

        Query query = new Query(
                Optional.<With>absent(),
                new QuerySpecification(
                        selectList(new AllColumns()),
                        ImmutableList.of(aliased(
                                values(row(new StringLiteral((queryPlan)))),
                                "plan",
                                ImmutableList.of("Query Plan")
                        )),
                        Optional.<Expression>absent(),
                        ImmutableList.<Expression>of(),
View Full Code Here

        private Regex getConstantPattern(LikePredicate node)
        {
            Regex result = likePatternCache.get(node);

            if (result == null) {
                StringLiteral pattern = (StringLiteral) node.getPattern();
                StringLiteral escape = (StringLiteral) node.getEscape();

                result = LikeUtils.likeToPattern(pattern.getSlice(), escape == null ? null : escape.getSlice());

                likePatternCache.put(node, result);
            }

            return result;
View Full Code Here

            throws Exception
    {
        assertExpression("ARRAY []", new ArrayConstructor(ImmutableList.<Expression>of()));
        assertExpression("ARRAY [1, 2]", new ArrayConstructor(ImmutableList.<Expression>of(new LongLiteral("1"), new LongLiteral("2"))));
        assertExpression("ARRAY [1.0, 2.5]", new ArrayConstructor(ImmutableList.<Expression>of(new DoubleLiteral("1.0"), new DoubleLiteral("2.5"))));
        assertExpression("ARRAY ['hi']", new ArrayConstructor(ImmutableList.<Expression>of(new StringLiteral("hi"))));
        assertExpression("ARRAY ['hi', 'hello']", new ArrayConstructor(ImmutableList.<Expression>of(new StringLiteral("hi"), new StringLiteral("hello"))));
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.sql.tree.StringLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.