src/dirbs/listgen/generator.py
def _create_intermediate_new_tables_structure(self, conn):
        """Create table structure for new tables used to create deltas."""
        table_names = []
        with conn.cursor() as cursor, CodeProfiler() as cp:
            tblname = self._blacklist_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                        imei_norm                     TEXT NOT NULL,
                                        virt_imei_shard               SMALLINT NOT NULL,
                                        block_date                    DATE NOT NULL,
                                        reasons                       TEXT[] NOT NULL,
                                        is_valid                      BOOLEAN,
                                        imei_norm_with_check_digit    TEXT
                                      ) PARTITION BY RANGE (virt_imei_shard)
                                   """).format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True)
            table_names.append(tblname)

            tblname = self._notifications_lists_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                        operator_id                 TEXT NOT NULL,
                                        imei_norm                   TEXT NOT NULL,
                                        virt_imei_shard             SMALLINT NOT NULL,
                                        imsi                        TEXT NOT NULL,
                                        msisdn                      TEXT NOT NULL,
                                        block_date                  DATE NOT NULL,
                                        reasons                     TEXT[] NOT NULL,
                                        is_valid                    BOOLEAN,
                                        amnesty_granted             BOOLEAN,
                                        imei_norm_with_check_digit  TEXT
                                      ) PARTITION BY LIST (operator_id)
                                   """).format(sql.Identifier(tblname)))
            table_names.append(tblname)
            self._create_operator_partitions(conn,
                                             parent_tbl_name=tblname,
                                             child_name_fn=self._notifications_lists_new_part_tblname,
                                             is_unlogged=True)

            tblname = self._exceptions_lists_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                        operator_id                 TEXT NOT NULL,
                                        imei_norm                   TEXT NOT NULL,
                                        virt_imei_shard             SMALLINT NOT NULL,
                                        imsi                        TEXT NOT NULL,
                                        is_valid                    BOOLEAN,
                                        imei_norm_with_check_digit  TEXT,
                                        is_blacklisted              BOOLEAN,
                                        is_barred                   BOOLEAN,
                                        have_barred_tac             BOOLEAN,
                                        msisdn                      TEXT NOT NULL
                                      ) PARTITION BY LIST (operator_id)
                                   """).format(sql.Identifier(tblname)))
            table_names.append(tblname)
            self._create_operator_partitions(conn,
                                             parent_tbl_name=tblname,
                                             child_name_fn=self._exceptions_lists_new_part_tblname,
                                             is_unlogged=True)

            tblname = self._blocking_conditions_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          cond_name     TEXT NOT NULL,
                                          reason        TEXT NOT NULL
                                      )""")
                           .format(sql.Identifier(tblname)))
            table_names.append(tblname)

            tblname = self._mnc_mcc_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          mcc_mnc_pattern       TEXT NOT NULL,
                                          operator_id           TEXT NOT NULL
                                      )""")
                           .format(sql.Identifier(tblname)))
            table_names.append(tblname)

            tblname = self._notifications_imei_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          block_date                    DATE NOT NULL,
                                          reasons                       TEXT[] NOT NULL,
                                          is_valid                      BOOLEAN,
                                          amnesty_granted               BOOLEAN,
                                          imei_norm_with_check_digit    TEXT
                                      ) PARTITION BY RANGE (virt_imei_shard)""")
                           .format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True)
            table_names.append(tblname)

            tblname = self._notifications_triplets_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          imsi                          TEXT NOT NULL,
                                          msisdn                        TEXT NOT NULL,
                                          block_date                    DATE NOT NULL,
                                          reasons                       TEXT[] NOT NULL,
                                          is_valid                      BOOLEAN,
                                          amnesty_granted               BOOLEAN,
                                          imei_norm_with_check_digit    TEXT,
                                          home_operator                 TEXT,
                                          fallback_operators            TEXT[]
                                      ) PARTITION BY RANGE (virt_imei_shard)""")
                           .format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True)
            table_names.append(tblname)

            tblname = self._pairings_imei_imsi_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          imsi                          TEXT NOT NULL,
                                          is_valid                      BOOLEAN,
                                          imei_norm_with_check_digit    TEXT,
                                          home_operator                 TEXT,
                                          is_blacklisted                BOOLEAN,
                                          is_barred                     BOOLEAN,
                                          have_barred_tac               BOOLEAN,
                                          msisdn                        TEXT NOT NULL
                                      ) PARTITION BY RANGE (virt_imei_shard) """)
                           .format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True, fillfactor=45)
            table_names.append(tblname)

        self._intermediate_table_names.extend(table_names)
        return -1, cp.duration
