bulltrackers-module 1.0.754 → 1.0.756
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.
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* * FIX: Switched to bigquery.createJob for GCS imports to prevent local file path interpretation errors.
|
|
10
10
|
* * FIX: Improved error logging to catch swallowed BigQuery insert errors.
|
|
11
11
|
* * FIX: finalizeResults now checks for file existence to prevent "Not found" errors on empty results.
|
|
12
|
+
* * FIX: Added SAFE.PARSE_JSON to MERGE statement for BOTH result_data and dependency_result_hashes.
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
const { Firestore } = require('@google-cloud/firestore');
|
|
@@ -498,6 +499,8 @@ class StorageManager {
|
|
|
498
499
|
const dataset = this.bigquery.dataset(this.config.bigquery.dataset);
|
|
499
500
|
const table = dataset.table(tableName);
|
|
500
501
|
|
|
502
|
+
// Note: result_data and dependency_result_hashes are loaded as STRING from the JSON file
|
|
503
|
+
// They will be parsed into JSON during the merge step.
|
|
501
504
|
const schema = [
|
|
502
505
|
{ name: 'date', type: 'DATE', mode: 'REQUIRED' },
|
|
503
506
|
{ name: 'computation_name', type: 'STRING', mode: 'REQUIRED' },
|
|
@@ -520,6 +523,9 @@ class StorageManager {
|
|
|
520
523
|
|
|
521
524
|
await this._ensureBigQueryTable(targetTable);
|
|
522
525
|
|
|
526
|
+
// FIX: Added SAFE.PARSE_JSON() to BOTH dependency_result_hashes AND result_data
|
|
527
|
+
// The source (temp table) has these as STRING (from the JSON file).
|
|
528
|
+
// The destination (target table) has these as JSON types.
|
|
523
529
|
const mergeQuery = `
|
|
524
530
|
MERGE INTO ${fullTarget} T
|
|
525
531
|
USING (
|
|
@@ -533,15 +539,15 @@ class StorageManager {
|
|
|
533
539
|
UPDATE SET
|
|
534
540
|
code_hash = S.code_hash,
|
|
535
541
|
result_hash = S.result_hash,
|
|
536
|
-
dependency_result_hashes = S.dependency_result_hashes,
|
|
542
|
+
dependency_result_hashes = SAFE.PARSE_JSON(S.dependency_result_hashes),
|
|
537
543
|
entity_count = S.entity_count,
|
|
538
|
-
result_data = S.result_data,
|
|
544
|
+
result_data = SAFE.PARSE_JSON(S.result_data),
|
|
539
545
|
updated_at = S.updated_at
|
|
540
546
|
WHEN NOT MATCHED THEN
|
|
541
547
|
INSERT (date, computation_name, category, entity_id, code_hash, result_hash,
|
|
542
548
|
dependency_result_hashes, entity_count, result_data, updated_at)
|
|
543
549
|
VALUES (S.date, S.computation_name, S.category, S.entity_id, S.code_hash, S.result_hash,
|
|
544
|
-
S.dependency_result_hashes, S.entity_count, S.result_data, S.updated_at)
|
|
550
|
+
SAFE.PARSE_JSON(S.dependency_result_hashes), S.entity_count, SAFE.PARSE_JSON(S.result_data), S.updated_at)
|
|
545
551
|
`;
|
|
546
552
|
|
|
547
553
|
await this.bigquery.query({ query: mergeQuery, location: this.config.bigquery.location });
|