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))

[((12, 23, 12, 36), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((15, 52, 15, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(15, 71, 15, 80): 'query_str', (15, 82, 15, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((21, 52, 21, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(21, 71, 21, 80): 'query_str', (21, 82, 21, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((27, 52, 27, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(27, 71, 27, 80): 'query_str', (27, 82, 27, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((37, 52, 37, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(37, 71, 37, 80): 'query_str', (37, 82, 37, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((51, 52, 51, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(51, 71, 51, 80): 'query_str', (51, 82, 51, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((64, 52, 64, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(64, 71, 64, 80): 'query_str', (64, 82, 64, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((77, 52, 77, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(77, 71, 77, 80): 'query_str', (77, 82, 77, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((95, 52, 95, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(95, 71, 95, 80): 'query_str', (95, 82, 95, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((114, 52, 114, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(114, 71, 114, 80): 'query_str', (114, 82, 114, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((138, 52, 138, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(138, 71, 138, 80): 'query_str', (138, 82, 138, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((164, 52, 164, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(164, 71, 164, 80): 'query_str', (164, 82, 164, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((188, 52, 188, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(188, 71, 188, 80): 'query_str', (188, 82, 188, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((212, 52, 212, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(212, 71, 212, 80): 'query_str', (212, 82, 212, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((236, 52, 236, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(236, 71, 236, 80): 'query_str', (236, 82, 236, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((261, 52, 261, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(261, 71, 261, 80): 'query_str', (261, 82, 261, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((282, 52, 282, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(282, 71, 282, 80): 'query_str', (282, 82, 282, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((304, 52, 304, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(304, 71, 304, 80): 'query_str', (304, 82, 304, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((325, 52, 325, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(325, 71, 325, 80): 'query_str', (325, 82, 325, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((346, 52, 346, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(346, 71, 346, 80): 'query_str', (346, 82, 346, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((367, 52, 367, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(367, 71, 367, 80): 'query_str', (367, 82, 367, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((389, 52, 389, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(389, 71, 389, 80): 'query_str', (389, 82, 389, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((418, 52, 418, 97), 'querybuilder.tests.query_tests.get_comparison_str', 'get_comparison_str', ({(418, 71, 418, 80): 'query_str', (418, 82, 418, 96): 'expected_query'}, {}), '(query_str, expected_query)', False, 'from querybuilder.tests.query_tests import QueryTestCase, get_comparison_str\n'), ((18, 23, 18, 36), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((24, 23, 24, 36), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((56, 16, 56, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((67, 16, 67, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((80, 16, 80, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((98, 16, 98, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((264, 16, 264, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((285, 16, 285, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((307, 16, 307, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((328, 16, 328, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((349, 16, 349, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((370, 16, 370, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((59, 16, 59, 27), 'querybuilder.fields.RankField', 'RankField', ({}, {}), '()', False, 'from querybuilder.fields import RankField, RowNumberField, DenseRankField, PercentRankField, CumeDistField, NTileField, LagField, LeadField, FirstValueField, LastValueField, NthValueField, NumStdDevField\n'), ((30, 23, 30, 36), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((117, 16, 117, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((141, 16, 141, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((167, 16, 167, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((191, 16, 191, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((215, 16, 215, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((239, 16, 239, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((392, 16, 392, 23), 'querybuilder.query.Query', 'Query', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((71, 25, 71, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((85, 25, 85, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((103, 25, 103, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((270, 25, 270, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((292, 25, 292, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((313, 25, 313, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((334, 25, 334, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((355, 25, 355, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((377, 25, 377, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((398, 25, 398, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((40, 23, 40, 36), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((122, 25, 122, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((172, 25, 172, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((196, 25, 196, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((220, 25, 220, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((245, 25, 245, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n'), ((146, 25, 146, 38), 'querybuilder.query.QueryWindow', 'QueryWindow', ({}, {}), '()', False, 'from querybuilder.query import QueryWindow, Query\n')]