当前位置: 首页>>代码示例>>Java>>正文


Java QualifiedName类代码示例

本文整理汇总了Java中com.facebook.presto.sql.tree.QualifiedName的典型用法代码示例。如果您正苦于以下问题:Java QualifiedName类的具体用法?Java QualifiedName怎么用?Java QualifiedName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QualifiedName类属于com.facebook.presto.sql.tree包,在下文中一共展示了QualifiedName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitArithmeticExpression

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Override
protected String visitArithmeticExpression(ArithmeticExpression node, Void context)
{
    if (node.getType().equals(ArithmeticExpression.Type.DIVIDE)) {
        if (_outputDivideByZeroGuard == true) {
            if (node.getRight() instanceof FunctionCall) {
                if (getFunctionName((FunctionCall) node.getRight()).equals("nullifzero")) {
                    // bypass appending nullifzero
                    return formatBinaryExpression(node.getType().getValue(), node.getLeft(), node.getRight());
                }
            } else if (node.getRight() instanceof Literal) {
    			// purely literal
    			return formatBinaryExpression(node.getType().getValue(), node.getLeft(), node.getRight());
            }
    
            List<Expression> arguments = new ArrayList<Expression>();
            arguments.add(node.getRight());
            FunctionCall nullifzeroFunc = new FunctionCall(new QualifiedName("nullifzero"), arguments);
            return formatBinaryExpression(node.getType().getValue(), node.getLeft(), nullifzeroFunc);
        } else {
            return formatBinaryExpression(node.getType().getValue(), node.getLeft(), node.getRight());
        }
    } else {
        return formatBinaryExpression(node.getType().getValue(), node.getLeft(), node.getRight());
    }
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:27,代码来源:VeroGenExpFormatter.java

示例2: getWindowFunctionImplementation

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
public WindowFunctionSupplier getWindowFunctionImplementation(Signature signature)
{
    checkArgument(signature.getKind() == WINDOW || signature.getKind() == AGGREGATE, "%s is not a window function", signature);
    checkArgument(signature.getTypeParameterRequirements().isEmpty(), "%s has unbound type parameters", signature);
    Iterable<SqlFunction> candidates = functions.get(QualifiedName.of(signature.getName()));
    // search for exact match
    for (SqlFunction operator : candidates) {
        Type returnType = typeManager.getType(signature.getReturnType());
        List<Type> argumentTypes = resolveTypes(signature.getArgumentTypes(), typeManager);
        Map<String, Type> boundTypeParameters = operator.getSignature().bindTypeParameters(returnType, argumentTypes, false, typeManager);
        if (boundTypeParameters != null) {
            try {
                return specializedWindowCache.getUnchecked(new SpecializedFunctionKey(operator, boundTypeParameters, signature.getArgumentTypes().size()));
            }
            catch (UncheckedExecutionException e) {
                throw Throwables.propagate(e.getCause());
            }
        }
    }
    throw new PrestoException(FUNCTION_IMPLEMENTATION_MISSING, format("%s not found", signature));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:FunctionRegistry.java

示例3: getAggregateFunctionImplementation

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
public InternalAggregationFunction getAggregateFunctionImplementation(Signature signature)
{
    checkArgument(signature.getKind() == AGGREGATE || signature.getKind() == APPROXIMATE_AGGREGATE, "%s is not an aggregate function", signature);
    checkArgument(signature.getTypeParameterRequirements().isEmpty(), "%s has unbound type parameters", signature);
    Iterable<SqlFunction> candidates = functions.get(QualifiedName.of(signature.getName()));
    // search for exact match
    for (SqlFunction operator : candidates) {
        Type returnType = typeManager.getType(signature.getReturnType());
        List<Type> argumentTypes = resolveTypes(signature.getArgumentTypes(), typeManager);
        Map<String, Type> boundTypeParameters = operator.getSignature().bindTypeParameters(returnType, argumentTypes, false, typeManager);
        if (boundTypeParameters != null) {
            try {
                return specializedAggregationCache.getUnchecked(new SpecializedFunctionKey(operator, boundTypeParameters, signature.getArgumentTypes().size()));
            }
            catch (UncheckedExecutionException e) {
                throw Throwables.propagate(e.getCause());
            }
        }
    }
    throw new PrestoException(FUNCTION_IMPLEMENTATION_MISSING, format("%s not found", signature));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:FunctionRegistry.java

示例4: resolveOperator

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
public Signature resolveOperator(OperatorType operatorType, List<? extends Type> argumentTypes)
        throws OperatorNotFoundException
{
    try {
        return resolveFunction(QualifiedName.of(mangleOperatorName(operatorType)), Lists.transform(argumentTypes, Type::getTypeSignature), false);
    }
    catch (PrestoException e) {
        if (e.getErrorCode().getCode() == FUNCTION_NOT_FOUND.toErrorCode().getCode()) {
            throw new OperatorNotFoundException(
                    operatorType,
                    argumentTypes.stream()
                            .map(Type::getTypeSignature)
                            .collect(toImmutableList()));
        }
        else {
            throw e;
        }
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:20,代码来源:FunctionRegistry.java

示例5: FunctionMap

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
public FunctionMap(FunctionMap map, Iterable<? extends SqlFunction> functions)
{
    this.functions = ImmutableListMultimap.<QualifiedName, SqlFunction>builder()
            .putAll(map.functions)
            .putAll(Multimaps.index(functions, function -> QualifiedName.of(function.getSignature().getName())))
            .build();

    // Make sure all functions with the same name are aggregations or none of them are
    for (Map.Entry<QualifiedName, Collection<SqlFunction>> entry : this.functions.asMap().entrySet()) {
        Collection<SqlFunction> values = entry.getValue();
        long aggregations = values.stream()
                .map(function -> function.getSignature().getKind())
                .filter(kind -> kind == AGGREGATE || kind == APPROXIMATE_AGGREGATE)
                .count();
        checkState(aggregations == 0 || aggregations == values.size(), "'%s' is both an aggregation and a scalar function", entry.getKey());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:FunctionRegistry.java

示例6: visitArrayConstructor

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Override
protected Object visitArrayConstructor(ArrayConstructor node, Object context)
{
    Type elementType = ((ArrayType) expressionTypes.get(node)).getElementType();
    BlockBuilder arrayBlockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), node.getValues().size());

    for (Expression expression : node.getValues()) {
        Object value = process(expression, context);
        if (value instanceof Expression) {
            return visitFunctionCall(new FunctionCall(QualifiedName.of(ArrayConstructor.ARRAY_CONSTRUCTOR), node.getValues()), context);
        }
        writeNativeValue(elementType, arrayBlockBuilder, value);
    }

    return arrayBlockBuilder.build();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:ExpressionInterpreter.java

示例7: rewriteCurrentTime

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Override
public Expression rewriteCurrentTime(CurrentTime node, Void context, ExpressionTreeRewriter<Void> treeRewriter)
{
    if (node.getPrecision() != null) {
        throw new UnsupportedOperationException("not yet implemented: non-default precision");
    }

    switch (node.getType()) {
        case DATE:
            return new FunctionCall(new QualifiedName("current_date"), ImmutableList.<Expression>of());
        case TIME:
            return new FunctionCall(new QualifiedName("current_time"), ImmutableList.<Expression>of());
        case LOCALTIME:
            return new FunctionCall(new QualifiedName("localtime"), ImmutableList.<Expression>of());
        case TIMESTAMP:
            return new FunctionCall(new QualifiedName("current_timestamp"), ImmutableList.<Expression>of());
        case LOCALTIMESTAMP:
            return new FunctionCall(new QualifiedName("localtimestamp"), ImmutableList.<Expression>of());
        default:
            throw new UnsupportedOperationException("not yet implemented: " + node.getType());
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:CanonicalizeExpressions.java

示例8: isCountConstant

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
public static boolean isCountConstant(ProjectNode projectNode, FunctionCall functionCall, Signature signature)
{
    if (!"count".equals(signature.getName()) ||
            signature.getArgumentTypes().size() != 1 ||
            !signature.getReturnType().getBase().equals(StandardTypes.BIGINT)) {
        return false;
    }

    Expression argument = functionCall.getArguments().get(0);
    if (argument instanceof Literal && !(argument instanceof NullLiteral)) {
        return true;
    }

    if (argument instanceof QualifiedNameReference) {
        QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) argument;
        QualifiedName qualifiedName = qualifiedNameReference.getName();
        Symbol argumentSymbol = Symbol.fromQualifiedName(qualifiedName);
        Expression argumentExpression = projectNode.getAssignments().get(argumentSymbol);
        return (argumentExpression instanceof Literal) && (!(argumentExpression instanceof NullLiteral));
    }

    return false;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:CountConstantOptimizer.java

示例9: visitSample

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Override
public PlanNode visitSample(SampleNode node, RewriteContext<Void> context)
{
    if (node.getSampleType() == SampleNode.Type.BERNOULLI) {
        PlanNode rewrittenSource = context.rewrite(node.getSource());

        ComparisonExpression expression = new ComparisonExpression(
                ComparisonExpression.Type.LESS_THAN,
                new FunctionCall(QualifiedName.of("rand"), ImmutableList.<Expression>of()),
                new DoubleLiteral(Double.toString(node.getSampleRatio())));
        return new FilterNode(node.getId(), rewrittenSource, expression);
    }
    else if (node.getSampleType() == SampleNode.Type.POISSONIZED ||
            node.getSampleType() == SampleNode.Type.SYSTEM) {
        return context.defaultRewrite(node);
    }
    throw new UnsupportedOperationException("not yet implemented");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:ImplementSampleAsFilter.java

示例10: testWith

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Test
public void testWith()
        throws Exception
{
    assertStatement("WITH a (t, u) AS (SELECT * FROM x), b AS (SELECT * FROM y) TABLE z",
            new Query(Optional.of(new With(false, ImmutableList.of(
                    new WithQuery("a", simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("x"))), ImmutableList.of("t", "u")),
                    new WithQuery("b", simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("y"))), null)))),
                    new Table(QualifiedName.of("z")),
                    ImmutableList.of(),
                    Optional.<String>empty(),
                    Optional.<Approximate>empty()));

    assertStatement("WITH RECURSIVE a AS (SELECT * FROM x) TABLE y",
            new Query(Optional.of(new With(true, ImmutableList.of(
                    new WithQuery("a", simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("x"))), null)))),
                    new Table(QualifiedName.of("y")),
                    ImmutableList.of(),
                    Optional.<String>empty(),
                    Optional.<Approximate>empty()));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TestSqlParser.java

示例11: testExplain

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Test
public void testExplain()
        throws Exception
{
    assertStatement("EXPLAIN SELECT * FROM t",
            new Explain(simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))), ImmutableList.of()));
    assertStatement("EXPLAIN (TYPE LOGICAL) SELECT * FROM t",
            new Explain(
                    simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
                    ImmutableList.of(new ExplainType(ExplainType.Type.LOGICAL))));
    assertStatement("EXPLAIN (TYPE LOGICAL, FORMAT TEXT) SELECT * FROM t",
            new Explain(
                    simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("t"))),
                    ImmutableList.of(
                            new ExplainType(ExplainType.Type.LOGICAL),
                            new ExplainFormat(ExplainFormat.Type.TEXT))));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:TestSqlParser.java

