本文整理了Java中io.prestosql.sql.tree.QualifiedName类的一些代码示例,展示了QualifiedName类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QualifiedName类的具体详情如下:包路径:io.prestosql.sql.tree.QualifiedName类名称:QualifiedName
QualifiedName介绍
暂无
代码示例
代码示例来源:origin: io.prestosql/presto-main
public static FunctionCall getCall(CurrentPath node) { return new FunctionCall(QualifiedName.of("$current_path"), ImmutableList.of()); }}
代码示例来源:origin: io.prestosql/presto-parser
@Overrideprotected Void visitDereferenceExpression(DereferenceExpression node, Integer indentLevel){ QualifiedName resolved = resolvedNameReferences.get(node); String resolvedName = ""; if (resolved != null) { resolvedName = "=>" + resolved.toString(); } print(indentLevel, "DereferenceExpression[" + node + resolvedName + "]"); return null;}
代码示例来源:origin: prestosql/presto
private String createTemporaryTableName(){ return rewritePrefix.getSuffix() + UUID.randomUUID().toString().replace("-", "");}
代码示例来源:origin: prestosql/presto
private QualifiedName generateTemporaryTableName(QualifiedName originalName){ List parts = new ArrayList(); int originalSize = originalName.getOriginalParts().size(); int prefixSize = rewritePrefix.getOriginalParts().size(); if (originalSize > prefixSize) { parts.addAll(originalName.getOriginalParts().subList(0, originalSize - prefixSize)); } parts.addAll(rewritePrefix.getOriginalParts()); parts.set(parts.size() - 1, createTemporaryTableName()); return QualifiedName.of(parts);}
代码示例来源:origin: prestosql/presto
@Override protected Void visitFunctionCall(FunctionCall node, AtomicBoolean deterministic) { // TODO: total hack to figure out if a function is deterministic. martint should fix this when he refactors the planning code if (node.getName().equals(QualifiedName.of("rand")) || node.getName().equals(QualifiedName.of("random")) || node.getName().equals(QualifiedName.of("shuffle"))) { deterministic.set(false); } return super.visitFunctionCall(node, deterministic); }}
代码示例来源:origin: io.prestosql/presto-main
public boolean canResolve(QualifiedName name){ if (!this.name.isPresent()) { return false; } // TODO: need to know whether the qualified name and the name of this field were quoted return matchesPrefix(name.getPrefix()) }
代码示例来源:origin: prestosql/presto
@Testpublic void testCreateTableAsSelectDifferentCatalog() throws Exception{ handle.execute("CREATE TABLE \"my_test_table2\" (column1 BIGINT, column2 DOUBLE)"); SqlParser parser = new SqlParser(); Query query = new Query(CATALOG, SCHEMA, ImmutableList.of(), "CREATE TABLE public.my_test_table2 AS SELECT 1 column1, 2E0 column2", ImmutableList.of(), null, null, ImmutableMap.of()); QueryRewriter rewriter = new QueryRewriter(parser, URL, QualifiedName.of("other_catalog", "other_schema", "tmp_"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), 1, new Duration(10, SECONDS)); Query rewrittenQuery = rewriter.shadowQuery(query); assertEquals(rewrittenQuery.getPreQueries().size(), 1); CreateTableAsSelect createTableAs = (CreateTableAsSelect) parser.createStatement(rewrittenQuery.getPreQueries().get(0)); assertEquals(createTableAs.getName().getParts().size(), 3); assertEquals(createTableAs.getName().getPrefix().get(), QualifiedName.of("other_catalog", "other_schema")); assertTrue(createTableAs.getName().getSuffix().startsWith("tmp_")); assertFalse(createTableAs.getName().getSuffix().contains("my_test_table"));}
代码示例来源:origin: prestosql/presto
private void testSetSessionWithParameters(String property, Expression expression, String expectedValue, List parameters) { QualifiedName qualifiedPropName = QualifiedName.of(CATALOG_NAME, property); QueryStateMachine stateMachine = QueryStateMachine.begin( format("set %s = 'old_value'", qualifiedPropName), TEST_SESSION, URI.create("fake://uri"), new ResourceGroupId("test"), false, transactionManager, accessControl, executor, metadata, WarningCollector.NOOP); getFutureValue(new SetSessionTask().execute(new SetSession(qualifiedPropName, expression), transactionManager, metadata, accessControl, stateMachine, parameters)); Map sessiOnProperties= stateMachine.getSetSessionProperties(); assertEquals(sessionProperties, ImmutableMap.of(qualifiedPropName.toString(), expectedValue)); }}
代码示例来源:origin: prestosql/presto
@Testpublic void testQualifiedName(){ assertEquals(QualifiedName.of("a", "b", "c", "d").toString(), "a.b.c.d"); assertEquals(QualifiedName.of("A", "b", "C", "d").toString(), "a.b.c.d"); assertTrue(QualifiedName.of("a", "b", "c", "d").hasSuffix(QualifiedName.of("b", "c", "d"))); assertTrue(QualifiedName.of("a", "b", "c", "d").hasSuffix(QualifiedName.of("a", "b", "c", "d"))); assertFalse(QualifiedName.of("a", "b", "c", "d").hasSuffix(QualifiedName.of("a", "c", "d"))); assertFalse(QualifiedName.of("a", "b", "c", "d").hasSuffix(QualifiedName.of("z", "a", "b", "c", "d"))); assertEquals(QualifiedName.of("a", "b", "c", "d"), QualifiedName.of("a", "b", "c", "d"));}
代码示例来源:origin: io.prestosql/presto-main
@Overrideprotected Scope visitTable(Table table, Optional scope) if (!table.getName().getPrefix().isPresent()) { String name = table.getName().getSuffix(); Field inputField = queryDescriptor.getFieldByIndex(field); fieldBuilder.add(Field.newQualified( QualifiedName.of(name), Optional.of(columnName.getValue()), inputField.getType(), fields = queryDescriptor.getAllFields().stream() .map(field -> Field.newQualified( QualifiedName.of(name), field.getName(), field.getType(), QualifiedName.of(name.getObjectName()), Optional.of(column.getName()), column.getType(),
代码示例来源:origin: io.prestosql/presto-main
@Override public ListenableFuture execute(ResetSession statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List parameters) { List parts = statement.getName().getParts(); if (parts.size() > 2) { throw new SemanticException(INVALID_SESSION_PROPERTY, statement, "Invalid session property '%s'", statement.getName()); } // validate the property name if (parts.size() == 1) { metadata.getSessionPropertyManager().getSystemSessionPropertyMetadata(parts.get(0)) .orElseThrow(() -> new SemanticException(INVALID_SESSION_PROPERTY, statement, "Session property %s does not exist", statement.getName())); } else { ConnectorId cOnnectorId= metadata.getCatalogHandle(stateMachine.getSession(), parts.get(0)) .orElseThrow(() -> new SemanticException(MISSING_CATALOG, statement, "Catalog %s does not exist", parts.get(0))); metadata.getSessionPropertyManager().getConnectorSessionPropertyMetadata(connectorId, parts.get(1)) .orElseThrow(() -> new SemanticException(INVALID_SESSION_PROPERTY, statement, "Session property %s does not exist", statement.getName())); } stateMachine.addResetSessionProperties(statement.getName().toString()); return immediateFuture(null); }}
代码示例来源:origin: prestosql/presto
@Testpublic void testCreateTableAsSelect() throws Exception{ handle.execute("CREATE TABLE \"my_test_table\" (column1 BIGINT, column2 DOUBLE)"); SqlParser parser = new SqlParser(); Query query = new Query(CATALOG, SCHEMA, ImmutableList.of(), "CREATE TABLE my_test_table AS SELECT 1 column1, CAST('2.0' AS DOUBLE) column2 LIMIT 1", ImmutableList.of(), null, null, ImmutableMap.of()); QueryRewriter rewriter = new QueryRewriter(parser, URL, QualifiedName.of("tmp_"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), 1, new Duration(10, SECONDS)); Query rewrittenQuery = rewriter.shadowQuery(query); assertEquals(rewrittenQuery.getPreQueries().size(), 1); assertEquals(rewrittenQuery.getPostQueries().size(), 1); CreateTableAsSelect createTableAs = (CreateTableAsSelect) parser.createStatement(rewrittenQuery.getPreQueries().get(0)); assertEquals(createTableAs.getName().getParts().size(), 1); assertTrue(createTableAs.getName().getSuffix().startsWith("tmp_")); assertFalse(createTableAs.getName().getSuffix().contains("my_test_table")); assertEquals(statementToQueryType(parser, rewrittenQuery.getQuery()), READ); Table table = new Table(createTableAs.getName()); SingleColumn column1 = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new Identifier("COLUMN1")))); SingleColumn column2 = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new FunctionCall(QualifiedName.of("round"), ImmutableList.of(new Identifier("COLUMN2"), new LongLiteral("1")))))); Select select = new Select(false, ImmutableList.of(column1, column2)); QuerySpecification querySpecification = new QuerySpecification(select, Optional.of(table), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); assertEquals(parser.createStatement(rewrittenQuery.getQuery()), new io.prestosql.sql.tree.Query(Optional.empty(), querySpecification, Optional.empty(), Optional.empty())); assertEquals(parser.createStatement(rewrittenQuery.getPostQueries().get(0)), new DropTable(createTableAs.getName(), true));}
代码示例来源:origin: prestosql/presto
public boolean hasSuffix(QualifiedName suffix){ if (parts.size()
public static CatalogSchemaName createCatalogSchemaName(Session session, Node node, Optional schema){ String catalogName = session.getCatalog().orElse(null); String schemaName = session.getSchema().orElse(null); if (schema.isPresent()) { List parts = schema.get().getParts(); if (parts.size() > 2) { throw new SemanticException(INVALID_SCHEMA_NAME, node, "Too many parts in schema name: %s", schema.get()); } if (parts.size() == 2) { catalogName = parts.get(0); } schemaName = schema.get().getSuffix(); } if (catalogName == null) { throw new SemanticException(CATALOG_NOT_SPECIFIED, node, "Catalog must be specified when session catalog is not set"); } if (schemaName == null) { throw new SemanticException(SCHEMA_NOT_SPECIFIED, node, "Schema must be specified when session schema is not set"); } return new CatalogSchemaName(catalogName, schemaName);}
代码示例来源:origin: prestosql/presto
private static String formatName(QualifiedName name){ return name.getOriginalParts().stream() .map(Formatter::formatName) .collect(joining("."));}
代码示例来源:origin: prestosql/presto
FunctionCall call = entry.getValue().getCall();Symbol symbol = entry.getKey();if (call.getName().equals(COUNT)) { List scalarAggregatiOnSourceTypeSignatures= ImmutableList.of( symbolAllocator.getTypes().get(nonNullableAggregationSourceSymbol).getTypeSignature());
代码示例来源:origin: io.prestosql/presto-main
private static boolean isColumnReference(QualifiedName name, RelationType relation){ while (name.getPrefix().isPresent()) { name = name.getPrefix().get(); if (!relation.resolveFields(name).isEmpty()) { return true; } } return false;}
代码示例来源:origin: io.prestosql/presto-main
public boolean matchesPrefix(Optional prefix){ return !prefix.isPresent() || relationAlias.isPresent() }
代码示例来源:origin: prestosql/presto
SqlParser parser = new SqlParser();Query query = new Query(CATALOG, SCHEMA, ImmutableList.of(), "INSERT INTO test_insert_table (b, a, c) values (1.1, 1, 'a'), (2.0, 2, 'b'), (3.1, 3, 'c')", ImmutableList.of(), null, null, ImmutableMap.of());QueryRewriter rewriter = new QueryRewriter(parser, URL, QualifiedName.of("other_catalog", "other_schema", "tmp_"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), 1, new Duration(10, SECONDS));Query rewrittenQuery = rewriter.shadowQuery(query);assertEquals(createTable.getName().getParts().size(), 3);assertEquals(createTable.getName().getPrefix().get(), QualifiedName.of("other_catalog", "other_schema"));assertTrue(createTable.getName().getSuffix().startsWith("tmp_"));assertFalse(createTable.getName().getSuffix().contains("test_insert_table"));SingleColumn columnA = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new Identifier("A"))));SingleColumn columnB = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new FunctionCall(QualifiedName.of("round"), ImmutableList.of(new Identifier("B"), new LongLiteral("1"))))));SingleColumn columnC = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new Identifier("C"))));Select select = new Select(false, ImmutableList.of(columnA, columnB, columnC));QuerySpecification querySpecification = new QuerySpecification(select, Optional.of(table), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
代码示例来源:origin: io.prestosql/presto-parser
/** * If this DereferenceExpression looks like a QualifiedName, return QualifiedName. * Otherwise return null */public static QualifiedName getQualifiedName(DereferenceExpression expression){ List parts = null; if (expression.base instanceof Identifier) { parts = ImmutableList.of((Identifier) expression.base, expression.field); } else if (expression.base instanceof DereferenceExpression) { QualifiedName baseQualifiedName = getQualifiedName((DereferenceExpression) expression.base); if (baseQualifiedName != null) { ImmutableList.Builder builder = ImmutableList.builder(); builder.addAll(baseQualifiedName.getOriginalParts()); builder.add(expression.field); parts = builder.build(); } } return parts == null ? null : QualifiedName.of(parts);}【文章出处:日本大带宽服务器 http://www.558idc.com/jap.html 欢迎留下您的宝贵建议】