com.facebook.presto.metadata.Metadata.getView()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.facebook.presto.metadata.Metadata.getView()方法的一些代码示例,展示了Metadata.getView()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.getView()方法的具体详情如下:
包路径:com.facebook.presto.metadata.Metadata
类名称:Metadata
方法名:getView

Metadata.getView介绍

[英]Returns the view definition for the specified view name.
[中]返回指定视图名称的视图定义。

代码示例

代码示例来源:origin: prestodb/presto

public Set<QualifiedTablePrefix> calculatePrefixesWithTableName(
    ConnectorSession connectorSession,
    Set<QualifiedTablePrefix> prefixes,
    TupleDomain<ColumnHandle> constraint,
    Optional<Predicate<Map<ColumnHandle, NullableValue>>> predicate)
{
  Session session = ((FullConnectorSession) connectorSession).getSession();
  Optional<Set<String>> tables = filterString(constraint, TABLE_NAME_COLUMN_HANDLE);
  if (tables.isPresent()) {
    return prefixes.stream()
        .flatMap(prefix -> tables.get().stream()
            .filter(this::isLowerCase)
            .map(table -> table.toLowerCase(ENGLISH))
            .map(table -> new QualifiedObjectName(catalogName, prefix.getSchemaName().get(), table)))
        .filter(objectName -> metadata.getTableHandle(session, objectName).isPresent() || metadata.getView(session, objectName).isPresent())
        .map(QualifiedObjectName::asQualifiedTablePrefix)
        .collect(toImmutableSet());
  }
  return prefixes.stream()
      .flatMap(prefix -> Stream.concat(
          metadata.listTables(session, prefix).stream(),
          metadata.listViews(session, prefix).stream()))
      .filter(objectName -> !predicate.isPresent() || predicate.get().test(asFixedValues(objectName)))
      .map(QualifiedObjectName::asQualifiedTablePrefix)
      .collect(toImmutableSet());
}

代码示例来源:origin: prestodb/presto

@Override
  public ListenableFuture<?> execute(DropView statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters)
  {
    Session session = stateMachine.getSession();
    QualifiedObjectName name = createQualifiedObjectName(session, statement, statement.getName());

    Optional<ViewDefinition> view = metadata.getView(session, name);
    if (!view.isPresent()) {
      if (!statement.isExists()) {
        throw new SemanticException(MISSING_TABLE, statement, "View '%s' does not exist", name);
      }
      return immediateFuture(null);
    }

    accessControl.checkCanDropView(session.getRequiredTransactionId(), session.getIdentity(), name);

    metadata.dropView(session, name);

    return immediateFuture(null);
  }
}

代码示例来源:origin: prestodb/presto

