<commit_before>
from checks.base_check import BaseCheck

class IdGapCheck(BaseCheck):

    def inner_run(self, db):
        cur = db.cursor()

        query = """
            select count(*) from (select abs((lead(cast(`%(col)s` as int), 1) over (order by cast(`%(col)s` as int)) - cast(`%(col)s` as int))) as diff, `%(col)s` from `%(schema)s`.`%(table)s`) t where diff > %(threshold)s
        """ % self.query_settings

        self.add_log("collection", "Run query %s" % (query))
        
        cur.execute(query)

        row = cur.fetchone()

        self.add_log("result", "Query came back with count %s" %(row[0]))

        self.failed = row[0] > 0

        self.failed_rows_query = """
                select gap_start, gap_end from (
                    select `%(col)s` as gap_start, cast(`%(col)s` as int) + diff as gap_end from 
                        (
                            select abs((lead(cast(`%(col)s` as int), 1) over (order by cast(`%(col)s` as int)) - cast(`%(col)s` as int))) as diff, `%(col)s` from `%(schema)s`.`%(table)s`) t where diff > %(threshold)s limit 10000
                        ) t2
                    where gap_end is not null
            """ % self.query_settings<commit_msg>Limit id gap selection criteria as it may kill the cluster<commit_after>
from checks.base_check import BaseCheck

class IdGapCheck(BaseCheck):

    def inner_run(self, db):
        cur = db.cursor()

        query = """
            select count(*) from (select abs((lead(cast(`%(col)s` as int), 1) over (order by cast(`%(col)s` as int)) - cast(`%(col)s` as int))) as diff, `%(col)s` from `%(schema)s`.`%(table)s`) t where diff > %(threshold)s
        """ % self.query_settings

        self.add_log("collection", "Run query %s" % (query))
        
        cur.execute(query)

        row = cur.fetchone()

        self.add_log("result", "Query came back with count %s" %(row[0]))

        self.failed = row[0] > 0

        self.failed_rows_query = """
                select gap_start, gap_end from (
                    select `%(col)s` as gap_start, cast(`%(col)s` as int) + diff as gap_end from 
                        (
                            select abs((lead(cast(`%(col)s` as int), 1) over (order by cast(`%(col)s` as int)) - cast(`%(col)s` as int))) as diff, `%(col)s` from `%(schema)s`.`%(table)s`) t where diff > %(threshold)s limit 1000
                        ) t2
                    where gap_end is not null
            """ % self.query_settings
{'fraction_non_alphanumeric': 0.16090104585679807, 'fraction_numerical': 0.008447304907481898, 'mean_word_length': 2.1361916771752836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4402405', 'n_tokens_mistral': 836, 'n_tokens_neox': 764, 'n_words': 223}