Java Code Examples for com.amazonaws.services.glue.model.Table#getName()
The following examples show how to use
com.amazonaws.services.glue.model.Table#getName() .
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: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test public void testDropPartitionsEmpty() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); List<String> values = Arrays.asList("foo", "bar"); Partition partition = new Partition().withDatabaseName(namespaceName) .withTableName(tableName) .withValues(values) .withStorageDescriptor(TestObjects.getTestStorageDescriptor()); mockGetPartitionsSuccess(Lists.<Partition>newArrayList()); mockBatchDeleteSuccess(); List<org.apache.hadoop.hive.metastore.api.Partition> partitions = metastoreClient.dropPartitions( namespaceName, tableName, Lists.newArrayList(getDumbExpression()), false, false, false); assertEquals(0, partitions.size()); assertDaemonThreadPools(); }
Example 2
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test(expected = IllegalArgumentException.class) public void testDropPartitionsDifferentNamespace() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName1 = testDB.getName(); String tableName1 = table.getName(); String namespaceName2 = namespaceName1 + ".2"; String tableName2 = tableName1 + ".2"; List<String> values1 = Arrays.asList("foo1", "bar1"); List<String> values2 = Arrays.asList("foo2", "bar2"); Partition partition1 = getTestPartition(namespaceName1, tableName1, values1); Partition partition2 = getTestPartition(namespaceName2, tableName2, values2); List<Partition> partitions = Lists.newArrayList(partition1, partition2); mockGetPartitionsSuccess(partitions); mockBatchDeleteSuccess(); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); metastoreClient.dropPartitions(namespaceName1, tableName1, Lists.newArrayList(getDumbExpression()), true, false, false); assertDaemonThreadPools(); }
Example 3
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test public void testDropPartitionsException() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); Partition partition = TestObjects.getTestPartition(namespaceName, tableName, Arrays.asList("foo", "bar")); mockGetPartitionsSuccess(Lists.newArrayList(partition)); mockBatchDeleteThrowsException(new NullPointerException("foo error")); // use NPE as a specific RuntimeException when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); try { metastoreClient.dropPartitions(namespaceName, tableName, Lists.newArrayList(getDumbExpression()), true, false, false); fail("should throw"); } catch (TException e) { verify(glueClient, times(1)).batchDeletePartition(any(BatchDeletePartitionRequest.class)); verify(wh, never()).deleteDir(any(Path.class), anyBoolean(), anyBoolean()); assertThat(e, is(instanceOf(MetaException.class))); assertThat(e.getMessage(), is("foo error")); assertDaemonThreadPools(); } }
Example 4
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test public void testDropPartitionsClientException() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); Partition partition = TestObjects.getTestPartition(namespaceName, tableName, Arrays.asList("foo", "bar")); mockGetPartitionsSuccess(Lists.newArrayList(partition)); mockBatchDeleteThrowsException(new InvalidInputException("InvalidInputException")); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); try { metastoreClient.dropPartitions(namespaceName, tableName, Lists.newArrayList(getDumbExpression()), true, false, false); fail("should throw"); } catch (TException e) { verify(glueClient, times(1)).batchDeletePartition(any(BatchDeletePartitionRequest.class)); verify(glueClient, never()).getPartition(any(GetPartitionRequest.class)); verify(wh, never()).deleteDir(any(Path.class), anyBoolean(), anyBoolean()); assertThat(e, is(instanceOf(InvalidObjectException.class))); assertThat(e.getMessage(), containsString("InvalidInputException")); } assertDaemonThreadPools(); }
Example 5
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test public void testDropPartitionsSucceed() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); List<String> values1 = Arrays.asList("foo1", "bar1"); List<String> values2 = Arrays.asList("foo2", "bar2"); Partition partition1 = getTestPartition(namespaceName, tableName, values1); Partition partition2 = getTestPartition(namespaceName, tableName, values2); List<Partition> partitions = Lists.newArrayList(partition1, partition2); List<org.apache.hadoop.hive.metastore.api.Partition> hivePartitions = CatalogToHiveConverter.convertPartitions(partitions); mockGetPartitionsSuccess(partitions); mockBatchDeleteSuccess(); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); List<org.apache.hadoop.hive.metastore.api.Partition> partitionsDropped = metastoreClient.dropPartitions( namespaceName, tableName, Lists.newArrayList(getDumbExpression()), true, false, false); verify(glueClient, times(1)).batchDeletePartition(any(BatchDeletePartitionRequest.class)); verify(wh, times(2)).deleteDir(any(Path.class), eq(true), eq(false)); assertEquals(hivePartitions, partitionsDropped); assertDaemonThreadPools(); }
Example 6
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test public void testDropPartitionsServiceException() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); List<String> values1 = Arrays.asList("foo1", "bar1"); List<String> values2 = Arrays.asList("foo2", "bar2"); List<String> values3 = Arrays.asList("foo3", "bar3"); Partition partition1 = getTestPartition(namespaceName, tableName, values1); Partition partition2 = getTestPartition(namespaceName, tableName, values2); Partition partition3 = getTestPartition(namespaceName, tableName, values3); List<Partition> partitions = Lists.newArrayList(partition1, partition2, partition3); List<org.apache.hadoop.hive.metastore.api.Partition> hivePartitions = CatalogToHiveConverter.convertPartitions(partitions); mockGetPartitionsSuccess(partitions); mockBatchDeleteThrowsException(new InternalServiceException("InternalServiceException")); when(glueClient.getPartition(any(GetPartitionRequest.class))) .thenReturn(new GetPartitionResult().withPartition(partition1)) .thenThrow(new EntityNotFoundException("EntityNotFoundException")) .thenThrow(new NullPointerException("NullPointerException")); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); try { metastoreClient.dropPartitions(namespaceName, tableName, Lists.newArrayList(getDumbExpression()), true, false, false); fail("should throw"); } catch (TException e) { verify(glueClient, times(1)).batchDeletePartition(any(BatchDeletePartitionRequest.class)); verify(glueClient, times(3)).getPartition(any(GetPartitionRequest.class)); verify(wh, times(1)).deleteDir(any(Path.class), eq(true), eq(false)); assertThat(e, is(instanceOf(MetaException.class))); assertThat(e.getMessage(), containsString("InternalServiceException")); assertDaemonThreadPools(); } }
Example 7
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test public void testDropPartitionsExceptionTwoPages() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); final int pageSize = 25; final int reqSize = (int) (pageSize * 1.5); // 2 pages List<Partition> partitions = Lists.newArrayList(); for (int i = 0; i < reqSize; i++) { partitions.add(TestObjects.getTestPartition(namespaceName, tableName, Arrays.asList("" + i))); } mockGetPartitionsSuccess(partitions); when(glueClient.batchDeletePartition(Mockito.any(BatchDeletePartitionRequest.class))) .thenThrow(new InternalServiceException("InternalServiceException")); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); when(glueClient.getPartition(any(GetPartitionRequest.class))) .thenReturn(new GetPartitionResult().withPartition(partitions.get(0))) .thenThrow(new EntityNotFoundException("EntityNotFoundException")) .thenThrow(new NullPointerException("NullPointerException")); try { metastoreClient.dropPartitions(namespaceName, tableName, Lists.newArrayList(getDumbExpression()), true, false, false); fail("should throw"); } catch (TException e) { verify(glueClient, times(2)).batchDeletePartition(any(BatchDeletePartitionRequest.class)); verify(glueClient, times(reqSize)).getPartition(any(GetPartitionRequest.class)); verify(wh, times(1)).deleteDir(any(Path.class), eq(true), eq(false)); assertThat(e, is(instanceOf(MetaException.class))); assertThat(e.getMessage(), containsString("InternalServiceException")); assertDaemonThreadPools(); } }
Example 8
Source File: AWSCatalogMetastoreClientTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test public void testDropPartitionsPartialFailure() throws Exception { Table table = HiveToCatalogConverter.convertTable(testTable); String namespaceName = testDB.getName(); String tableName = table.getName(); List<String> values1 = Arrays.asList("foo1", "bar1"); List<String> values2 = Arrays.asList("foo2", "bar2"); Partition partition1 = getTestPartition(namespaceName, tableName, values1); Partition partition2 = getTestPartition(namespaceName, tableName, values2); List<Partition> partitions = Lists.newArrayList(partition1, partition2); mockGetPartitionsSuccess(partitions); mockBatchDeleteWithFailures(Lists.newArrayList(getPartitionError(values1, new EntityNotFoundException("EntityNotFoundException")))); when(glueClient.getTable(any(GetTableRequest.class))) .thenReturn(new GetTableResult().withTable(HiveToCatalogConverter.convertTable(testTable))); try { metastoreClient.dropPartitions(namespaceName, tableName, Lists.newArrayList(getDumbExpression()), true, false, false); fail("should throw"); } catch (TException e) { verify(glueClient, times(1)).batchDeletePartition(any(BatchDeletePartitionRequest.class)); verify(glueClient, never()).getPartition(any(GetPartitionRequest.class)); verify(wh, times(1)).deleteDir(any(Path.class), eq(true), eq(false)); assertThat(e, is(instanceOf(NoSuchObjectException.class))); assertThat(e.getMessage(), containsString("EntityNotFoundException")); assertDaemonThreadPools(); } }