示例12: testUnnest

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
@Test
public void testUnnest()
        throws Exception
{
    assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a)",
            simpleQuery(
                    selectList(new AllColumns()),
                    new Join(
                            Join.Type.CROSS,
                            new Table(QualifiedName.of("t")),
                            new Unnest(ImmutableList.of(new QualifiedNameReference(QualifiedName.of("a"))), false),
                            Optional.empty())));
    assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a) WITH ORDINALITY",
            simpleQuery(
                    selectList(new AllColumns()),
                    new Join(
                            Join.Type.CROSS,
                            new Table(QualifiedName.of("t")),
                            new Unnest(ImmutableList.of(new QualifiedNameReference(QualifiedName.of("a"))), true),
                            Optional.empty())));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:22,代码来源:TestSqlParser.java

示例13: render

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
private Relation render(List<ForeignKey> keys) {
  if (keys.isEmpty()) {
    return QueryUtil.table(new QualifiedName(baseTable));
  }
  ForeignKey key = keys.get(0);
  if (keys.size() == 1) {
    return new Join(Join.Type.INNER,
        QueryUtil.table(new QualifiedName(key.getSourceTable())),
        QueryUtil.table(new QualifiedName(key.getDestinationTable())),
        Optional.of(new JoinOn(new ComparisonExpression(
            ComparisonExpression.Type.EQUAL,
            new QualifiedNameReference(QualifiedName.of(
                key.getSourceTable(), key.getSourceColumn())),
            new QualifiedNameReference(QualifiedName.of(
                key.getDestinationTable(), key.getDestinationColumn()))))));
  }
  return new Join(Join.Type.INNER,
      render(keys.subList(1, keys.size())),
      QueryUtil.table(new QualifiedName(key.getDestinationTable())),
      Optional.of(new JoinOn(new ComparisonExpression(
          ComparisonExpression.Type.EQUAL,
          new QualifiedNameReference(QualifiedName.of(
              key.getSourceTable(), key.getSourceColumn())),
          new QualifiedNameReference(QualifiedName.of(
              key.getDestinationTable(), key.getDestinationColumn()))))));
}
 
