|
30 | 30 | import com.amazonaws.athena.connector.lambda.domain.predicate.QueryPlan; |
31 | 31 | import com.amazonaws.athena.connector.lambda.domain.spill.S3SpillLocation; |
32 | 32 | import com.amazonaws.athena.connector.lambda.domain.spill.SpillLocation; |
| 33 | +import com.amazonaws.athena.connector.lambda.exceptions.AthenaConnectorException; |
33 | 34 | import com.amazonaws.athena.connector.lambda.metadata.GetTableRequest; |
34 | 35 | import com.amazonaws.athena.connector.lambda.metadata.GetTableResponse; |
35 | 36 | import com.amazonaws.athena.connector.lambda.metadata.glue.GlueFieldLexer; |
|
49 | 50 | import org.apache.arrow.vector.util.JsonStringArrayList; |
50 | 51 | import org.apache.arrow.vector.util.JsonStringHashMap; |
51 | 52 | import org.junit.After; |
| 53 | +import org.junit.Assert; |
52 | 54 | import org.junit.Before; |
53 | 55 | import org.junit.Rule; |
54 | 56 | import org.junit.Test; |
|
64 | 66 | import software.amazon.awssdk.services.glue.GlueClient; |
65 | 67 | import software.amazon.awssdk.services.glue.model.Column; |
66 | 68 | import software.amazon.awssdk.services.glue.model.EntityNotFoundException; |
| 69 | +import software.amazon.awssdk.services.glue.model.FederationSourceErrorCode; |
67 | 70 | import software.amazon.awssdk.services.glue.model.StorageDescriptor; |
68 | 71 | import software.amazon.awssdk.services.glue.model.Table; |
69 | 72 | import software.amazon.awssdk.services.s3.S3Client; |
|
96 | 99 | import static com.amazonaws.services.dynamodbv2.document.ItemUtils.toAttributeValue; |
97 | 100 | import static com.amazonaws.util.json.Jackson.toJsonString; |
98 | 101 | import static org.junit.Assert.assertEquals; |
| 102 | +import static org.junit.Assert.assertThrows; |
99 | 103 | import static org.junit.Assert.assertTrue; |
100 | 104 | import static org.mockito.ArgumentMatchers.any; |
101 | 105 | import static org.mockito.Mockito.mock; |
@@ -964,6 +968,33 @@ public void testNumStructWithSchemaFromGlueTable() throws Exception |
964 | 968 | assertEquals(numMapReader.reader("key2").readInteger(), (Integer) 2); |
965 | 969 | } |
966 | 970 |
|
| 971 | + @Test |
| 972 | + public void testResourceNotFoundExceptionHandling() throws Exception |
| 973 | + { |
| 974 | + Split split = Split.newBuilder(SPILL_LOCATION, keyFactory.create()) |
| 975 | + .add(TABLE_METADATA, "nonexistent_table") |
| 976 | + .add(SEGMENT_ID_PROPERTY, "0") |
| 977 | + .add(SEGMENT_COUNT_METADATA, "1") |
| 978 | + .build(); |
| 979 | + |
| 980 | + ReadRecordsRequest request = new ReadRecordsRequest( |
| 981 | + TEST_IDENTITY, |
| 982 | + TEST_CATALOG_NAME, |
| 983 | + TEST_QUERY_ID, |
| 984 | + new TableName(DEFAULT_SCHEMA, "nonexistent_table"), |
| 985 | + schema, |
| 986 | + split, |
| 987 | + new Constraints(Collections.emptyMap(), Collections.emptyList(), Collections.emptyList(), DEFAULT_NO_LIMIT, Collections.emptyMap(), null), |
| 988 | + 100_000_000_000L, |
| 989 | + 100_000_000_000L); |
| 990 | + |
| 991 | + AthenaConnectorException exception = assertThrows(AthenaConnectorException.class, () -> { |
| 992 | + handler.doReadRecords(allocator, request); |
| 993 | + }); |
| 994 | + Assert.assertEquals(FederationSourceErrorCode.ENTITY_NOT_FOUND_EXCEPTION.toString(), |
| 995 | + exception.getErrorDetails().errorCode()); |
| 996 | + } |
| 997 | + |
967 | 998 | private long getPackedDateTimeWithZone(String s) |
968 | 999 | { |
969 | 1000 | ZonedDateTime zdt = ZonedDateTime.parse(s); |
|
0 commit comments