Search in sources :

Example 1 with Filter

use of com.palantir.foundry.athena.api.Filter in project foundry-athena-query-federation-connector by palantir.

the class ConstraintConverterTests method testConvert.

@ParameterizedTest
@MethodSource
void testConvert(ValueSet valueSet, Filter expected) {
    Filter actual = ConstraintConverter.convert(COLUMN, valueSet);
    assertThat(actual).isEqualTo(expected);
}
Also used : Filter(com.palantir.foundry.athena.api.Filter) AndFilter(com.palantir.foundry.athena.api.AndFilter) FalseFilter(com.palantir.foundry.athena.api.FalseFilter) NullFilter(com.palantir.foundry.athena.api.NullFilter) NotFilter(com.palantir.foundry.athena.api.NotFilter) ValueFilter(com.palantir.foundry.athena.api.ValueFilter) OrFilter(com.palantir.foundry.athena.api.OrFilter) TrueFilter(com.palantir.foundry.athena.api.TrueFilter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with Filter

use of com.palantir.foundry.athena.api.Filter in project foundry-athena-query-federation-connector by palantir.

the class SplitsFetcher method getSplits.

GetSplitsResponse getSplits(GetSplitsRequest request, SpillLocationFactory spillLocationFactory, EncryptionKey encryptionKey) {
    CatalogLocator locator = FoundryAthenaObjectMapper.objectMapper().convertValue(request.getSchema().getCustomMetadata(), CatalogLocator.class);
    Optional<Filter> filter;
    if (request.getConstraints().getSummary().isEmpty()) {
        filter = Optional.empty();
    } else {
        // we just push down all constraints which will include those for any partition columns
        filter = Optional.of(Filter.and(AndFilter.of(request.getConstraints().getSummary().entrySet().stream().map(entry -> ConstraintConverter.convert(entry.getKey(), entry.getValue())).collect(Collectors.toList()))));
    }
    Set<Split> splits = new HashSet<>();
    Optional<String> pageToken = Optional.empty();
    while (true) {
        GetSlicesResponse response = metadataService.getSlices(authProvider.getAuthHeader(), GetSlicesRequest.builder().locator(locator).filter(filter).nextPageToken(pageToken).build());
        splits.addAll(response.getSlices().stream().map(slice -> slices.toSplit(spillLocationFactory.makeSpillLocation(), encryptionKey, slice)).collect(Collectors.toSet()));
        if (response.getNextPageToken().isPresent()) {
            pageToken = response.getNextPageToken();
        } else {
            log.debug("finished planning splits. number of splits: {}", splits.size());
            return new GetSplitsResponse(request.getCatalogName(), splits);
        }
    }
}
Also used : CatalogLocator(com.palantir.foundry.athena.api.CatalogLocator) GetSplitsResponse(com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse) Filter(com.palantir.foundry.athena.api.Filter) Logger(org.slf4j.Logger) CatalogLocator(com.palantir.foundry.athena.api.CatalogLocator) Split(com.amazonaws.athena.connector.lambda.domain.Split) LoggerFactory(org.slf4j.LoggerFactory) GetSlicesRequest(com.palantir.foundry.athena.api.GetSlicesRequest) Set(java.util.Set) SpillLocation(com.amazonaws.athena.connector.lambda.domain.spill.SpillLocation) GetSlicesResponse(com.palantir.foundry.athena.api.GetSlicesResponse) Collectors(java.util.stream.Collectors) AndFilter(com.palantir.foundry.athena.api.AndFilter) HashSet(java.util.HashSet) FoundryAthenaMetadataServiceBlocking(com.palantir.foundry.athena.api.FoundryAthenaMetadataServiceBlocking) EncryptionKey(com.amazonaws.athena.connector.lambda.security.EncryptionKey) Optional(java.util.Optional) GetSplitsRequest(com.amazonaws.athena.connector.lambda.metadata.GetSplitsRequest) GetSlicesResponse(com.palantir.foundry.athena.api.GetSlicesResponse) Filter(com.palantir.foundry.athena.api.Filter) AndFilter(com.palantir.foundry.athena.api.AndFilter) GetSplitsResponse(com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse) Split(com.amazonaws.athena.connector.lambda.domain.Split) HashSet(java.util.HashSet)

Aggregations

AndFilter (com.palantir.foundry.athena.api.AndFilter)2 Filter (com.palantir.foundry.athena.api.Filter)2 Split (com.amazonaws.athena.connector.lambda.domain.Split)1 SpillLocation (com.amazonaws.athena.connector.lambda.domain.spill.SpillLocation)1 GetSplitsRequest (com.amazonaws.athena.connector.lambda.metadata.GetSplitsRequest)1 GetSplitsResponse (com.amazonaws.athena.connector.lambda.metadata.GetSplitsResponse)1 EncryptionKey (com.amazonaws.athena.connector.lambda.security.EncryptionKey)1 CatalogLocator (com.palantir.foundry.athena.api.CatalogLocator)1 FalseFilter (com.palantir.foundry.athena.api.FalseFilter)1 FoundryAthenaMetadataServiceBlocking (com.palantir.foundry.athena.api.FoundryAthenaMetadataServiceBlocking)1 GetSlicesRequest (com.palantir.foundry.athena.api.GetSlicesRequest)1 GetSlicesResponse (com.palantir.foundry.athena.api.GetSlicesResponse)1 NotFilter (com.palantir.foundry.athena.api.NotFilter)1 NullFilter (com.palantir.foundry.athena.api.NullFilter)1 OrFilter (com.palantir.foundry.athena.api.OrFilter)1 TrueFilter (com.palantir.foundry.athena.api.TrueFilter)1 ValueFilter (com.palantir.foundry.athena.api.ValueFilter)1 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1