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

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

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

Metadata.getType介绍

暂无

代码示例

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

private static Optional<Symbol> newGeometrySymbol(Context context, Expression expression, Metadata metadata)
{
  if (expression instanceof SymbolReference) {
    return Optional.empty();
  }
  return Optional.of(context.getSymbolAllocator().newSymbol(expression, metadata.getType(GEOMETRY_TYPE_SIGNATURE)));
}

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

protected Function<Column, Type> columnTypeGetter()
  {
    return column -> {
      String typeName = column.getType();
      Type type = prestoServer.getMetadata().getType(parseTypeSignature(typeName));
      if (type == null) {
        throw new AssertionError("Unhandled type: " + typeName);
      }
      return type;
    };
  }
}

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

private boolean isIntegralType(TypeSignature targetType)
{
  switch (targetType.getBase()) {
    case StandardTypes.BIGINT:
    case StandardTypes.INTEGER:
    case StandardTypes.SMALLINT:
    case StandardTypes.TINYINT:
      return true;
    case StandardTypes.DECIMAL:
      DecimalType decimalType = (DecimalType) metadata.getType(targetType);
      return decimalType.getScale() == 0;
    default:
      return false;
  }
}

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

@Override
  protected Type _deserialize(String value, DeserializationContext context)
  {
    Type type = metadata.getType(parseTypeSignature(value));
    if (type == null) {
      throw new IllegalArgumentException(String.valueOf("Unknown type " + value));
    }
    return type;
  }
}

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

private ColumnStatisticsAggregation createAggregation(QualifiedName functionName, SymbolReference input, Type inputType, Type outputType)
{
  Signature signature = metadata.getFunctionRegistry().resolveFunction(functionName, TypeSignatureProvider.fromTypes(ImmutableList.of(inputType)));
  Type resolvedType = metadata.getType(getOnlyElement(signature.getArgumentTypes()));
  verify(resolvedType.equals(inputType), "resolved function input type does not match the input type: %s != %s", resolvedType, inputType);
  return new ColumnStatisticsAggregation(
      new AggregationNode.Aggregation(
          new FunctionCall(functionName, ImmutableList.of(input)),
          signature,
          Optional.empty()),
      outputType);
}

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

@Test
public void testRowTypeLookup()
{
  functionAssertions.getMetadata().getType(parseTypeSignature("row(a bigint)"));
  Type type = functionAssertions.getMetadata().getType(parseTypeSignature("row(b bigint)"));
  assertEquals(type.getTypeSignature().getParameters().size(), 1);
  assertEquals(type.getTypeSignature().getParameters().get(0).getNamedTypeSignature().getName().get(), "b");
}

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

Type type = metadata.getType(argument.getType());
checkCondition(type != null, INVALID_PROCEDURE_DEFINITION, "Unknown procedure argument type: %s", argument.getType());

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

