org.apache.hadoop.hive.metastore.api.SetPartitionsStatsRequest Java Examples

The following examples show how to use org.apache.hadoop.hive.metastore.api.SetPartitionsStatsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatabaseMappingImplTest.java    From waggle-dance with Apache License 2.0 6 votes vote down vote up
@Test
public void transformInboundSetPartitionStatsRequest() throws Exception {
  SetPartitionsStatsRequest setPartitionsStatsRequest = new SetPartitionsStatsRequest();
  ColumnStatistics columnStatistics = new ColumnStatistics();
  ColumnStatisticsDesc statsDesc = new ColumnStatisticsDesc();
  statsDesc.setDbName(DB_NAME);
  columnStatistics.setStatsDesc(statsDesc);
  setPartitionsStatsRequest.setColStats(Lists.newArrayList(columnStatistics));
  SetPartitionsStatsRequest result = databaseMapping
      .transformInboundSetPartitionStatsRequest(setPartitionsStatsRequest);
  assertThat(result, is(sameInstance(setPartitionsStatsRequest)));
  ColumnStatistics resultColStats = result.getColStats().get(0);
  assertThat(resultColStats, is(sameInstance(columnStatistics)));
  assertThat(resultColStats.getStatsDesc(), is(sameInstance(statsDesc)));
  assertThat(resultColStats.getStatsDesc().getDbName(), is(IN_DB_NAME));
}
 
Example #2
Source File: DatabaseMappingImpl.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
public SetPartitionsStatsRequest transformInboundSetPartitionStatsRequest(SetPartitionsStatsRequest request) {
  if (request.isSetColStats()) {
    for (ColumnStatistics stats : request.getColStats()) {
      transformInboundColumnStatistics(stats);
    }
  }
  return request;
}
 
Example #3
Source File: FederatedHMSHandler.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Override
@Loggable(value = Loggable.DEBUG, skipResult = true, name = INVOCATION_LOG_NAME)
public boolean set_aggr_stats_for(SetPartitionsStatsRequest request)
    throws NoSuchObjectException, InvalidObjectException, MetaException, InvalidInputException, TException {
  if (!request.getColStats().isEmpty()) {
    DatabaseMapping mapping = databaseMappingService
        .databaseMapping(request.getColStats().get(0).getStatsDesc().getDbName());
    for (ColumnStatistics stats : request.getColStats()) {
      mapping.checkWritePermissions(stats.getStatsDesc().getDbName());
    }
    return mapping.getClient().set_aggr_stats_for(mapping.transformInboundSetPartitionStatsRequest(request));
  }
  return false;
}
 
Example #4
Source File: IdentityMappingTest.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Test
public void transformInboundSetPartitionStatsRequest() throws Exception {
  SetPartitionsStatsRequest setPartitionsStatsRequest = new SetPartitionsStatsRequest();
  SetPartitionsStatsRequest result = databaseMapping
      .transformInboundSetPartitionStatsRequest(setPartitionsStatsRequest);
  assertThat(result, is(sameInstance(setPartitionsStatsRequest)));
}
 
Example #5
Source File: IdentityMappingTest.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Test
public void transformInboundSetPartitionStatsRequestNoColumnStats() throws Exception {
  SetPartitionsStatsRequest setPartitionsStatsRequest = new SetPartitionsStatsRequest();
  SetPartitionsStatsRequest result = databaseMapping
      .transformInboundSetPartitionStatsRequest(setPartitionsStatsRequest);
  assertThat(result, is(sameInstance(setPartitionsStatsRequest)));
}
 
Example #6
Source File: DatabaseMappingImplTest.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Test
public void transformInboundSetPartitionStatsRequestNoColumnStats() throws Exception {
  SetPartitionsStatsRequest setPartitionsStatsRequest = new SetPartitionsStatsRequest();
  SetPartitionsStatsRequest result = databaseMapping
      .transformInboundSetPartitionStatsRequest(setPartitionsStatsRequest);
  assertThat(result, is(sameInstance(setPartitionsStatsRequest)));
  assertFalse(result.isSetColStats());
}
 
Example #7
Source File: FederatedHMSHandlerTest.java    From waggle-dance with Apache License 2.0 5 votes vote down vote up
@Test
public void set_aggr_stats_for() throws TException {
  ColumnStatisticsDesc statsDesc = new ColumnStatisticsDesc(true, DB_P, "table");
  ColumnStatistics colStatistics = new ColumnStatistics(statsDesc, Collections.emptyList());
  List<ColumnStatistics> colStats = Collections.singletonList(colStatistics);
  SetPartitionsStatsRequest request = new SetPartitionsStatsRequest(colStats);
  SetPartitionsStatsRequest inboundRequest = new SetPartitionsStatsRequest();
  when(primaryMapping.transformInboundSetPartitionStatsRequest(request)).thenReturn(inboundRequest);
  when(primaryClient.set_aggr_stats_for(inboundRequest)).thenReturn(true);
  boolean result = handler.set_aggr_stats_for(request);
  assertThat(result, is(true));
}
 
