Search in sources :

Example 16 with BlockSpiller

use of com.amazonaws.athena.connector.lambda.data.BlockSpiller in project foundry-athena-query-federation-connector by palantir.

the class PartitionValueRoundTripTests method partitionValueRoundTrip.

@ParameterizedTest
@MethodSource
void partitionValueRoundTrip(ArrowType arrowType, PartitionValue partitionValue, FilterValue filterValue) {
    BlockSpiller blockSpiller = new InMemorySingleBlockSpiller(new Schema(ImmutableList.of(new Field(FIELD_NAME, FieldType.nullable(arrowType), ImmutableList.of()))), ConstraintEvaluator.emptyEvaluator());
    blockSpiller.writeRows((block, _rowIdx) -> {
        partitionValue.accept(new PartitionValueWriter(block, FIELD_NAME, 0));
        return 1;
    });
    FieldReader fieldReader = blockSpiller.getBlock().getFieldReader(FIELD_NAME);
    assertThat(arrowType.accept(new FilterValueReader(fieldReader))).isEqualTo(filterValue);
    blockSpiller.close();
}
Also used : Field(org.apache.arrow.vector.types.pojo.Field) Schema(org.apache.arrow.vector.types.pojo.Schema) FieldReader(org.apache.arrow.vector.complex.reader.FieldReader) BlockSpiller(com.amazonaws.athena.connector.lambda.data.BlockSpiller) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 17 with BlockSpiller

use of com.amazonaws.athena.connector.lambda.data.BlockSpiller in project aws-athena-query-federation by awslabs.

the class ThrottlingInvokerTest method invokeWithThrottleNoSpill.

@Test(expected = FederationThrottleException.class)
public void invokeWithThrottleNoSpill() throws TimeoutException {
    BlockSpiller spiller = mock(BlockSpiller.class);
    ThrottlingInvoker invoker = ThrottlingInvoker.newBuilder().withDecrease(0.5).withIncrease(10).withInitialDelayMs(10).withMaxDelayMs(500).withFilter((Exception ex) -> ex instanceof RuntimeException).withSpiller(spiller).build();
    when(spiller.spilled()).thenReturn(false);
    invoker.invoke(() -> {
        throw new RuntimeException();
    }, 2_000);
}
Also used : FederationThrottleException(com.amazonaws.athena.connector.lambda.exceptions.FederationThrottleException) TimeoutException(java.util.concurrent.TimeoutException) BlockSpiller(com.amazonaws.athena.connector.lambda.data.BlockSpiller) Test(org.junit.Test)

Example 18 with BlockSpiller

use of com.amazonaws.athena.connector.lambda.data.BlockSpiller in project aws-athena-query-federation by awslabs.

the class HiveMuxRecordHandlerTest method readWithConstraint.

@Test
public void readWithConstraint() throws SQLException {
    BlockSpiller blockSpiller = Mockito.mock(BlockSpiller.class);
    ReadRecordsRequest readRecordsRequest = Mockito.mock(ReadRecordsRequest.class);
    Mockito.when(readRecordsRequest.getCatalogName()).thenReturn("recordHive");
    this.jdbcRecordHandler.readWithConstraint(blockSpiller, readRecordsRequest, queryStatusChecker);
    Mockito.verify(this.hiveRecordHandler, Mockito.times(1)).readWithConstraint(Mockito.eq(blockSpiller), Mockito.eq(readRecordsRequest), Mockito.eq(queryStatusChecker));
}
Also used : ReadRecordsRequest(com.amazonaws.athena.connector.lambda.records.ReadRecordsRequest) BlockSpiller(com.amazonaws.athena.connector.lambda.data.BlockSpiller) Test(org.junit.Test)

Example 19 with BlockSpiller

use of com.amazonaws.athena.connector.lambda.data.BlockSpiller in project aws-athena-query-federation by awslabs.