@VisibleForTesting
public static final class ExtractSpatialLeftJoin
    implements Rule<JoinNode>
{
  private static final Pattern<JoinNode> PATTERN = join().matching(node -> node.getCriteria().isEmpty() && node.getFilter().isPresent() && node.getType() == LEFT);
  private final Metadata metadata;
  private final SplitManager splitManager;
  private final PageSourceManager pageSourceManager;
  private final SqlParser sqlParser;
  public ExtractSpatialLeftJoin(Metadata metadata, SplitManager splitManager, PageSourceManager pageSourceManager, SqlParser sqlParser)
  {
    this.metadata = requireNonNull(metadata, "metadata is null");
    this.splitManager = requireNonNull(splitManager, "splitManager is null");
    this.pageSourceManager = requireNonNull(pageSourceManager, "pageSourceManager is null");
    this.sqlParser = requireNonNull(sqlParser, "sqlParser is null");
  }
  @Override
  public boolean isEnabled(Session session)
  {
    return isSpatialJoinEnabled(session);
  }
  @Override
  public Pattern<JoinNode> getPattern()
  {
    return PATTERN;
  }

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

if (name.toString().equals(NAME) && call.getArguments().size() == 1) {
  Expression geometry = getOnlyElement(call.getArguments());
  Symbol envelopeSymbol = context.getSymbolAllocator().newSymbol("envelope", metadata.getType(GEOMETRY_TYPE_SIGNATURE));
  if (geometry instanceof FunctionCall && ((FunctionCall) geometry).getName().toString().equalsIgnoreCase("ST_Envelope")) {
    envelopeAssignments.put(envelopeSymbol, geometry);

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

@Override
protected Object visitGenericLiteral(GenericLiteral node, ConnectorSession session)
{
  Type type = metadata.getType(parseTypeSignature(node.getType()));
  if (type == null) {
    throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType());
  }
  if (JSON.equals(type)) {
    Signature operatorSignature = new Signature("json_parse", SCALAR, JSON.getTypeSignature(), VARCHAR.getTypeSignature());
    return functionInvoker.invoke(operatorSignature, session, ImmutableList.of(utf8Slice(node.getValue())));
  }
  try {
    Signature signature = metadata.getFunctionRegistry().getCoercion(VARCHAR, type);
    return functionInvoker.invoke(signature, session, ImmutableList.of(utf8Slice(node.getValue())));
  }
  catch (IllegalArgumentException e) {
    throw new SemanticException(TYPE_MISMATCH, node, "No literal form for type %s", type);
  }
}

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

Type type;
try {
  type = metadata.getType(parseTypeSignature(column.getType()));

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

Type type;
try {
  type = metadata.getType(parseTypeSignature(element.getType()));

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

Type targetType = metadata.getType(parseTypeSignature(node.getType()));
if (targetType == null) {
  throw new IllegalArgumentException("Unsupported type: " + node.getType());

代码示例来源:origin: com.facebook.presto/presto-tests

protected Function<Column, Type> columnTypeGetter()
  {
    return column -> {
      String typeName = column.getType();
      Type type = prestoServer.getMetadata().getType(parseTypeSignature(typeName));
      if (type == null) {
        throw new AssertionError("Unhandled type: " + typeName);
      }
      return type;
    };
  }
}

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

@Test
public void testRowTypeLookup()
    throws Exception
{
  functionAssertions.getMetadata().getType(parseTypeSignature("row<bigint>('a')"));
  Type type = functionAssertions.getMetadata().getType(parseTypeSignature("row<bigint>('b')"));
  assertEquals(type.getTypeSignature().getParameters().size(), 1);
  assertEquals(type.getTypeSignature().getParameters().get(0).getNamedTypeSignature().getName(), "b");
}

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

@Override
  public CompletableFuture<?> execute(AddColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
  {
    Session session = stateMachine.getSession();
    QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getName());
    Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
    if (!tableHandle.isPresent()) {
      throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
    }

    accessControl.checkCanAddColumns(session.getRequiredTransactionId(), session.getIdentity(), tableName);

    Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());

    TableElement element = statement.getColumn();
    Type type = metadata.getType(parseTypeSignature(element.getType()));
    if ((type == null) || type.equals(UNKNOWN)) {
      throw new SemanticException(TYPE_MISMATCH, element, "Unknown type for column '%s' ", element.getName());
    }
    if (columnHandles.containsKey(element.getName())) {
      throw new SemanticException(COLUMN_ALREADY_EXISTS, statement, "Column '%s' already exists", element.getName());
    }

    metadata.addColumn(session, tableHandle.get(), new ColumnMetadata(element.getName(), type));

    return completedFuture(null);
  }
}

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

Type type = metadata.getType(parseTypeSignature(element.getType()));
if ((type == null) || type.equals(UNKNOWN)) {
  throw new SemanticException(TYPE_MISMATCH, element, "Unknown type for column '%s' ", element.getName());

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

@Override
protected Object visitGenericLiteral(GenericLiteral node, ConnectorSession session)
  Type type = metadata.getType(parseTypeSignature(node.getType()));
  if (type == null) {
    throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType());

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

Type type = metadata.getType(parseTypeSignature(node.getType()));
if (type == null) {
  throw new IllegalArgumentException("Unsupported type: " + node.getType());

相关文章