Esempio n. 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();
  }
  protected List<HiveColumnHandle> getColumnHandles(List<TestColumn> testColumns) {
    List<HiveColumnHandle> columns = new ArrayList<>();
    int nextHiveColumnIndex = 0;
    for (int i = 0; i < testColumns.size(); i++) {
      TestColumn testColumn = testColumns.get(i);
      int columnIndex = testColumn.isPartitionKey() ? -1 : nextHiveColumnIndex++;

      HiveType hiveType = HiveType.valueOf(testColumn.getObjectInspector().getTypeName());
      columns.add(
          new HiveColumnHandle(
              "client_id",
              testColumn.getName(),
              hiveType,
              hiveType.getTypeSignature(),
              columnIndex,
              testColumn.isPartitionKey()));
    }
    return columns;
  }
Esempio n. 3
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();
  }