use of com.hazelcast.jet.sql.impl.opt.metadata.WatermarkedFields in project hazelcast by hazelcast.
the class AggregateSlidingWindowPhysicalRule method findWatermarkedField.
/**
* Extract watermarked column index
* (possibly) enforced by IMPOSE_ORDER.
*
* @return watermarked column index.
*/
@Nullable
private static Integer findWatermarkedField(AggregateLogicalRel logicalAggregate, RelNode input) {
// TODO: [viliam, sasha] besides watermark order, we can also use normal collation
HazelcastRelMetadataQuery query = OptUtils.metadataQuery(input);
WatermarkedFields watermarkedFields = query.extractWatermarkedFields(input);
if (watermarkedFields == null) {
return null;
}
Entry<Integer, RexNode> watermarkedField = watermarkedFields.findFirst(logicalAggregate.getGroupSet());
return watermarkedField != null ? watermarkedField.getKey() : null;
}
use of com.hazelcast.jet.sql.impl.opt.metadata.WatermarkedFields in project hazelcast by hazelcast.
the class SlidingWindowAggregatePhysicalRel method watermarkedFields.
public WatermarkedFields watermarkedFields() {
Map<Integer, RexNode> propertiesByIndex = new HashMap<>();
RexBuilder rexBuilder = getCluster().getRexBuilder();
for (Integer index : windowEndIndexes) {
propertiesByIndex.put(index, rexBuilder.makeInputRef(getInput(), index));
}
// Backlog: also support windowStartIndexes by adding windowSize to windowStart
return new WatermarkedFields(propertiesByIndex);
}
use of com.hazelcast.jet.sql.impl.opt.metadata.WatermarkedFields in project hazelcast by hazelcast.
the class CalciteSqlOptimizer method detectStandaloneImposeOrder.
// The IMPOSE_ORDER function must also drop late items. We don't have this implemented,
// therefore we detect if, besides IMPOSE_ORDER, there's also streaming window aggregation.
// If not, we throw an error. But we don't cover all cases...
private void detectStandaloneImposeOrder(RelNode rel) {
HazelcastRelMetadataQuery mq = HazelcastRelMetadataQuery.reuseOrCreate(rel.getCluster().getMetadataQuery());
WatermarkedFields wm = mq.extractWatermarkedFields(rel);
if (wm != null && !wm.isEmpty()) {
StreamingAggregationDetector detector = new StreamingAggregationDetector();
detector.go(rel);
if (!detector.found) {
throw QueryException.error("Currently, IMPOSE_ORDER can only be used with window aggregation");
}
}
}
Aggregations