|
21 | 21 | from data_diff.queries.extras import ApplyFuncAndNormalizeAsString, Checksum, NormalizeAsString |
22 | 22 | from data_diff.utils import ArithString, is_uuid, join_iter, safezip |
23 | 23 | from data_diff.queries.api import Expr, table, Select, SKIP, Explain, Code, this |
24 | | -from data_diff.queries.ast_classes import Alias, BinOp, CaseWhen, Cast, Column, Commit, Concat, ConstantTable, Count, \ |
25 | | - CreateTable, Cte, \ |
26 | | - CurrentTimestamp, DropTable, Func, \ |
27 | | - GroupBy, \ |
28 | | - ITable, In, InsertToTable, IsDistinctFrom, \ |
29 | | - Join, \ |
30 | | - Param, \ |
31 | | - Random, \ |
32 | | - Root, TableAlias, TableOp, TablePath, \ |
33 | | - TimeTravel, TruncateTable, UnaryOp, WhenThen, _ResolveColumn |
| 24 | +from data_diff.queries.ast_classes import ( |
| 25 | + Alias, |
| 26 | + BinOp, |
| 27 | + CaseWhen, |
| 28 | + Cast, |
| 29 | + Column, |
| 30 | + Commit, |
| 31 | + Concat, |
| 32 | + ConstantTable, |
| 33 | + Count, |
| 34 | + CreateTable, |
| 35 | + Cte, |
| 36 | + CurrentTimestamp, |
| 37 | + DropTable, |
| 38 | + Func, |
| 39 | + GroupBy, |
| 40 | + ITable, |
| 41 | + In, |
| 42 | + InsertToTable, |
| 43 | + IsDistinctFrom, |
| 44 | + Join, |
| 45 | + Param, |
| 46 | + Random, |
| 47 | + Root, |
| 48 | + TableAlias, |
| 49 | + TableOp, |
| 50 | + TablePath, |
| 51 | + TimeTravel, |
| 52 | + TruncateTable, |
| 53 | + UnaryOp, |
| 54 | + WhenThen, |
| 55 | + _ResolveColumn, |
| 56 | +) |
34 | 57 | from data_diff.abcs.database_types import ( |
35 | 58 | Array, |
36 | 59 | Struct, |
@@ -414,7 +437,9 @@ def render_checksum(self, c: Compiler, elem: Checksum) -> str: |
414 | 437 |
|
415 | 438 | def render_concat(self, c: Compiler, elem: Concat) -> str: |
416 | 439 | # We coalesce because on some DBs (e.g. MySQL) concat('a', NULL) is NULL |
417 | | - items = [f"coalesce({self.compile(c, Code(self.to_string(self.compile(c, expr))))}, '<null>')" for expr in elem.exprs] |
| 440 | + items = [ |
| 441 | + f"coalesce({self.compile(c, Code(self.to_string(self.compile(c, expr))))}, '<null>')" for expr in elem.exprs |
| 442 | + ] |
418 | 443 | assert items |
419 | 444 | if len(items) == 1: |
420 | 445 | return items[0] |
@@ -559,17 +584,15 @@ def render_groupby(self, c: Compiler, elem: GroupBy) -> str: |
559 | 584 | columns=columns, |
560 | 585 | group_by_exprs=[Code(k) for k in keys], |
561 | 586 | having_exprs=elem.having_exprs, |
562 | | - ) |
| 587 | + ), |
563 | 588 | ) |
564 | 589 |
|
565 | 590 | keys_str = ", ".join(keys) |
566 | 591 | columns_str = ", ".join(self.compile(c, x) for x in columns) |
567 | 592 | having_str = ( |
568 | 593 | " HAVING " + " AND ".join(map(compile_fn, elem.having_exprs)) if elem.having_exprs is not None else "" |
569 | 594 | ) |
570 | | - select = ( |
571 | | - f"SELECT {columns_str} FROM {self.compile(c.replace(in_select=True), elem.table)} GROUP BY {keys_str}{having_str}" |
572 | | - ) |
| 595 | + select = f"SELECT {columns_str} FROM {self.compile(c.replace(in_select=True), elem.table)} GROUP BY {keys_str}{having_str}" |
573 | 596 |
|
574 | 597 | if c.in_select: |
575 | 598 | select = f"({select}) {c.new_unique_name()}" |
@@ -601,7 +624,7 @@ def render_timetravel(self, c: Compiler, elem: TimeTravel) -> str: |
601 | 624 | # TODO: why is it c.? why not self? time-trvelling is the dialect's thing, isnt't it? |
602 | 625 | c.time_travel( |
603 | 626 | elem.table, before=elem.before, timestamp=elem.timestamp, offset=elem.offset, statement=elem.statement |
604 | | - ) |
| 627 | + ), |
605 | 628 | ) |
606 | 629 |
|
607 | 630 | def render_createtable(self, c: Compiler, elem: CreateTable) -> str: |
@@ -779,7 +802,6 @@ class _DialectWithMixins(cls, *mixins, *abstract_mixins): |
779 | 802 | _DialectWithMixins.__name__ = cls.__name__ |
780 | 803 | return _DialectWithMixins() |
781 | 804 |
|
782 | | - |
783 | 805 | @property |
784 | 806 | @abstractmethod |
785 | 807 | def name(self) -> str: |
|
0 commit comments