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_twoConsecutiveSlidingWindowsAgg_then_returnGcdOfWindowsSize() {
        HazelcastTable table = streamGeneratorTable("s1", 100);
        HazelcastTable table2 = partitionedTable("map", asList(field(KEY, INT), field(VALUE, INT)), 1);
        List<QueryDataType> parameterTypes = asList(INT, INT);

        final String sql = "SELECT window_end, window_end_inner, v, COUNT(v) FROM " +
                "TABLE(HOP(" +
                "   (SELECT v, window_end AS window_end_inner FROM " +
                "       TABLE(HOP(" +
                "  (SELECT * FROM TABLE(IMPOSE_ORDER((SELECT * FROM TABLE(GENERATE_STREAM(10))), DESCRIPTOR(v), 1)))" +
                "       , DESCRIPTOR(v), 6, 2" +
                "       )) GROUP BY v, window_end_inner" +
                "   )" +
                "   , DESCRIPTOR(window_end_inner), 15, 5" +
                ")) " +
                "GROUP BY window_end, window_end_inner, v";

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

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

        // GCD(15, 6) = 3
        assertThat(WatermarkThrottlingFrameSizeCalculator.calculate(optimizedPhysicalRel, MOCK_EEC))
                .isEqualTo(1L);
    }