src/dirbs/listgen/generator.py
def _create_intermediate_old_tables_structure(self, conn):
        """Create table structure for old tables used to create deltas."""
        table_names = []
        with conn.cursor() as cursor, CodeProfiler() as cp:
            tblname = self._blacklist_old_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
                                      ) 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_old_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,
                                        amnesty_granted BOOLEAN
                                      ) 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_old_part_tblname,
                                             is_unlogged=True)

            tblname = self._exceptions_lists_old_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
                                      ) 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_old_part_tblname,
                                             is_unlogged=True)

        self._intermediate_table_names.extend(table_names)
        return -1, cp.duration
Create table structure for old tables used to create deltas.
Create table structure for old tables used to create deltas.
Create table structure for old tables used to create deltas .
def _create_intermediate_old_tables_structure(self, conn):
        table_names = []
        with conn.cursor() as cursor, CodeProfiler() as cp:
            tblname = self._blacklist_old_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
                                      ) 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_old_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,
                                        amnesty_granted BOOLEAN
                                      ) 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_old_part_tblname,
                                             is_unlogged=True)
            tblname = self._exceptions_lists_old_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
                                      ) 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_old_part_tblname,
                                             is_unlogged=True)
        self._intermediate_table_names.extend(table_names)
        return -1, cp.duration
def _create_intermediate_old_tables_structure ( self , conn ) : table_names = [ ] with conn . cursor ( ) as cursor , CodeProfiler ( ) as cp : tblname = self . _blacklist_old_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
                                      ) 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_old_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,
                                        amnesty_granted BOOLEAN
                                      ) 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_old_part_tblname , is_unlogged = True ) tblname = self . _exceptions_lists_old_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
                                      ) 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_old_part_tblname , is_unlogged = True ) self . _intermediate_table_names . extend ( table_names ) return - 1 , cp . duration
Create table structure for old tables used to create deltas.
Create table structure for old tables used to create deltas .
"""Create table structure for old tables used to create deltas."""
self
conn