def build_query(self, page=1, page_size=10):
        """Convert the query tree into a parameterized SQL SELECT statement.

        :param page: The page number to get results for.
        :type page: int
        :param page_size: The number of results per page.
        :type page_size: int

        :return: SQL query data.
        :rtype: 2-tuple of (SQL statement string, query parameter tuple)
        """
        def get_table_joins(tables):
            joins = [
                ("INNER", "code", "codelet_code_id", "code_id"),
                ("LEFT", "authors", "author_codelet", "codelet_id"),
                ("LEFT", "symbols", "symbol_code", "code_id"),
                ("LEFT", "symbol_locations", "sloc_symbol", "symbol_id")
            ]
            tmpl = "%s JOIN %s ON %s = %s"
            for args in joins:
                if args[1] in tables:
                    yield tmpl % args

        tables = set()
        cond, arglist, ranks, need_ranks = self._root.parameterize(tables)
        ranks = ranks or [cond]
        if need_ranks:
            score = " + ((%s) / %d)" % (" + ".join(ranks), len(ranks))
        else:
            score = ""
        joins = " ".join(get_table_joins(tables))
        offset = (page - 1) * page_size

        query = (score, joins, cond, page_size, offset) % QUERY_TEMPLATE
        return query, tuple(arglist * 2 if need_ranks else arglist)
dataset/ETHPy150Open earwig/bitshift/bitshift/query/tree.py/Tree.build_query/swapped operands of `%`