@@ -141,6 +141,8 @@ class UnknownColType(ColType):
141141
142142
143143class AbstractDialect (ABC ):
144+ """Dialect-dependent query expressions"""
145+
144146 name : str
145147
146148 @abstractmethod
@@ -177,56 +179,18 @@ def explain_as_text(self, query: str) -> str:
177179 "Provide SQL for explaining a query, returned in as table(varchar)"
178180 ...
179181
180-
181- class AbstractDatabase (AbstractDialect ):
182182 @abstractmethod
183- def timestamp_value (self , t : DbTime ) -> str :
183+ def timestamp_value (self , t : datetime ) -> str :
184184 "Provide SQL for the given timestamp value"
185185 ...
186186
187- @abstractmethod
188- def md5_to_int (self , s : str ) -> str :
189- "Provide SQL for computing md5 and returning an int"
190- ...
191-
192- @abstractmethod
193- def _query (self , sql_code : str ) -> list :
194- "Send query to database and return result"
195- ...
196-
197- @abstractmethod
198- def select_table_schema (self , path : DbPath ) -> str :
199- "Provide SQL for selecting the table schema as (name, type, date_prec, num_prec)"
200- ...
201187
202- @abstractmethod
203- def query_table_schema (self , path : DbPath ) -> Dict [str , tuple ]:
204- """Query the table for its schema for table in 'path', and return {column: tuple}
205- where the tuple is (table_name, col_name, type_repr, datetime_precision?, numeric_precision?, numeric_scale?)
206- """
207- ...
188+ class AbstractDatadiffDialect (ABC ):
189+ """Dialect-dependent query expressions, that are specific to data-diff"""
208190
209191 @abstractmethod
210- def _process_table_schema (
211- self , path : DbPath , raw_schema : Dict [str , tuple ], filter_columns : Sequence [str ], where : str = None
212- ):
213- """Process the result of query_table_schema().
214-
215- Done in a separate step, to minimize the amount of processed columns.
216- Needed because processing each column may:
217- * throw errors and warnings
218- * query the database to sample values
219-
220- """
221-
222- @abstractmethod
223- def parse_table_name (self , name : str ) -> DbPath :
224- "Parse the given table name into a DbPath"
225- ...
226-
227- @abstractmethod
228- def close (self ):
229- "Close connection(s) to the database instance. Querying will stop functioning."
192+ def md5_to_int (self , s : str ) -> str :
193+ "Provide SQL for computing md5 and returning an int"
230194 ...
231195
232196 @abstractmethod
@@ -294,6 +258,48 @@ def normalize_value_by_type(self, value: str, coltype: ColType) -> str:
294258 return self .normalize_uuid (value , coltype )
295259 return self .to_string (value )
296260
261+
262+ class AbstractDatabase (AbstractDialect , AbstractDatadiffDialect ):
263+ @abstractmethod
264+ def _query (self , sql_code : str ) -> list :
265+ "Send query to database and return result"
266+ ...
267+
268+ @abstractmethod
269+ def select_table_schema (self , path : DbPath ) -> str :
270+ "Provide SQL for selecting the table schema as (name, type, date_prec, num_prec)"
271+ ...
272+
273+ @abstractmethod
274+ def query_table_schema (self , path : DbPath ) -> Dict [str , tuple ]:
275+ """Query the table for its schema for table in 'path', and return {column: tuple}
276+ where the tuple is (table_name, col_name, type_repr, datetime_precision?, numeric_precision?, numeric_scale?)
277+ """
278+ ...
279+
280+ @abstractmethod
281+ def _process_table_schema (
282+ self , path : DbPath , raw_schema : Dict [str , tuple ], filter_columns : Sequence [str ], where : str = None
283+ ):
284+ """Process the result of query_table_schema().
285+
286+ Done in a separate step, to minimize the amount of processed columns.
287+ Needed because processing each column may:
288+ * throw errors and warnings
289+ * query the database to sample values
290+
291+ """
292+
293+ @abstractmethod
294+ def parse_table_name (self , name : str ) -> DbPath :
295+ "Parse the given table name into a DbPath"
296+ ...
297+
298+ @abstractmethod
299+ def close (self ):
300+ "Close connection(s) to the database instance. Querying will stop functioning."
301+ ...
302+
297303 @abstractmethod
298304 def _normalize_table_path (self , path : DbPath ) -> DbPath :
299305 ...
0 commit comments