private Map getRows()

in odps-sdk/odps-sdk-core/src/main/java/com/aliyun/odps/sqa/commandapi/DescribeTableCommand.java [187:263]


  private Map<String, Object> getRows(Table t, Partition meta, boolean isExtended) {
    Map<String, Object> map = new HashMap<>();

    try {
      if (meta != null) { // partition meta
        map.put("PartitionSize", meta.getSize());
        map.put("CreatedTime", meta.getCreatedTime());
        map.put("LastDDLTime", meta.getLastMetaModifiedTime());
        map.put("LastModifiedTime", meta.getLastDataModifiedTime());
        map.put("MetadataJson", meta.getMetadataJson());
      } else { // table meta
        map.put("Owner", t.getOwner());
        map.put("Project", t.getProject());
        map.put("Schema", t.getSchemaName());
        map.put("TableComment", t.getComment());
        map.put("CreatedTime", t.getCreatedTime());
        map.put("LastDDLTime", t.getLastMetaModifiedTime());
        map.put("LastModifiedTime", t.getLastDataModifiedTime());
        map.put("Lifecycle", t.getLife());

        if (t.isExternalTable()) {
          map.put("TableType", Table.TableType.EXTERNAL_TABLE.toString());
        } else if (t.isVirtualView()) {
          map.put("TableType", Table.TableType.VIRTUAL_VIEW.toString());
        } else if (t.isMaterializedView()) {
          map.put("TableType", Table.TableType.MATERIALIZED_VIEW.toString());
        } else {
          map.put("TableType", Table.TableType.MANAGED_TABLE.toString());
        }

        List<Struct> structList = new ArrayList<>();
        for (Column c : t.getSchema().getColumns()) {
          String fieldName = c.getName();
          String typeName = c.getTypeInfo().getTypeName().toLowerCase();
          String comment = c.getComment();

          if (isExtended) {
            String defaultValueStr = null;
            if (c.hasDefaultValue()) {
              defaultValueStr = c.getDefaultValue();
            }
            Struct
                struct =
                new SimpleStruct(getExtendedStructTypeInfo(), Lists
                    .newArrayList(fieldName, typeName, c.isNullable(), defaultValueStr, comment));
            structList.add(struct);
          } else {
            Struct
                struct =
                new SimpleStruct(getStructTypeInfo(),
                                 Lists.newArrayList(fieldName, typeName, comment));
            structList.add(struct);
          }
        }
        map.put("NativeColumns", structList);

        map.put("PartitionColumns", null);
        if (t.getSchema().getPartitionColumns().size() > 0) {
          List<Struct> partitionStruct = new ArrayList<>();
          for (Column c : t.getSchema().getPartitionColumns()) {
            Struct
                struct =
                new SimpleStruct(getStructTypeInfo(), Lists
                    .newArrayList(c.getName(), c.getTypeInfo().getTypeName().toLowerCase(),
                                  c.getComment()));
            partitionStruct.add(struct);
          }
          map.put("PartitionColumns", partitionStruct);
        }
        map.put("MetadataJson", t.getMetadataJson());
      }
    } catch (Exception e) {
      throw new RuntimeException("Invalid table schema.", e);
    }

    return map;
  }