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_streamToStreamJoin_then_returnMinPostponeTime() {
        HazelcastTable table = streamGeneratorTable("t1", 1);
        HazelcastTable table2 = streamGeneratorTable("t2", 10);
        HazelcastTable table3 = streamGeneratorTable("t3", 100);
        List<QueryDataType> parameterTypes = Collections.singletonList(INT);

        int expectedWindowSize = 20;

        final String query = "SELECT * FROM "
                + joinSubQuery("t1", "s1", 1)
                + " JOIN "
                + joinSubQuery("t2", "s2", 2)
                + " ON s1.v BETWEEN s2.v - 180 AND s2.v + 70 "    // spread = 250
                + " JOIN "
                + joinSubQuery("t3", "s3", 3)
                + " ON s3.v BETWEEN s1.v - 100 AND s1.v + 100 ";   // spread = 200

        PhysicalRel optPhysicalRel = optimizePhysical(query, parameterTypes, table, table2, table3).getPhysical();

        // assert plan for better visibility of what was generated
        assertPlan(optPhysicalRel, plan(
                planRow(0, StreamToStreamJoinPhysicalRel.class),
                planRow(1, StreamToStreamJoinPhysicalRel.class),
                planRow(2, FullScanPhysicalRel.class),
                planRow(2, FullScanPhysicalRel.class),
                planRow(1, FullScanPhysicalRel.class)
        ));

        // GCD(100, 40) = 4
        assertThat(WatermarkThrottlingFrameSizeCalculator.calculate(optPhysicalRel, MOCK_EEC))
                .isEqualTo(expectedWindowSize);
    }