from querybuilder.fields import (
    RankField, RowNumberField, DenseRankField, PercentRankField, CumeDistField, NTileField, LagField,
    LeadField, FirstValueField, LastValueField, NthValueField, NumStdDevField
)
from querybuilder.query import QueryWindow, Query
from querybuilder.tests.models import Order
from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str


class QueryWindowTest(QueryTestCase):
    def test_query_window(self):
        query_window = QueryWindow()
        query_str = query_window.get_sql()
        expected_query = 'OVER ()'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_query_window_partition(self):
        query_window = QueryWindow().partition_by('field_one')
        query_str = query_window.get_sql()
        expected_query = 'OVER (PARTITION BY field_one)'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_query_window_order(self):
        query_window = QueryWindow().order_by('field_one')
        query_str = query_window.get_sql()
        expected_query = 'OVER (ORDER BY field_one ASC)'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_query_window_partition_order(self):
        query_window = QueryWindow().partition_by(
            'field_one'
        ).order_by(
            'field_one'
        )
        query_str = query_window.get_sql()
        expected_query = 'OVER (PARTITION BY field_one ORDER BY field_one ASC)'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_query_window_partition_order_many(self):
        query_window = QueryWindow().partition_by(
            'field_one'
        ).partition_by(
            'field_two'
        ).order_by(
            'field_one'
        ).order_by(
            '-field_two'
        )
        query_str = query_window.get_sql()
        expected_query = 'OVER (PARTITION BY field_one, field_two ORDER BY field_one ASC, field_two DESC)'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))


