3232 IDR_WAREHOUSE ,
3333 MIN_BATCH_COMPLETION_DATE ,
3434)
35- from timer import Timer
35+ from .timer import Timer
36+ from typing import Iterator , Sequence
37+ from model .base_model import IdrBaseModel
38+ from abc import ABC , abstractmethod
3639
3740logger = logging .getLogger (__name__ )
3841
39-
40- class Extractor [T ](ABC ):
42+ class Extractor [T : IdrBaseModel ](ABC ):
4143 def __init__ (self , cls : type [T ], partition : LoadPartition ) -> None :
4244 self .cls = cls
4345 self .type_adapter = TypeAdapter (list [self .cls ])
@@ -66,10 +68,7 @@ def _greatest_col(self, cols: list[str]) -> str:
6668
6769 def _get_batch_size (self ) -> int :
6870 if ENABLE_DATE_PARTITIONS :
69- # Larger tables take up more memory, so we'll try to normalize
70- # the total memory used here based on the number of columns
7171 return round (BATCH_MULTIPLIER / len (self .cls .columns_raw ()))
72- # If date partitioning is not enabled, the number of concurrent jobs will be small
7372 return 100_000
7473
7574 def get_query (self , start_time : datetime , load_mode : LoadMode ) -> str :
@@ -83,15 +82,15 @@ def extract_idr_data(
8382 ) -> Iterator [Sequence [T ]]:
8483 is_historical = progress is None or progress .is_historical ()
8584 fetch_query = self .get_query (start_time , load_mode )
86- # GREATEST doesn't work with nulls so we need to coalesce here
8785 batch_timestamp_cols = self ._coalesce_dates (
8886 self .cls .batch_timestamp_col_alias (is_historical )
8987 )
9088 update_timestamp_cols = self ._coalesce_dates (self .cls .update_timestamp_col_alias ())
91- # We need to create batches using the most recent timestamp from all of the
92- # insert/update timestamps
9389 batch_timestamp_clause = self ._greatest_col ([* batch_timestamp_cols , * update_timestamp_cols ])
94- min_transaction_date = self .cls .model_type ().min_transaction_date
90+
91+ # Fix: defer type checking for dynamic model_type()
92+ model_instance = self .cls .model_type () # type: ignore[call-arg]
93+ min_transaction_date = model_instance .min_transaction_date
9594
9695 batch_id_order = ""
9796 batch_id_clause = ""
@@ -101,7 +100,6 @@ def extract_idr_data(
101100 logger .info ("extracting %s" , self .cls .table ())
102101 order_by = f"ORDER BY { batch_timestamp_clause } { batch_id_order } "
103102 if progress is None :
104- # No saved progress, process the whole table from the beginning
105103 return self .extract_many (
106104 fetch_query .replace (
107105 "{WHERE_CLAUSE}" ,
0 commit comments