data-factory-utils 2.2.0__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/PKG-INFO +1 -1
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/pyproject.toml +1 -1
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/src/data_factory_utils/query.py +13 -8
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/README.md +0 -0
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/src/data_factory_utils/__init__.py +0 -0
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/src/data_factory_utils/athena.py +0 -0
- {data_factory_utils-2.2.0 → data_factory_utils-2.4.0}/src/data_factory_utils/environment.py +0 -0
|
@@ -89,8 +89,9 @@ class WhereSetMembership(NamedTuple):
|
|
|
89
89
|
"""Config for WHERE IN comparisons."""
|
|
90
90
|
|
|
91
91
|
col: str
|
|
92
|
-
set: tuple[str]
|
|
92
|
+
set: tuple[str] | Subquery
|
|
93
93
|
unquote: bool | None = False
|
|
94
|
+
membership_operator: Literal["IN", "NOT IN"] = "IN"
|
|
94
95
|
prefix: Literal["AND", "OR", "NOT"] | None = "AND"
|
|
95
96
|
brackets: Literal["open", "close", "wrap"] | None = None
|
|
96
97
|
|
|
@@ -529,15 +530,19 @@ def _build_where_set_membership(config: WhereSetMembership) -> str:
|
|
|
529
530
|
- WHERE NOT col IN (value, value)
|
|
530
531
|
"""
|
|
531
532
|
validate_identifier(config.col)
|
|
532
|
-
|
|
533
|
-
|
|
533
|
+
if not isinstance(config.set, Subquery):
|
|
534
|
+
for value in config.set:
|
|
535
|
+
validate_identifier(value)
|
|
534
536
|
|
|
535
|
-
if config.
|
|
537
|
+
if isinstance(config.set, Subquery):
|
|
538
|
+
values = str(config.set)
|
|
539
|
+
query_str = f"{config.col} {config.membership_operator} {values}"
|
|
540
|
+
elif config.unquote:
|
|
536
541
|
values = ", ".join(config.set)
|
|
537
|
-
query_str = f"{config.col}
|
|
542
|
+
query_str = f"{config.col} {config.membership_operator} ({values})"
|
|
538
543
|
else:
|
|
539
544
|
values = ", ".join(f"'{value}'" for value in config.set)
|
|
540
|
-
query_str = f'"{config.col}"
|
|
545
|
+
query_str = f'"{config.col}" {config.membership_operator} ({values})'
|
|
541
546
|
|
|
542
547
|
if config.brackets:
|
|
543
548
|
query_str = _wrap(loc=config.brackets, text=query_str)
|
|
@@ -733,8 +738,8 @@ class Query:
|
|
|
733
738
|
msg = "WHERE statement has no valid conditions."
|
|
734
739
|
raise ValueError(msg)
|
|
735
740
|
|
|
736
|
-
# first condition cannot have prefix
|
|
737
|
-
if i > 0 and condition.prefix:
|
|
741
|
+
# first condition cannot have prefix - unless it's "NOT"
|
|
742
|
+
if (i == 0 and condition.prefix == "NOT") or (i > 0 and condition.prefix):
|
|
738
743
|
cond_str = f"{condition.prefix} {cond_str}"
|
|
739
744
|
|
|
740
745
|
query_str.append(cond_str)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|