public static InstanceAssignmentConfig getInstanceAssignmentConfig(TableConfig tableConfig,
      InstancePartitionsType instancePartitionsType) {
    Preconditions.checkState(allowInstanceAssignment(tableConfig, instancePartitionsType),
        "Instance assignment is not allowed for the given table config");

    // Use the instance assignment config from the table config if it exists
    Map<String, InstanceAssignmentConfig> instanceAssignmentConfigMap = tableConfig.getInstanceAssignmentConfigMap();
    if (instanceAssignmentConfigMap != null) {
      InstanceAssignmentConfig instanceAssignmentConfig =
          instanceAssignmentConfigMap.get(instancePartitionsType.toString());
      if (instanceAssignmentConfig != null) {
        return instanceAssignmentConfig;
      }
    }

    // Generate default instance assignment config if it does not exist
    // Only allow default config for offline table with replica-group segment assignment for backward-compatibility

    InstanceTagPoolConfig tagPoolConfig =
        new InstanceTagPoolConfig(TagNameUtils.extractOfflineServerTag(tableConfig.getTenantConfig()), false, 0, null);

    InstanceReplicaGroupPartitionConfig replicaGroupPartitionConfig;
    SegmentsValidationAndRetentionConfig segmentConfig = tableConfig.getValidationConfig();
    int numReplicaGroups = tableConfig.getReplication();
    ReplicaGroupStrategyConfig replicaGroupStrategyConfig = segmentConfig.getReplicaGroupStrategyConfig();
    Preconditions.checkState(replicaGroupStrategyConfig != null, "Failed to find the replica-group strategy config");
    String partitionColumn = replicaGroupStrategyConfig.getPartitionColumn();
    boolean minimizeDataMovement = segmentConfig.isMinimizeDataMovement();
    if (partitionColumn != null) {
      int numPartitions = tableConfig.getIndexingConfig().getSegmentPartitionConfig().getNumPartitions(partitionColumn);
      Preconditions.checkState(numPartitions > 0, "Number of partitions for column: %s is not properly configured",
          partitionColumn);
      replicaGroupPartitionConfig = new InstanceReplicaGroupPartitionConfig(true, 0, numReplicaGroups, 0, numPartitions,
          replicaGroupStrategyConfig.getNumInstancesPerPartition(), minimizeDataMovement, partitionColumn);
    } else {
      // If partition column is not configured, use replicaGroupStrategyConfig.getNumInstancesPerPartition() as
      // number of instances per replica-group for backward-compatibility
      replicaGroupPartitionConfig = new InstanceReplicaGroupPartitionConfig(true, 0, numReplicaGroups,
          replicaGroupStrategyConfig.getNumInstancesPerPartition(), 0, 0, minimizeDataMovement, null);
    }

    return new InstanceAssignmentConfig(tagPoolConfig, null, replicaGroupPartitionConfig, null, minimizeDataMovement);
  }
@Test
  public void testGetInstanceAssignmentConfigWhenInstanceAssignmentConfigIsNotPresentAndPartitionColumnNotPresent() {

    TagOverrideConfig tagOverrideConfig = new TagOverrideConfig("broker", "Server");

    Map<InstancePartitionsType, String> instancePartitionsTypeStringMap = new HashMap<>();
    instancePartitionsTypeStringMap.put(InstancePartitionsType.OFFLINE, "offlineString");
    TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("testTable")
        .setTagOverrideConfig(tagOverrideConfig).setInstancePartitionsMap(instancePartitionsTypeStringMap)
        .build();
    SegmentsValidationAndRetentionConfig segmentsValidationAndRetentionConfig =
        new SegmentsValidationAndRetentionConfig();
    ReplicaGroupStrategyConfig replicaGroupStrategyConfig =
        new ReplicaGroupStrategyConfig(null, 2);
    segmentsValidationAndRetentionConfig.setReplicaGroupStrategyConfig(replicaGroupStrategyConfig);
    segmentsValidationAndRetentionConfig.setReplication("1");
    tableConfig.setValidationConfig(segmentsValidationAndRetentionConfig);
    IndexingConfig indexingConfig = new IndexingConfig();
    Map<String, ColumnPartitionConfig> columnPartitionConfigMap = new HashMap<>();
    ColumnPartitionConfig columnPartitionConfig = new ColumnPartitionConfig("column1", 1);
    columnPartitionConfigMap.put("column1", columnPartitionConfig);
    SegmentPartitionConfig segmentPartitionConfig = new SegmentPartitionConfig(columnPartitionConfigMap);
    indexingConfig.setSegmentPartitionConfig(segmentPartitionConfig);
    tableConfig.setIndexingConfig(indexingConfig);
    Assert.assertEquals(InstanceAssignmentConfigUtils
        .getInstanceAssignmentConfig(tableConfig, InstancePartitionsType.OFFLINE)
        .getReplicaGroupPartitionConfig().isReplicaGroupBased(), Boolean.TRUE);
    Assert.assertEquals(InstanceAssignmentConfigUtils
        .getInstanceAssignmentConfig(tableConfig, InstancePartitionsType.OFFLINE)
        .getReplicaGroupPartitionConfig().getPartitionColumn(), null);
    Assert.assertEquals(InstanceAssignmentConfigUtils
        .getInstanceAssignmentConfig(tableConfig, InstancePartitionsType.OFFLINE)
        .getReplicaGroupPartitionConfig().getNumInstancesPerReplicaGroup(), 2);
  }