开发者ID:vqtran,项目名称:EchoQuery,代码行数:27,代码来源:MultiTableJoinRecipe.java

示例14: qualifiedNameToTable

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
private Table qualifiedNameToTable(QualifiedName name, CatalogSchemaContext context)
{
    List<String> nameParts = name.getParts();

    String connectorId = context.getCatalog();
    String schema = context.getSchema();
    String table = null;

    if (nameParts.size() == 3) {
        connectorId = nameParts.get(0);
        schema = nameParts.get(1);
        table = nameParts.get(2);
    } else if (nameParts.size() == 2) {
        schema = nameParts.get(0);
        table = nameParts.get(1);
    } else if (nameParts.size() == 1) {
        table = nameParts.get(0);
    }

    return new Table(connectorId, schema, table);
}
 
开发者ID:airbnb,项目名称:airpal,代码行数:22,代码来源:InputReferenceExtractor.java

示例15: processFuncQuarter

import com.facebook.presto.sql.tree.QualifiedName; //导入依赖的package包/类
protected static String processFuncQuarter(Formatter formatter, FunctionCall node) {
	FunctionCall month = new FunctionCall(new QualifiedName("month"), node.getArguments());
	ArithmeticExpression substract = new ArithmeticExpression(ArithmeticExpression.Type.SUBTRACT, month, new LongLiteral("1"));
	ArithmeticExpression divide = new ArithmeticExpression(ArithmeticExpression.Type.DIVIDE, substract, new LongLiteral("3"));
	FunctionCall floor = new FunctionCall(new QualifiedName("floor"), Arrays.asList(divide));
	ArithmeticExpression add = new ArithmeticExpression(ArithmeticExpression.Type.ADD, floor, new LongLiteral("1"));
	return formatter.process(add, null);
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:9,代码来源:VeroFunctions.java


注:本文中的com.facebook.presto.sql.tree.QualifiedName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。