bulltrackers-module 1.0.755 → 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,7 +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
|
|
12
|
+
* * FIX: Added SAFE.PARSE_JSON to MERGE statement for BOTH result_data and dependency_result_hashes.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const { Firestore } = require('@google-cloud/firestore');
|
|
@@ -499,6 +499,8 @@ class StorageManager {
|
|
|
499
499
|
const dataset = this.bigquery.dataset(this.config.bigquery.dataset);
|
|
500
500
|
const table = dataset.table(tableName);
|
|
501
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.
|
|
502
504
|
const schema = [
|
|
503
505
|
{ name: 'date', type: 'DATE', mode: 'REQUIRED' },
|
|
504
506
|
{ name: 'computation_name', type: 'STRING', mode: 'REQUIRED' },
|
|
@@ -521,10 +523,9 @@ class StorageManager {
|
|
|
521
523
|
|
|
522
524
|
await this._ensureBigQueryTable(targetTable);
|
|
523
525
|
|
|
524
|
-
// FIX: Added SAFE.PARSE_JSON() to dependency_result_hashes
|
|
525
|
-
// The source (temp table) has
|
|
526
|
-
// The destination (target table) has
|
|
527
|
-
// We must explicitly parse the string to JSON during the merge.
|
|
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.
|
|
528
529
|
const mergeQuery = `
|
|
529
530
|
MERGE INTO ${fullTarget} T
|
|
530
531
|
USING (
|
|
@@ -540,13 +541,13 @@ class StorageManager {
|
|
|
540
541
|
result_hash = S.result_hash,
|
|
541
542
|
dependency_result_hashes = SAFE.PARSE_JSON(S.dependency_result_hashes),
|
|
542
543
|
entity_count = S.entity_count,
|
|
543
|
-
result_data = S.result_data,
|
|
544
|
+
result_data = SAFE.PARSE_JSON(S.result_data),
|
|
544
545
|
updated_at = S.updated_at
|
|
545
546
|
WHEN NOT MATCHED THEN
|
|
546
547
|
INSERT (date, computation_name, category, entity_id, code_hash, result_hash,
|
|
547
548
|
dependency_result_hashes, entity_count, result_data, updated_at)
|
|
548
549
|
VALUES (S.date, S.computation_name, S.category, S.entity_id, S.code_hash, S.result_hash,
|
|
549
|
-
SAFE.PARSE_JSON(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)
|
|
550
551
|
`;
|
|
551
552
|
|
|
552
553
|
await this.bigquery.query({ query: mergeQuery, location: this.config.bigquery.location });
|