コード例 #1
0
  @Test
  public void testAlterPartitionedTableShards() throws Exception {
    AlterTableAnalyzedStatement analysis =
        (AlterTableAnalyzedStatement) analyze("alter table parted set (number_of_shards=10)");
    assertThat(analysis.partitionName().isPresent(), is(false));
    assertThat(analysis.table().isPartitioned(), is(true));
    assertThat(
        analysis.table().tableParameterInfo(),
        instanceOf(AlterPartitionedTableParameterInfo.class));
    assertEquals(
        "10", analysis.tableParameter().settings().get(TableParameterInfo.NUMBER_OF_SHARDS));

    AlterPartitionedTableParameterInfo tableSettingsInfo =
        (AlterPartitionedTableParameterInfo) analysis.table().tableParameterInfo();
    TableParameter tableParameter =
        new TableParameter(
            analysis.tableParameter().settings(),
            tableSettingsInfo.partitionTableSettingsInfo().supportedInternalSettings());
    assertEquals(null, tableParameter.settings().get(TableParameterInfo.NUMBER_OF_SHARDS));
  }
コード例 #2
0
 @Test
 public void testAlterPartitionedTablePartition() throws Exception {
   AlterTableAnalyzedStatement analysis =
       (AlterTableAnalyzedStatement)
           analyze(
               "alter table parted partition (date=1395874800000) set (number_of_replicas='0-all')");
   assertThat(analysis.partitionName().isPresent(), is(true));
   assertThat(
       analysis.partitionName().get(),
       is(new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000")))));
   assertThat(
       analysis.table().tableParameterInfo(),
       instanceOf(AlterPartitionedTableParameterInfo.class));
   AlterPartitionedTableParameterInfo tableSettingsInfo =
       (AlterPartitionedTableParameterInfo) analysis.table().tableParameterInfo();
   assertThat(
       tableSettingsInfo.partitionTableSettingsInfo(), instanceOf(TableParameterInfo.class));
   assertEquals(
       "0-all", analysis.tableParameter().settings().get(TableParameterInfo.AUTO_EXPAND_REPLICAS));
 }