Example #8
Source File: ReplicaTest.java    From circus-train with Apache License 2.0 4 votes vote down vote up
@Test
public void alteringExistingPartitionedReplicaViewWithPartitionsSucceeds() throws Exception, IOException {
  convertSourceTableToView();
  convertExistingReplicaTableToView();
  Partition newPartition = newPartition("three", "four");
  newPartition.getSd().setLocation(null);
  ColumnStatistics newPartitionStatistics = newPartitionStatistics("three", "four");
  Partition modifiedPartition = new Partition(existingPartition);
  ColumnStatistics modifiedPartitionStatistics = newPartitionStatistics("one", "two");
  when(mockMetaStoreClient
      .getPartitionsByNames(DB_NAME, TABLE_NAME, Lists.newArrayList("c=one/d=two", "c=three/d=four")))
          .thenReturn(Arrays.asList(existingPartition));

  Map<String, List<ColumnStatisticsObj>> partitionStatsMap = new HashMap<>();
  partitionStatsMap
      .put(Warehouse.makePartName(PARTITIONS, newPartition.getValues()), newPartitionStatistics.getStatsObj());
  partitionStatsMap
      .put(Warehouse.makePartName(PARTITIONS, modifiedPartition.getValues()),
          modifiedPartitionStatistics.getStatsObj());

  PartitionsAndStatistics partitionsAndStatistics = new PartitionsAndStatistics(sourceTable.getPartitionKeys(),
      Arrays.asList(modifiedPartition, newPartition), partitionStatsMap);

  existingReplicaTable.getParameters().put(REPLICATION_EVENT.parameterName(), "previousEventId");

  replica
      .updateMetadata(EVENT_ID, tableAndStatistics, partitionsAndStatistics, DB_NAME, TABLE_NAME,
          mockReplicaLocationManager);

  verify(alterTableService).alterTable(eq(mockMetaStoreClient), eq(existingReplicaTable), any(Table.class));
  verify(mockMetaStoreClient).updateTableColumnStatistics(columnStatistics);
  verify(mockMetaStoreClient).alter_partitions(eq(DB_NAME), eq(TABLE_NAME), alterPartitionCaptor.capture());
  verify(mockMetaStoreClient).add_partitions(addPartitionCaptor.capture());
  verify(mockReplicaLocationManager, never()).addCleanUpLocation(anyString(), any(Path.class));

  assertThat(alterPartitionCaptor.getValue().size(), is(1));
  assertThat(addPartitionCaptor.getValue().size(), is(1));

  Partition altered = alterPartitionCaptor.getValue().get(0);
  assertThat(altered.getValues(), is(Arrays.asList("one", "two")));

  Partition added = addPartitionCaptor.getValue().get(0);
  assertThat(added.getValues(), is(Arrays.asList("three", "four")));

  verify(mockMetaStoreClient).setPartitionColumnStatistics(setStatsRequestCaptor.capture());
  SetPartitionsStatsRequest statsRequest = setStatsRequestCaptor.getValue();

  List<ColumnStatistics> columnStats = new ArrayList<>(statsRequest.getColStats());
  Collections.sort(columnStats, new Comparator<ColumnStatistics>() {
    @Override
    public int compare(ColumnStatistics o1, ColumnStatistics o2) {
      return o1.getStatsDesc().getPartName().compareTo(o2.getStatsDesc().getPartName());
    }
  });
  assertThat(columnStats.size(), is(2));

  assertThat(columnStats.get(0).getStatsDesc().isIsTblLevel(), is(false));
  assertThat(columnStats.get(0).getStatsDesc().getDbName(), is(DB_NAME));
  assertThat(columnStats.get(0).getStatsDesc().getTableName(), is(TABLE_NAME));
  assertThat(columnStats.get(0).getStatsDesc().getPartName(), is("c=one/d=two"));
  assertThat(columnStats.get(0).getStatsObj().size(), is(2));
  assertThat(columnStats.get(1).getStatsDesc().isIsTblLevel(), is(false));
  assertThat(columnStats.get(1).getStatsDesc().getDbName(), is(DB_NAME));
  assertThat(columnStats.get(1).getStatsDesc().getTableName(), is(TABLE_NAME));
  assertThat(columnStats.get(1).getStatsDesc().getPartName(), is("c=three/d=four"));
  assertThat(columnStats.get(1).getStatsObj().size(), is(2));
}
 
Example #9
Source File: IdentityMapping.java    From waggle-dance with Apache License 2.0 4 votes vote down vote up
@Override
public SetPartitionsStatsRequest transformInboundSetPartitionStatsRequest(SetPartitionsStatsRequest request) {
  return request;
}
 
Example #10
Source File: CatalogThriftHiveMetastore.java    From metacat with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean set_aggr_stats_for(final SetPartitionsStatsRequest request) throws TException {
    throw unimplemented("set_aggr_stats_for", new Object[]{request});
}
 
Example #11
Source File: DatabaseMapping.java    From waggle-dance with Apache License 2.0 votes vote down vote up
SetPartitionsStatsRequest transformInboundSetPartitionStatsRequest(SetPartitionsStatsRequest request);