if (metadata.getView(session, targetTable).isPresent()) {
  throw new SemanticException(NOT_SUPPORTED, insert, "Inserting into views is not supported");

代码示例来源:origin: prestodb/presto

Optional<ViewDefinition> viewDefinition = metadata.getView(session, objectName);

代码示例来源:origin: prestodb/presto

@Override
protected Scope visitDelete(Delete node, Optional<Scope> scope)
{
  Table table = node.getTable();
  QualifiedObjectName tableName = createQualifiedObjectName(session, table, table.getName());
  if (metadata.getView(session, tableName).isPresent()) {
    throw new SemanticException(NOT_SUPPORTED, node, "Deleting from views is not supported");
  }
  // Analyzer checks for select permissions but DELETE has a separate permission, so disable access checks
  // TODO: we shouldn't need to create a new analyzer. The access control should be carried in the context object
  StatementAnalyzer analyzer = new StatementAnalyzer(
      analysis,
      metadata,
      sqlParser,
      new AllowAllAccessControl(),
      session,
      WarningCollector.NOOP);
  Scope tableScope = analyzer.analyze(table, scope);
  node.getWhere().ifPresent(where -> analyzeWhere(node, tableScope, where));
  analysis.setUpdateType("DELETE");
  accessControl.checkCanDeleteFromTable(session.getRequiredTransactionId(), session.getIdentity(), tableName);
  return createAndAssignScope(node, scope, Field.newUnqualified("rows", BIGINT));
}

代码示例来源:origin: prestodb/presto

QualifiedObjectName qualifiedTableName = createQualifiedObjectName(session, showGrants, tableName.get());
if (!metadata.getView(session, qualifiedTableName).isPresent() &&
    !metadata.getTableHandle(session, qualifiedTableName).isPresent()) {
  throw new SemanticException(MISSING_TABLE, showGrants, "Table '%s' does not exist", tableName);

代码示例来源:origin: prestodb/presto

analysis.addEmptyColumnReferencesForTable(accessControl, session.getIdentity(), name);
Optional<ViewDefinition> optionalView = metadata.getView(session, name);
if (optionalView.isPresent()) {
  Statement statement = analysis.getStatement();

代码示例来源:origin: prestodb/presto

@Override
protected Node visitShowColumns(ShowColumns showColumns, Void context)
{
  QualifiedObjectName tableName = createQualifiedObjectName(session, showColumns, showColumns.getTable());
  if (!metadata.getView(session, tableName).isPresent() &&
      !metadata.getTableHandle(session, tableName).isPresent()) {
    throw new SemanticException(MISSING_TABLE, showColumns, "Table '%s' does not exist", tableName);
  }
  return simpleQuery(
      selectList(
          aliasedName("column_name", "Column"),
          aliasedName("data_type", "Type"),
          aliasedNullToEmpty("extra_info", "Extra"),
          aliasedNullToEmpty("comment", "Comment")),
      from(tableName.getCatalogName(), TABLE_COLUMNS),
      logicalAnd(
          equal(identifier("table_schema"), new StringLiteral(tableName.getSchemaName())),
          equal(identifier("table_name"), new StringLiteral(tableName.getObjectName()))),
      ordering(ascending("ordinal_position")));
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
  public CompletableFuture<?> execute(DropView statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
  {
    Session session = stateMachine.getSession();
    QualifiedObjectName name = createQualifiedObjectName(session, statement, statement.getName());

    Optional<ViewDefinition> view = metadata.getView(session, name);
    if (!view.isPresent()) {
      if (!statement.isExists()) {
        throw new SemanticException(MISSING_TABLE, statement, "View '%s' does not exist", name);
      }
      return completedFuture(null);
    }

    accessControl.checkCanDropView(session.getRequiredTransactionId(), session.getIdentity(), name);

    metadata.dropView(session, name);

    return completedFuture(null);
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

if (metadata.getView(session, targetTable).isPresent()) {
  throw new SemanticException(NOT_SUPPORTED, insert, "Inserting into views is not supported");

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

Optional<ViewDefinition> optionalView = metadata.getView(session, name);
if (optionalView.isPresent()) {
  ViewDefinition view = optionalView.get();

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
protected RelationType visitDelete(Delete node, AnalysisContext context)
{
  Table table = node.getTable();
  QualifiedObjectName tableName = createQualifiedObjectName(session, table, table.getName());
  if (metadata.getView(session, tableName).isPresent()) {
    throw new SemanticException(NOT_SUPPORTED, node, "Deleting from views is not supported");
  }
  // Analyzer checks for select permissions but DELETE has a separate permission, so disable access checks
  // TODO: we shouldn't need to create a new analyzer. The access control should be carried in the context object
  StatementAnalyzer analyzer = new StatementAnalyzer(
      analysis,
      metadata,
      sqlParser,
      new AllowAllAccessControl(),
      session,
      experimentalSyntaxEnabled,
      queryExplainer);
  RelationType descriptor = analyzer.process(table, context);
  node.getWhere().ifPresent(where -> analyzer.analyzeWhere(node, descriptor, context, where));
  analysis.setUpdateType("DELETE");
  analysis.setStatement(node);
  accessControl.checkCanDeleteFromTable(session.getRequiredTransactionId(), session.getIdentity(), tableName);
  return new RelationType(Field.newUnqualified("rows", BIGINT));
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
protected RelationType visitShowColumns(ShowColumns showColumns, AnalysisContext context)
{
  QualifiedObjectName tableName = createQualifiedObjectName(session, showColumns, showColumns.getTable());
  if (!metadata.getView(session, tableName).isPresent() &&
      !metadata.getTableHandle(session, tableName).isPresent()) {
    throw new SemanticException(MISSING_TABLE, showColumns, "Table '%s' does not exist", tableName);
  }
  Query query = simpleQuery(
      selectList(
          aliasedName("column_name", "Column"),
          aliasedName("data_type", "Type"),
          aliasedNullToEmpty("comment", "Comment")),
      from(tableName.getCatalogName(), TABLE_COLUMNS),
      logicalAnd(
          equal(nameReference("table_schema"), new StringLiteral(tableName.getSchemaName())),
          equal(nameReference("table_name"), new StringLiteral(tableName.getObjectName()))),
      ordering(ascending("ordinal_position")));
  return process(query, context);
}

相关文章