soda-postgres 4.3.0__tar.gz → 4.14.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.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soda-postgres
3
- Version: 4.3.0
3
+ Version: 4.14.0
4
4
  Summary: Soda Postgres V4
5
5
  Author-email: "Soda Data N.V." <info@soda.io>
6
6
  License: Proprietary
7
7
  Requires-Python: >=3.10
8
- Requires-Dist: soda-core==4.3.0
8
+ Requires-Dist: soda-core==4.14.0
9
9
  Requires-Dist: psycopg[binary]>=3.2
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "soda-postgres"
3
- version = "4.3.0"
3
+ version = "4.14.0"
4
4
  description = "Soda Postgres V4"
5
5
  requires-python = ">=3.10"
6
6
  license = {text = "Proprietary"}
@@ -8,7 +8,7 @@ authors = [
8
8
  {name = "Soda Data N.V.", email = "info@soda.io"}
9
9
  ]
10
10
  dependencies = [
11
- "soda-core==4.3.0",
11
+ "soda-core==4.14.0",
12
12
  "psycopg[binary]>=3.2",
13
13
  ]
14
14
 
@@ -264,11 +264,11 @@ class PostgresSqlDialect(SqlDialect, sqlglot_dialect="postgres"):
264
264
 
265
265
  select_columns = []
266
266
  if include_table_name_column:
267
- select_columns.append(COLUMN("relname", table_alias="c", field_alias="table_name"))
267
+ select_columns.append(COLUMN("relname", table_alias="c").AS("table_name"))
268
268
 
269
269
  select_columns.extend(
270
270
  [
271
- COLUMN("attname", table_alias="a", field_alias="column_name"),
271
+ COLUMN("attname", table_alias="a").AS("column_name"),
272
272
  # Normalize data type into information_schema.columns style.
273
273
  RAW_SQL(
274
274
  """CASE
@@ -345,9 +345,9 @@ class PostgresSqlDialect(SqlDialect, sqlglot_dialect="postgres"):
345
345
  END AS "datetime_precision"
346
346
  """
347
347
  ),
348
- COLUMN(current_database_expression, field_alias="table_catalog"),
349
- COLUMN("nspname", table_alias="n", field_alias="table_schema"),
350
- COLUMN("relname", table_alias="c", field_alias="table_name"),
348
+ current_database_expression.AS("table_catalog"),
349
+ COLUMN("nspname", table_alias="n").AS("table_schema"),
350
+ COLUMN("relname", table_alias="c").AS("table_name"),
351
351
  RAW_SQL(self.relkind_table_type_sql_expression()),
352
352
  ]
353
353
  )
@@ -2,13 +2,17 @@ from __future__ import annotations
2
2
 
3
3
  import logging
4
4
  from abc import ABC
5
+ from datetime import timezone, tzinfo
5
6
  from pathlib import Path
6
7
  from typing import Callable, ClassVar, Dict, Literal, Optional, Union
7
8
 
8
9
  import psycopg
9
10
  from pydantic import Field, IPvAnyAddress, SecretStr, field_validator
10
- from soda_core.common.data_source_connection import DataSourceConnection
11
- from soda_core.common.data_source_results import QueryResult, UpdateResult
11
+ from soda_core.common.data_source_connection import (
12
+ DataSourceConnection,
13
+ parse_session_timezone,
14
+ )
15
+ from soda_core.common.data_source_results import QueryResult
12
16
  from soda_core.common.logging_constants import soda_logger
13
17
  from soda_core.model.data_source.data_source import DataSourceBase
14
18
  from soda_core.model.data_source.data_source_connection_properties import (
@@ -86,6 +90,14 @@ class PostgresDataSourceConnection(DataSourceConnection):
86
90
  connection = psycopg.connect(**connection_kwargs)
87
91
  return connection
88
92
 
93
+ def _fetch_session_timezone(self) -> tzinfo:
94
+ with self.connection.cursor() as cursor:
95
+ cursor.execute("SHOW timezone")
96
+ row = cursor.fetchone()
97
+ if not row:
98
+ return timezone.utc
99
+ return parse_session_timezone(row[0])
100
+
89
101
  def execute_query(self, sql: str, log_query: bool = True) -> QueryResult:
90
102
  try:
91
103
  return super().execute_query(sql, log_query=log_query)
@@ -95,7 +107,7 @@ class PostgresDataSourceConnection(DataSourceConnection):
95
107
  self.rollback()
96
108
  raise e
97
109
 
98
- def execute_update(self, sql: str, log_query: bool = True) -> UpdateResult:
110
+ def execute_update(self, sql: str, log_query: bool = True) -> int:
99
111
  try:
100
112
  return super().execute_update(sql, log_query=log_query)
101
113
  except psycopg.errors.Error as e: # Catch the error and roll back the transaction
@@ -35,9 +35,9 @@ class PostgresMetadataTablesQuery(MetadataTablesQuery):
35
35
  select: list = [
36
36
  SELECT(
37
37
  [
38
- COLUMN(current_database_expression, field_alias="table_catalog"),
39
- COLUMN("nspname", table_alias="n", field_alias="table_schema"),
40
- COLUMN("relname", table_alias="c", field_alias="table_name"),
38
+ current_database_expression.AS("table_catalog"),
39
+ COLUMN("nspname", table_alias="n").AS("table_schema"),
40
+ COLUMN("relname", table_alias="c").AS("table_name"),
41
41
  RAW_SQL(self.sql_dialect.relkind_table_type_sql_expression()),
42
42
  ]
43
43
  ),
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soda-postgres
3
- Version: 4.3.0
3
+ Version: 4.14.0
4
4
  Summary: Soda Postgres V4
5
5
  Author-email: "Soda Data N.V." <info@soda.io>
6
6
  License: Proprietary
7
7
  Requires-Python: >=3.10
8
- Requires-Dist: soda-core==4.3.0
8
+ Requires-Dist: soda-core==4.14.0
9
9
  Requires-Dist: psycopg[binary]>=3.2
@@ -1,2 +1,2 @@
1
- soda-core==4.3.0
1
+ soda-core==4.14.0
2
2
  psycopg[binary]>=3.2
File without changes