logos-sdk 0.0.25.dev29__tar.gz → 0.0.25.dev30__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.
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/PKG-INFO +1 -1
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/big_query/BigQuery.py +27 -14
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk.egg-info/PKG-INFO +1 -1
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/LICENSE +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/README.md +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/__init__.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/big_query/__init__.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/logging/LogosLogger.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/logging/__init__.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/CampaignManager.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/Collabim.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/DV360.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/Facebook.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/GA4.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/GoogleAds.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/GoogleSheets.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/MarketMiner.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/MerchantCenter.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/MicrosoftAdvertising.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/MicrosoftAdvertisingMerchantCenter.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/Sklik.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/__init__.py +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk.egg-info/SOURCES.txt +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk.egg-info/dependency_links.txt +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk.egg-info/requires.txt +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk.egg-info/top_level.txt +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/setup.cfg +0 -0
- {logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/setup.py +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
|
+
import uuid
|
|
2
3
|
from datetime import datetime
|
|
3
4
|
|
|
4
5
|
import google.auth.exceptions
|
|
@@ -96,6 +97,8 @@ class BigQuery:
|
|
|
96
97
|
schema_columns: List[Dict],
|
|
97
98
|
partitioning_column_name: str,
|
|
98
99
|
partition_type=bigquery.TimePartitioningType.DAY,
|
|
100
|
+
retention_days: Optional[int] = None,
|
|
101
|
+
cluster_fields: Optional[List[str]] = None,
|
|
99
102
|
):
|
|
100
103
|
bq_table = self.check_table_exists(dataset_id, table_id)
|
|
101
104
|
if bq_table is None:
|
|
@@ -105,6 +108,8 @@ class BigQuery:
|
|
|
105
108
|
schema_columns,
|
|
106
109
|
partitioning_column_name,
|
|
107
110
|
partition_type,
|
|
111
|
+
retention_days,
|
|
112
|
+
cluster_fields,
|
|
108
113
|
)
|
|
109
114
|
|
|
110
115
|
self._insert_into_table(bq_table, records)
|
|
@@ -127,6 +132,8 @@ class BigQuery:
|
|
|
127
132
|
schema_columns: List[Dict],
|
|
128
133
|
partitioning_column_name: str,
|
|
129
134
|
partition_type=bigquery.TimePartitioningType.DAY,
|
|
135
|
+
retention_days: Optional[int] = None,
|
|
136
|
+
cluster_fields: Optional[List[str]] = None,
|
|
130
137
|
):
|
|
131
138
|
table_schema = [
|
|
132
139
|
bigquery.schema.SchemaField(
|
|
@@ -140,11 +147,20 @@ class BigQuery:
|
|
|
140
147
|
try:
|
|
141
148
|
sql_format = self._get_table_id_sql_format(dataset_id, table_id)
|
|
142
149
|
table_object = bigquery.Table(sql_format, schema=table_schema)
|
|
143
|
-
|
|
150
|
+
|
|
151
|
+
time_partitioning_kwargs = {
|
|
152
|
+
"type_": partition_type,
|
|
153
|
+
"field": partitioning_column_name,
|
|
154
|
+
}
|
|
155
|
+
if retention_days is not None and retention_days > 0:
|
|
156
|
+
time_partitioning_kwargs["expiration_ms"] = (
|
|
157
|
+
retention_days * 24 * 60 * 60 * 1000
|
|
158
|
+
)
|
|
144
159
|
table_object.time_partitioning = bigquery.TimePartitioning(
|
|
145
|
-
|
|
146
|
-
field=partitioning_column_name, # The column to use for partitioning
|
|
160
|
+
**time_partitioning_kwargs
|
|
147
161
|
)
|
|
162
|
+
if cluster_fields:
|
|
163
|
+
table_object.clustering_fields = cluster_fields
|
|
148
164
|
return self._service.create_table(table_object)
|
|
149
165
|
except google.cloud.exceptions.Conflict:
|
|
150
166
|
return False
|
|
@@ -220,25 +236,22 @@ class BigQuery:
|
|
|
220
236
|
raise BigQueryException(errors)
|
|
221
237
|
|
|
222
238
|
def upsert_into_table(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
239
|
+
self,
|
|
240
|
+
dataset_id: str,
|
|
241
|
+
target_table: str,
|
|
242
|
+
records: List[Dict],
|
|
243
|
+
schema_columns: List[Dict],
|
|
244
|
+
key_columns: Sequence[str],
|
|
229
245
|
) -> None:
|
|
230
246
|
if not records:
|
|
231
247
|
return
|
|
232
248
|
if not key_columns:
|
|
233
249
|
return
|
|
234
250
|
|
|
235
|
-
bq_table = self.check_table_exists(dataset_id, target_table)
|
|
236
|
-
if bq_table is None:
|
|
237
|
-
self.create_table(dataset_id, target_table, schema_columns)
|
|
238
251
|
table_id = f"{self.project_id}.{dataset_id}.{target_table}"
|
|
239
252
|
cols = [f["name"] for f in schema_columns]
|
|
240
253
|
|
|
241
|
-
staging_table_name = f"_staging_{
|
|
254
|
+
staging_table_name = f"_staging_{str(uuid.uuid4())}"
|
|
242
255
|
staging_table_id = f"{self.project_id}.{dataset_id}.{staging_table_name}"
|
|
243
256
|
self.create_table(dataset_id, staging_table_name, schema_columns)
|
|
244
257
|
|
|
@@ -248,7 +261,7 @@ class BigQuery:
|
|
|
248
261
|
|
|
249
262
|
on_clause = " AND ".join(f"T.{q(k)} = S.{q(k)}" for k in key_columns)
|
|
250
263
|
update_cols = [c for c in cols if c not in set(key_columns)]
|
|
251
|
-
update_set = ",\n ".join(f"{q(c)} = S.{q(c)}" for c in update_cols)
|
|
264
|
+
update_set = ",\n ".join(f"T.{q(c)} = S.{q(c)}" for c in update_cols)
|
|
252
265
|
|
|
253
266
|
insert_cols = ", ".join(q(c) for c in cols)
|
|
254
267
|
insert_vals = ", ".join(f"S.{q(c)}" for c in cols)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{logos_sdk-0.0.25.dev29 → logos_sdk-0.0.25.dev30}/logos_sdk/services/MicrosoftAdvertising.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|