use of org.apache.flink.table.catalog.CatalogPartitionSpec in project flink by apache.
the class SqlToOperationConverter method convertShowPartitions.
/**
* Convert SHOW PARTITIONS statement.
*/
private Operation convertShowPartitions(SqlShowPartitions sqlShowPartitions) {
UnresolvedIdentifier unresolvedIdentifier = UnresolvedIdentifier.of(sqlShowPartitions.fullTableName());
ObjectIdentifier tableIdentifier = catalogManager.qualifyIdentifier(unresolvedIdentifier);
LinkedHashMap<String, String> partitionKVs = sqlShowPartitions.getPartitionKVs();
if (partitionKVs != null) {
CatalogPartitionSpec partitionSpec = new CatalogPartitionSpec(partitionKVs);
return new ShowPartitionsOperation(tableIdentifier, partitionSpec);
}
return new ShowPartitionsOperation(tableIdentifier, null);
}
use of org.apache.flink.table.catalog.CatalogPartitionSpec in project flink by apache.
the class TestValuesCatalog method listPartitionsByFilter.
@Override
public List<CatalogPartitionSpec> listPartitionsByFilter(ObjectPath tablePath, List<Expression> filters) throws TableNotExistException, TableNotPartitionedException, CatalogException {
if (!supportListPartitionByFilter) {
throw new UnsupportedOperationException("TestValuesCatalog doesn't support list partition by filters");
}
List<CatalogPartitionSpec> partitions = listPartitions(tablePath);
if (partitions.isEmpty()) {
return partitions;
}
CatalogBaseTable table = this.getTable(tablePath);
TableSchema schema = table.getSchema();
List<ResolvedExpression> resolvedExpressions = filters.stream().map(filter -> {
if (filter instanceof ResolvedExpression) {
return (ResolvedExpression) filter;
}
throw new UnsupportedOperationException(String.format("TestValuesCatalog only works with resolved expressions. Get unresolved expression: %s", filter));
}).collect(Collectors.toList());
return partitions.stream().filter(partition -> {
Function<String, Comparable<?>> getter = getValueGetter(partition.getPartitionSpec(), schema);
return FilterUtils.isRetainedAfterApplyingFilterPredicates(resolvedExpressions, getter);
}).collect(Collectors.toList());
}
Aggregations