public static List getFromSessionFile()

in spanner-data-validator-java/src/main/java/com/google/migration/TableSpecList.java [306:332]


  public static List<TableSpec> getFromSessionFile(DVTOptionsCore options) {
    Schema schema = SessionFileReader.read(options.getSessionFileJson());
    List<TableSpec> tableSpecList = new ArrayList<>();
    for (String tableId : schema.getSpSchema().keySet()) {
      TableSpec tableSpec = new TableSpec();
      //Fetch the source and spanner tables from session object
      SpannerTable spannerTable = schema.getSpSchema().get(tableId);
      SourceTable sourceTable = schema.getSrcSchema().get(tableId);
      tableSpec.setTableName(spannerTable.getName());
      tableSpec.setPartitionCount(options.getPartitionCount());
      tableSpec.setPartitionFilterRatio(options.getPartitionFilterRatio());
      tableSpec.setRangeFieldIndex(0);
      tableSpec.setRangeCoverage(BigDecimal.valueOf(1));
      PartitionKey partitionKey = determinePartitionKey(sourceTable, spannerTable);
      if (partitionKey == null) {
        continue;
      }
      tableSpec.setRangeStart(partitionKey.getPartitionKeyMinValue());
      tableSpec.setRangeEnd(partitionKey.getPartitionKeyMaxValue());
      tableSpec.setDestQuery(spannerTable.getSpannerQuery(partitionKey.getPartitionKeyColId(), sourceTable.getColIds(), !Helpers.isNullOrEmpty(options.getTransformationJarPath()) && !Helpers.isNullOrEmpty(options.getTransformationClassName())));
      tableSpec.setSourceQuery(sourceTable.getSourceQuery(partitionKey.getPartitionKeyColId(), spannerTable.getColIds()));
      tableSpec.setRangeFieldType(partitionKey.getPartitionKeyColDataType());
      tableSpec.setRangeFieldName(sourceTable.getColDefs().get(partitionKey.getPartitionKeyColId()).getName());
      tableSpecList.add(tableSpec);
    }
    return tableSpecList;
  }