interloper-sql 0.119.0__tar.gz → 0.121.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.
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/PKG-INFO +1 -1
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/pyproject.toml +1 -1
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/pyproject.toml.orig +1 -1
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/__init__.py +3 -1
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/view/__init__.py +12 -1
- interloper_sql-0.121.0/src/interloper_sql/view/timezone.py +61 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/README.md +0 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/connection.py +0 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/destination.py +0 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/types.py +0 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/view/base.py +0 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/view/decorator.py +0 -0
- {interloper_sql-0.119.0 → interloper_sql-0.121.0}/src/interloper_sql/view/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: interloper-sql
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.121.0
|
|
4
4
|
Summary: Interloper SQL integration: portable views over SQL warehouses, and a SQLAlchemy-backed destination for PostgreSQL and other SQL databases
|
|
5
5
|
Author: Guillaume Onfroy
|
|
6
6
|
Author-email: Guillaume Onfroy <guillaume@digitlcloud.com>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "interloper-sql"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.121.0"
|
|
4
4
|
description = "Interloper SQL integration: portable views over SQL warehouses, and a SQLAlchemy-backed destination for PostgreSQL and other SQL databases"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# ###############
|
|
4
4
|
[project]
|
|
5
5
|
name = "interloper-sql"
|
|
6
|
-
version = "0.
|
|
6
|
+
version = "0.121.0"
|
|
7
7
|
description = "Interloper SQL integration: portable views over SQL warehouses, and a SQLAlchemy-backed destination for PostgreSQL and other SQL databases"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
authors = [{ name = "Guillaume Onfroy", email = "guillaume@digitlcloud.com" }]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Interloper SQL integration: portable views, and a SQLAlchemy-backed destination behind the postgres extra."""
|
|
2
2
|
|
|
3
|
-
from interloper_sql.view import IbisView, ibis_view, latest, union
|
|
3
|
+
from interloper_sql.view import IbisView, ibis_view, latest, local_date, union
|
|
4
4
|
|
|
5
5
|
try:
|
|
6
6
|
from interloper_sql.connection import SQLConnection
|
|
@@ -13,6 +13,7 @@ except ModuleNotFoundError as error:
|
|
|
13
13
|
"IbisView",
|
|
14
14
|
"ibis_view",
|
|
15
15
|
"latest",
|
|
16
|
+
"local_date",
|
|
16
17
|
"union",
|
|
17
18
|
]
|
|
18
19
|
else:
|
|
@@ -22,5 +23,6 @@ else:
|
|
|
22
23
|
"SQLDestination",
|
|
23
24
|
"ibis_view",
|
|
24
25
|
"latest",
|
|
26
|
+
"local_date",
|
|
25
27
|
"union",
|
|
26
28
|
]
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
from interloper_sql.view.base import IbisDefinition, IbisView, latest, union
|
|
4
4
|
from interloper_sql.view.decorator import ibis_view
|
|
5
|
+
from interloper_sql.view.timezone import LocalDate, local_date
|
|
5
6
|
from interloper_sql.view.types import IBIS_DIALECTS, ibis_schema
|
|
6
7
|
|
|
7
|
-
__all__ = [
|
|
8
|
+
__all__ = [
|
|
9
|
+
"IBIS_DIALECTS",
|
|
10
|
+
"IbisDefinition",
|
|
11
|
+
"IbisView",
|
|
12
|
+
"LocalDate",
|
|
13
|
+
"ibis_schema",
|
|
14
|
+
"ibis_view",
|
|
15
|
+
"latest",
|
|
16
|
+
"local_date",
|
|
17
|
+
"union",
|
|
18
|
+
]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Per-row timezone conversion for portable views: the day an instant falls on in a named timezone."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import ibis.expr.operations as ops
|
|
6
|
+
import ibis.expr.rules as rlz
|
|
7
|
+
import ibis.expr.types as ir
|
|
8
|
+
import sqlglot.expressions as sge
|
|
9
|
+
from ibis.backends.sql.compilers.base import SQLGlotCompiler
|
|
10
|
+
from ibis.expr import datatypes
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LocalDate(ops.Value):
|
|
14
|
+
"""The calendar day an instant falls on in a timezone, which may differ from row to row."""
|
|
15
|
+
|
|
16
|
+
instant: ops.Value[datatypes.Timestamp]
|
|
17
|
+
timezone: ops.Value[datatypes.String]
|
|
18
|
+
|
|
19
|
+
dtype = datatypes.date
|
|
20
|
+
shape = rlz.shape_like("args")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _compile_local_date(
|
|
24
|
+
compiler: SQLGlotCompiler, op: LocalDate, *, instant: sge.Expression, timezone: sge.Expression
|
|
25
|
+
) -> sge.Expression:
|
|
26
|
+
"""Compile a `LocalDate` as sqlglot's timezone conversion, cast to a date.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
compiler: The Ibis SQL compiler of the target dialect.
|
|
30
|
+
op: The node being compiled; its arguments arrive already compiled.
|
|
31
|
+
instant: The compiled instant.
|
|
32
|
+
timezone: The compiled IANA timezone name.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
The SQL expression, which sqlglot renders in the compiler's dialect.
|
|
36
|
+
"""
|
|
37
|
+
return sge.Cast(this=sge.ConvertTimezone(target_tz=timezone, timestamp=instant), to=sge.DataType.build("date"))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Ibis converts between zones only by a constant; sqlglot's ConvertTimezone takes a column and renders
|
|
41
|
+
# in each dialect's own syntax, so every Ibis SQL compiler learns this node from their common base
|
|
42
|
+
SQLGlotCompiler.visit_LocalDate = _compile_local_date # ty: ignore[unresolved-attribute]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def local_date(instant: ir.TimestampValue, timezone: ir.StringValue | str) -> ir.DateValue:
|
|
46
|
+
"""The calendar day *instant* falls on in *timezone*: 22:00 UTC on 4 May is 5 May in Berlin.
|
|
47
|
+
|
|
48
|
+
A vendor that schedules in UTC instants still means the account's own
|
|
49
|
+
days; this reads them back. The conversion renders on BigQuery, DuckDB,
|
|
50
|
+
Postgres, Snowflake and Databricks. T-SQL names its zones the Windows way
|
|
51
|
+
and ClickHouse converts only by a constant zone, so a view using this does
|
|
52
|
+
not run there.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
instant: A UTC instant column.
|
|
56
|
+
timezone: An IANA timezone name, per row as a column or the same for every row; NULL gives a NULL day.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
A date column.
|
|
60
|
+
"""
|
|
61
|
+
return LocalDate(instant, timezone).to_expr() # ty: ignore[invalid-argument-type]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|