class WindowFunctionTest(QueryTestCase):
    def test_rank_no_over(self):
        query = Query().from_table(
            table=Order,
            fields=[
                RankField()
            ]
        )
        query_str = query.get_sql()
        expected_query = 'SELECT RANK() AS "rank" FROM querybuilder_tests_order'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_rank_over(self):
        query = Query().from_table(
            table=Order,
            fields=[
                RankField(
                    over=QueryWindow()
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = 'SELECT RANK() OVER () AS "rank" FROM querybuilder_tests_order'
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_rank_over_order(self):
        query = Query().from_table(
            table=Order,
            fields=[
                'id',
                RankField(
                    over=QueryWindow().order_by(
                        'id'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.id, RANK() OVER (ORDER BY id ASC) AS "rank" FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_rank_over_partition(self):
        query = Query().from_table(
            table=Order,
            fields=[
                'id',
                RankField(
                    over=QueryWindow().partition_by(
                        'account_id'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.id, RANK() OVER (PARTITION BY account_id) AS "rank" FROM '
            'querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_row_number(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                RowNumberField(
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        ).order_by(
            'row_number'
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'ROW_NUMBER() OVER (ORDER BY margin DESC) AS "row_number" '
            'FROM querybuilder_tests_order '
            'ORDER BY row_number '
            'ASC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_rank(self):
        query = Query().from_table(
            table=Order,
            fields=[
                'id',
                RankField(
                    over=QueryWindow().partition_by(
                        'account_id'
                    ).order_by(
                        'id'
                    )
                )
            ]
        ).order_by(
            '-rank'
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.id, '
            'RANK() OVER (PARTITION BY account_id ORDER BY id ASC) AS "rank" '
            'FROM querybuilder_tests_order '
            'ORDER BY rank '
            'DESC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_dense_rank(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                DenseRankField(
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        ).order_by(
            'dense_rank'
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'DENSE_RANK() OVER (ORDER BY margin DESC) AS "dense_rank" '
            'FROM querybuilder_tests_order '
            'ORDER BY dense_rank '
            'ASC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_rank_percent(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                PercentRankField(
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        ).order_by(
            'percent_rank'
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'PERCENT_RANK() OVER (ORDER BY margin DESC) AS "percent_rank" '
            'FROM querybuilder_tests_order '
            'ORDER BY percent_rank '
            'ASC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_cume_dist(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                CumeDistField(
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        ).order_by(
            'cume_dist'
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'CUME_DIST() OVER (ORDER BY margin DESC) AS "cume_dist" '
            'FROM querybuilder_tests_order '
            'ORDER BY cume_dist '
            'ASC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_ntile(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                NTileField(
                    num_buckets=2,
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        ).order_by(
            'ntile'
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'NTILE(2) OVER (ORDER BY margin DESC) AS "ntile" '
            'FROM querybuilder_tests_order '
            'ORDER BY ntile '
            'ASC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_lag(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                LagField(
                    'margin',
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'LAG(querybuilder_tests_order.margin, 1) OVER (ORDER BY margin DESC) AS "margin_lag" '
            'FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_lag_default(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                LagField(
                    'margin',
                    default=0,
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'LAG(querybuilder_tests_order.margin, 1, \'0\') OVER (ORDER BY margin DESC) AS "margin_lag" '
            'FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_lead(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                LeadField(
                    'margin',
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'LEAD(querybuilder_tests_order.margin, 1) OVER (ORDER BY margin DESC) AS "margin_lead" '
            'FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_first_value(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                FirstValueField(
                    'margin',
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'FIRST_VALUE(querybuilder_tests_order.margin) OVER (ORDER BY margin DESC) AS "margin_first_value" '
            'FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_last_value(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                LastValueField(
                    'margin',
                    over=QueryWindow().order_by(
                        'margin'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'LAST_VALUE(querybuilder_tests_order.margin) OVER (ORDER BY margin ASC) AS "margin_last_value" '
            'FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_nth_value(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                NthValueField(
                    'margin',
                    n=2,
                    over=QueryWindow().order_by(
                        '-margin'
                    )
                )
            ]
        )
        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            'NTH_VALUE(querybuilder_tests_order.margin, 2) OVER (ORDER BY margin DESC) AS "margin_nth_value" '
            'FROM querybuilder_tests_order'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

    def test_num_stddev(self):
        query = Query().from_table(
            table=Order,
            fields=[
                '*',
                NumStdDevField(
                    'margin',
                    over=QueryWindow()
                )
            ]
        ).order_by(
            '-margin_num_stddev'
        )

        query_str = query.get_sql()
        expected_query = (
            'SELECT querybuilder_tests_order.*, '
            '(CASE WHEN (STDDEV(querybuilder_tests_order.margin) OVER ()) <> 0 '
            'THEN ((querybuilder_tests_order.margin - ('
            'AVG(querybuilder_tests_order.margin) OVER ())) / (STDDEV(querybuilder_tests_order.margin) OVER ())) '
            'ELSE 0 '
            'END) '
            'AS "margin_num_stddev" '
            'FROM querybuilder_tests_order '
            'ORDER BY margin_num_stddev '
            'DESC'
        )
        self.assertEqual(query_str, expected_query, get_comparison_str(query_str, expected_query))

[((483, 496), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (494, 496), False, 'from querybuilder.query import QueryWindow, Query\n'), ((627, 672), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (645, 672), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((933, 978), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (951, 978), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((1231, 1276), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (1249, 1276), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((1632, 1677), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (1650, 1677), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((2158, 2203), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (2176, 2203), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((2584, 2629), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (2602, 2629), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((3029, 3074), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (3047, 3074), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((3631, 3676), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (3649, 3676), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((4272, 4317), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (4290, 4317), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((5023, 5068), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (5041, 5068), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((5830, 5875), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (5848, 5875), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((6581, 6626), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (6599, 6626), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((7344, 7389), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (7362, 7389), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((8089, 8134), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (8107, 8134), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((8847, 8892), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (8865, 8892), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((9543, 9588), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (9561, 9588), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((10285, 10330), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (10303, 10330), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((10985, 11030), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (11003, 11030), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((11709, 11754), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (11727, 11754), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((12427, 12472), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (12445, 12472), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((13171, 13216), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (13189, 13216), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((14164, 14209), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', (['query_str', 'expected_query'], {}), '(query_str, expected_query)\n', (14182, 14209), False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((741, 754), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (752, 754), False, 'from querybuilder.query import QueryWindow, Query\n'), ((1043, 1056), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (1054, 1056), False, 'from querybuilder.query import QueryWindow, Query\n'), ((2297, 2304), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (2302, 2304), False, 'from querybuilder.query import QueryWindow, Query\n'), ((2678, 2685), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (2683, 2685), False, 'from querybuilder.query import QueryWindow, Query\n'), ((3129, 3136), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (3134, 3136), False, 'from querybuilder.query import QueryWindow, Query\n'), ((3735, 3742), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (3740, 3742), False, 'from querybuilder.query import QueryWindow, Query\n'), ((8935, 8942), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (8940, 8942), False, 'from querybuilder.query import QueryWindow, Query\n'), ((9639, 9646), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (9644, 9646), False, 'from querybuilder.query import QueryWindow, Query\n'), ((10374, 10381), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (10379, 10381), False, 'from querybuilder.query import QueryWindow, Query\n'), ((11081, 11088), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (11086, 11088), False, 'from querybuilder.query import QueryWindow, Query\n'), ((11804, 11811), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (11809, 11811), False, 'from querybuilder.query import QueryWindow, Query\n'), ((12521, 12528), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (12526, 12528), False, 'from querybuilder.query import QueryWindow, Query\n'), ((2379, 2390), 'querybuilder.fields.RankField', 'RankField', ([], {}), '()\n', (2388, 2390), False, 'from querybuilder.fields import RankField, RowNumberField, DenseRankField, PercentRankField, CumeDistField, NTileField, LagField, LeadField, FirstValueField, LastValueField, NthValueField, NumStdDevField\n'), ((1351, 1364), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (1362, 1364), False, 'from querybuilder.query import QueryWindow, Query\n'), ((4367, 4374), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (4372, 4374), False, 'from querybuilder.query import QueryWindow, Query\n'), ((5112, 5119), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (5117, 5119), False, 'from querybuilder.query import QueryWindow, Query\n'), ((5925, 5932), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (5930, 5932), False, 'from querybuilder.query import QueryWindow, Query\n'), ((6678, 6685), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (6683, 6685), False, 'from querybuilder.query import QueryWindow, Query\n'), ((7438, 7445), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (7443, 7445), False, 'from querybuilder.query import QueryWindow, Query\n'), ((8179, 8186), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (8184, 8186), False, 'from querybuilder.query import QueryWindow, Query\n'), ((13266, 13273), 'querybuilder.query.Query', 'Query', ([], {}), '()\n', (13271, 13273), False, 'from querybuilder.query import QueryWindow, Query\n'), ((2796, 2809), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (2807, 2809), False, 'from querybuilder.query import QueryWindow, Query\n'), ((3269, 3282), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (3280, 3282), False, 'from querybuilder.query import QueryWindow, Query\n'), ((3875, 3888), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (3886, 3888), False, 'from querybuilder.query import QueryWindow, Query\n'), ((9103, 9116), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (9114, 9116), False, 'from querybuilder.query import QueryWindow, Query\n'), ((9838, 9851), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (9849, 9851), False, 'from querybuilder.query import QueryWindow, Query\n'), ((10543, 10556), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (10554, 10556), False, 'from querybuilder.query import QueryWindow, Query\n'), ((11256, 11269), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (11267, 11269), False, 'from querybuilder.query import QueryWindow, Query\n'), ((11978, 11991), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (11989, 11991), False, 'from querybuilder.query import QueryWindow, Query\n'), ((12719, 12732), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (12730, 12732), False, 'from querybuilder.query import QueryWindow, Query\n'), ((13440, 13453), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (13451, 13453), False, 'from querybuilder.query import QueryWindow, Query\n'), ((1757, 1770), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (1768, 1770), False, 'from querybuilder.query import QueryWindow, Query\n'), ((4511, 4524), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (4522, 4524), False, 'from querybuilder.query import QueryWindow, Query\n'), ((6069, 6082), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (6080, 6082), False, 'from querybuilder.query import QueryWindow, Query\n'), ((6824, 6837), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (6835, 6837), False, 'from querybuilder.query import QueryWindow, Query\n'), ((7581, 7594), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (7592, 7594), False, 'from querybuilder.query import QueryWindow, Query\n'), ((8354, 8367), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (8365, 8367), False, 'from querybuilder.query import QueryWindow, Query\n'), ((5252, 5265), 'querybuilder.query.QueryWindow', 'QueryWindow', ([], {}), '()\n', (5263, 5265), False, 'from querybuilder.query import QueryWindow, Query\n')]