public static long calculate(PhysicalRel rel, ExpressionEvalContext evalContext) {
        GcdCalculatorVisitor visitor = new GcdCalculatorVisitor(evalContext);
        visitor.go(rel);

        if (visitor.gcd == 0) {
            // there's no window aggr in the rel, return the value for joins, which is already capped at some reasonable value
            return visitor.maximumIntervalForJoins;
        }
        // if there's window aggr, cap it with the maximumIntervalForJoins
        return Math.min(visitor.gcd, visitor.maximumIntervalForJoins);
    }
@Test
    public void when_onlySlidingWindowInTree_then_returnWindowSize() {
        HazelcastTable streamTable = streamGeneratorTable("_stream", 10);
        List<QueryDataType> parameterTypes = Collections.singletonList(INT);

        final String sql = "SELECT MAX(v) FROM " +
                "TABLE(HOP(" +
                "  (SELECT * FROM TABLE(IMPOSE_ORDER((SELECT * FROM TABLE(GENERATE_STREAM(10))), DESCRIPTOR(v), 1)))" +
                "  , DESCRIPTOR(v) , 6, 3)) " +
                "GROUP BY window_start, v";

        PhysicalRel optimizedPhysicalRel = optimizePhysical(sql, parameterTypes, streamTable).getPhysical();

        assertPlan(optimizedPhysicalRel, plan(
                planRow(0, CalcPhysicalRel.class),
                planRow(1, SlidingWindowAggregatePhysicalRel.class),
                planRow(2, CalcPhysicalRel.class),
                planRow(3, FullScanPhysicalRel.class)
        ));

        assertThat(WatermarkThrottlingFrameSizeCalculator.calculate(optimizedPhysicalRel, MOCK_EEC))
                .isEqualTo(3L);
    }