the class HiveMuxRecordHandlerTest method readWithConstraintWithUnsupportedCatalog.

@Test(expected = RuntimeException.class)
public void readWithConstraintWithUnsupportedCatalog() throws SQLException {
    BlockSpiller blockSpiller = Mockito.mock(BlockSpiller.class);
    ReadRecordsRequest readRecordsRequest = Mockito.mock(ReadRecordsRequest.class);
    Mockito.when(readRecordsRequest.getCatalogName()).thenReturn("unsupportedCatalog");
    this.jdbcRecordHandler.readWithConstraint(blockSpiller, readRecordsRequest, queryStatusChecker);
}
Also used : ReadRecordsRequest(com.amazonaws.athena.connector.lambda.records.ReadRecordsRequest) BlockSpiller(com.amazonaws.athena.connector.lambda.data.BlockSpiller) Test(org.junit.Test)

Example 20 with BlockSpiller

use of com.amazonaws.athena.connector.lambda.data.BlockSpiller in project aws-athena-query-federation by awslabs.

the class MySqlMuxJdbcRecordHandlerTest method readWithConstraintWithUnsupportedCatalog.

@Test(expected = RuntimeException.class)
public void readWithConstraintWithUnsupportedCatalog() {
    BlockSpiller blockSpiller = Mockito.mock(BlockSpiller.class);
    ReadRecordsRequest readRecordsRequest = Mockito.mock(ReadRecordsRequest.class);
    Mockito.when(readRecordsRequest.getCatalogName()).thenReturn("unsupportedCatalog");
    this.jdbcRecordHandler.readWithConstraint(blockSpiller, readRecordsRequest, queryStatusChecker);
}
Also used : ReadRecordsRequest(com.amazonaws.athena.connector.lambda.records.ReadRecordsRequest) BlockSpiller(com.amazonaws.athena.connector.lambda.data.BlockSpiller) Test(org.junit.Test)

Aggregations

BlockSpiller (com.amazonaws.athena.connector.lambda.data.BlockSpiller)32 Test (org.junit.Test)31 ReadRecordsRequest (com.amazonaws.athena.connector.lambda.records.ReadRecordsRequest)30 S3BlockSpiller (com.amazonaws.athena.connector.lambda.data.S3BlockSpiller)2 SpillConfig (com.amazonaws.athena.connector.lambda.data.SpillConfig)2 ConstraintEvaluator (com.amazonaws.athena.connector.lambda.domain.predicate.ConstraintEvaluator)2 Constraints (com.amazonaws.athena.connector.lambda.domain.predicate.Constraints)2 S3SpillLocation (com.amazonaws.athena.connector.lambda.domain.spill.S3SpillLocation)2 QueryStatusChecker (com.amazonaws.athena.connector.lambda.QueryStatusChecker)1 BlockAllocator (com.amazonaws.athena.connector.lambda.data.BlockAllocator)1 BlockAllocatorImpl (com.amazonaws.athena.connector.lambda.data.BlockAllocatorImpl)1 FieldBuilder (com.amazonaws.athena.connector.lambda.data.FieldBuilder)1 SchemaBuilder (com.amazonaws.athena.connector.lambda.data.SchemaBuilder)1 com.amazonaws.athena.connector.lambda.data.writers.extractors (com.amazonaws.athena.connector.lambda.data.writers.extractors)1 Split (com.amazonaws.athena.connector.lambda.domain.Split)1 TableName (com.amazonaws.athena.connector.lambda.domain.TableName)1 EquatableValueSet (com.amazonaws.athena.connector.lambda.domain.predicate.EquatableValueSet)1 ValueSet (com.amazonaws.athena.connector.lambda.domain.predicate.ValueSet)1 FederationThrottleException (com.amazonaws.athena.connector.lambda.exceptions.FederationThrottleException)1 GetTableRequest (com.amazonaws.athena.connector.lambda.metadata.GetTableRequest)1