Create table structure for new tables used to create deltas.
Create table structure for new tables used to create deltas.
Create table structure for new tables used to create deltas .
def _create_intermediate_new_tables_structure(self, conn):
        table_names = []
        with conn.cursor() as cursor, CodeProfiler() as cp:
            tblname = self._blacklist_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                        imei_norm                     TEXT NOT NULL,
                                        virt_imei_shard               SMALLINT NOT NULL,
                                        block_date                    DATE NOT NULL,
                                        reasons                       TEXT[] NOT NULL,
                                        is_valid                      BOOLEAN,
                                        imei_norm_with_check_digit    TEXT
                                      ) PARTITION BY RANGE (virt_imei_shard)
                                   """).format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True)
            table_names.append(tblname)
            tblname = self._notifications_lists_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                        operator_id                 TEXT NOT NULL,
                                        imei_norm                   TEXT NOT NULL,
                                        virt_imei_shard             SMALLINT NOT NULL,
                                        imsi                        TEXT NOT NULL,
                                        msisdn                      TEXT NOT NULL,
                                        block_date                  DATE NOT NULL,
                                        reasons                     TEXT[] NOT NULL,
                                        is_valid                    BOOLEAN,
                                        amnesty_granted             BOOLEAN,
                                        imei_norm_with_check_digit  TEXT
                                      ) PARTITION BY LIST (operator_id)
                                   """).format(sql.Identifier(tblname)))
            table_names.append(tblname)
            self._create_operator_partitions(conn,
                                             parent_tbl_name=tblname,
                                             child_name_fn=self._notifications_lists_new_part_tblname,
                                             is_unlogged=True)
            tblname = self._exceptions_lists_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                        operator_id                 TEXT NOT NULL,
                                        imei_norm                   TEXT NOT NULL,
                                        virt_imei_shard             SMALLINT NOT NULL,
                                        imsi                        TEXT NOT NULL,
                                        is_valid                    BOOLEAN,
                                        imei_norm_with_check_digit  TEXT,
                                        is_blacklisted              BOOLEAN,
                                        is_barred                   BOOLEAN,
                                        have_barred_tac             BOOLEAN,
                                        msisdn                      TEXT NOT NULL
                                      ) PARTITION BY LIST (operator_id)
                                   """).format(sql.Identifier(tblname)))
            table_names.append(tblname)
            self._create_operator_partitions(conn,
                                             parent_tbl_name=tblname,
                                             child_name_fn=self._exceptions_lists_new_part_tblname,
                                             is_unlogged=True)
            tblname = self._blocking_conditions_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          cond_name     TEXT NOT NULL,
                                          reason        TEXT NOT NULL
                                      )""")
                           .format(sql.Identifier(tblname)))
            table_names.append(tblname)
            tblname = self._mnc_mcc_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          mcc_mnc_pattern       TEXT NOT NULL,
                                          operator_id           TEXT NOT NULL
                                      )""")
                           .format(sql.Identifier(tblname)))
            table_names.append(tblname)
            tblname = self._notifications_imei_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          block_date                    DATE NOT NULL,
                                          reasons                       TEXT[] NOT NULL,
                                          is_valid                      BOOLEAN,
                                          amnesty_granted               BOOLEAN,
                                          imei_norm_with_check_digit    TEXT
                                      ) PARTITION BY RANGE (virt_imei_shard)""")
                           .format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True)
            table_names.append(tblname)
            tblname = self._notifications_triplets_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          imsi                          TEXT NOT NULL,
                                          msisdn                        TEXT NOT NULL,
                                          block_date                    DATE NOT NULL,
                                          reasons                       TEXT[] NOT NULL,
                                          is_valid                      BOOLEAN,
                                          amnesty_granted               BOOLEAN,
                                          imei_norm_with_check_digit    TEXT,
                                          home_operator                 TEXT,
                                          fallback_operators            TEXT[]
                                      ) PARTITION BY RANGE (virt_imei_shard)""")
                           .format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True)
            table_names.append(tblname)
            tblname = self._pairings_imei_imsi_new_tblname
            cursor.execute(sql.SQL("""CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          imsi                          TEXT NOT NULL,
                                          is_valid                      BOOLEAN,
                                          imei_norm_with_check_digit    TEXT,
                                          home_operator                 TEXT,
                                          is_blacklisted                BOOLEAN,
                                          is_barred                     BOOLEAN,
                                          have_barred_tac               BOOLEAN,
                                          msisdn                        TEXT NOT NULL
                                      ) PARTITION BY RANGE (virt_imei_shard) """)
                           .format(sql.Identifier(tblname)))
            partition_utils.create_imei_shard_partitions(conn, tbl_name=tblname, unlogged=True, fillfactor=45)
            table_names.append(tblname)
        self._intermediate_table_names.extend(table_names)
        return -1, cp.duration
def _create_intermediate_new_tables_structure ( self , conn ) : table_names = [ ] with conn . cursor ( ) as cursor , CodeProfiler ( ) as cp : tblname = self . _blacklist_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                        imei_norm                     TEXT NOT NULL,
                                        virt_imei_shard               SMALLINT NOT NULL,
                                        block_date                    DATE NOT NULL,
                                        reasons                       TEXT[] NOT NULL,
                                        is_valid                      BOOLEAN,
                                        imei_norm_with_check_digit    TEXT
                                      ) PARTITION BY RANGE (virt_imei_shard)
                                   """ ) . format ( sql . Identifier ( tblname ) ) ) partition_utils . create_imei_shard_partitions ( conn , tbl_name = tblname , unlogged = True ) table_names . append ( tblname ) tblname = self . _notifications_lists_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                        operator_id                 TEXT NOT NULL,
                                        imei_norm                   TEXT NOT NULL,
                                        virt_imei_shard             SMALLINT NOT NULL,
                                        imsi                        TEXT NOT NULL,
                                        msisdn                      TEXT NOT NULL,
                                        block_date                  DATE NOT NULL,
                                        reasons                     TEXT[] NOT NULL,
                                        is_valid                    BOOLEAN,
                                        amnesty_granted             BOOLEAN,
                                        imei_norm_with_check_digit  TEXT
                                      ) PARTITION BY LIST (operator_id)
                                   """ ) . format ( sql . Identifier ( tblname ) ) ) table_names . append ( tblname ) self . _create_operator_partitions ( conn , parent_tbl_name = tblname , child_name_fn = self . _notifications_lists_new_part_tblname , is_unlogged = True ) tblname = self . _exceptions_lists_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                        operator_id                 TEXT NOT NULL,
                                        imei_norm                   TEXT NOT NULL,
                                        virt_imei_shard             SMALLINT NOT NULL,
                                        imsi                        TEXT NOT NULL,
                                        is_valid                    BOOLEAN,
                                        imei_norm_with_check_digit  TEXT,
                                        is_blacklisted              BOOLEAN,
                                        is_barred                   BOOLEAN,
                                        have_barred_tac             BOOLEAN,
                                        msisdn                      TEXT NOT NULL
                                      ) PARTITION BY LIST (operator_id)
                                   """ ) . format ( sql . Identifier ( tblname ) ) ) table_names . append ( tblname ) self . _create_operator_partitions ( conn , parent_tbl_name = tblname , child_name_fn = self . _exceptions_lists_new_part_tblname , is_unlogged = True ) tblname = self . _blocking_conditions_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                          cond_name     TEXT NOT NULL,
                                          reason        TEXT NOT NULL
                                      )""" ) . format ( sql . Identifier ( tblname ) ) ) table_names . append ( tblname ) tblname = self . _mnc_mcc_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                          mcc_mnc_pattern       TEXT NOT NULL,
                                          operator_id           TEXT NOT NULL
                                      )""" ) . format ( sql . Identifier ( tblname ) ) ) table_names . append ( tblname ) tblname = self . _notifications_imei_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          block_date                    DATE NOT NULL,
                                          reasons                       TEXT[] NOT NULL,
                                          is_valid                      BOOLEAN,
                                          amnesty_granted               BOOLEAN,
                                          imei_norm_with_check_digit    TEXT
                                      ) PARTITION BY RANGE (virt_imei_shard)""" ) . format ( sql . Identifier ( tblname ) ) ) partition_utils . create_imei_shard_partitions ( conn , tbl_name = tblname , unlogged = True ) table_names . append ( tblname ) tblname = self . _notifications_triplets_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          imsi                          TEXT NOT NULL,
                                          msisdn                        TEXT NOT NULL,
                                          block_date                    DATE NOT NULL,
                                          reasons                       TEXT[] NOT NULL,
                                          is_valid                      BOOLEAN,
                                          amnesty_granted               BOOLEAN,
                                          imei_norm_with_check_digit    TEXT,
                                          home_operator                 TEXT,
                                          fallback_operators            TEXT[]
                                      ) PARTITION BY RANGE (virt_imei_shard)""" ) . format ( sql . Identifier ( tblname ) ) ) partition_utils . create_imei_shard_partitions ( conn , tbl_name = tblname , unlogged = True ) table_names . append ( tblname ) tblname = self . _pairings_imei_imsi_new_tblname cursor . execute ( sql . SQL ( """CREATE UNLOGGED TABLE {0} (
                                          imei_norm                     TEXT NOT NULL,
                                          virt_imei_shard               SMALLINT NOT NULL,
                                          imsi                          TEXT NOT NULL,
                                          is_valid                      BOOLEAN,
                                          imei_norm_with_check_digit    TEXT,
                                          home_operator                 TEXT,
                                          is_blacklisted                BOOLEAN,
                                          is_barred                     BOOLEAN,
                                          have_barred_tac               BOOLEAN,
                                          msisdn                        TEXT NOT NULL
                                      ) PARTITION BY RANGE (virt_imei_shard) """ ) . format ( sql . Identifier ( tblname ) ) ) partition_utils . create_imei_shard_partitions ( conn , tbl_name = tblname , unlogged = True , fillfactor = 45 ) table_names . append ( tblname ) self . _intermediate_table_names . extend ( table_names ) return - 1 , cp . duration
Create table structure for new tables used to create deltas.
Create table structure for new tables used to create deltas .
"""Create table structure for new tables used to create deltas."""
self
conn