예제 #1
0
  public static List<HiveColumnHandle> getPartitionKeyColumnHandles(
      String connectorId, Table table, boolean forceIntegralToBigint) {
    ImmutableList.Builder<HiveColumnHandle> columns = ImmutableList.builder();

    List<Column> partitionKeys = table.getPartitionColumns();
    for (Column field : partitionKeys) {
      HiveType hiveType = field.getType();
      if (!hiveType.isSupportedType()) {
        throw new PrestoException(
            NOT_SUPPORTED,
            format(
                "Unsupported Hive type %s found in partition keys of table %s.%s",
                hiveType, table.getDatabaseName(), table.getTableName()));
      }
      columns.add(
          new HiveColumnHandle(
              connectorId,
              field.getName(),
              hiveType,
              hiveType.getTypeSignature(forceIntegralToBigint),
              -1,
              PARTITION_KEY));
    }

    return columns.build();
  }
예제 #2
0
  public static List<HiveColumnHandle> getRegularColumnHandles(
      String connectorId, Table table, boolean forceIntegralToBigint) {
    ImmutableList.Builder<HiveColumnHandle> columns = ImmutableList.builder();

    int hiveColumnIndex = 0;
    for (Column field : table.getDataColumns()) {
      // ignore unsupported types rather than failing
      HiveType hiveType = field.getType();
      if (hiveType.isSupportedType()) {
        columns.add(
            new HiveColumnHandle(
                connectorId,
                field.getName(),
                hiveType,
                hiveType.getTypeSignature(forceIntegralToBigint),
                hiveColumnIndex,
                REGULAR));
      }
      hiveColumnIndex++;
    }

    return columns.build();
  }