@firebaseextensions/firestore-bigquery-change-tracker 1.1.18 → 1.1.20
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.
- package/lib/bigquery/index.js +22 -2
- package/lib/bigquery/schema.js +7 -1
- package/lib/logs.js +4 -1
- package/package.json +1 -1
package/lib/bigquery/index.js
CHANGED
|
@@ -254,6 +254,10 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
254
254
|
const documentIdColExists = fields.find((column) => column.name === "document_id");
|
|
255
255
|
const pathParamsColExists = fields.find((column) => column.name === "path_params");
|
|
256
256
|
const oldDataColExists = fields.find((column) => column.name === "old_data");
|
|
257
|
+
if (!oldDataColExists) {
|
|
258
|
+
fields.push(schema_1.oldDataField);
|
|
259
|
+
logs.addNewColumn(this.rawChangeLogTableName(), schema_1.oldDataField.name);
|
|
260
|
+
}
|
|
257
261
|
if (!documentIdColExists) {
|
|
258
262
|
fields.push(schema_1.documentIdField);
|
|
259
263
|
logs.addNewColumn(this.rawChangeLogTableName(), schema_1.documentIdField.name);
|
|
@@ -262,7 +266,6 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
262
266
|
fields.push(schema_1.documentPathParams);
|
|
263
267
|
logs.addNewColumn(this.rawChangeLogTableName(), schema_1.documentPathParams.name);
|
|
264
268
|
}
|
|
265
|
-
await partitioning.addPartitioningToSchema(metadata.schema.fields);
|
|
266
269
|
/** Updated table metadata if required */
|
|
267
270
|
const shouldUpdate = await checkUpdates_1.tableRequiresUpdate({
|
|
268
271
|
table,
|
|
@@ -272,7 +275,16 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
272
275
|
oldDataColExists,
|
|
273
276
|
});
|
|
274
277
|
if (shouldUpdate) {
|
|
278
|
+
/** set partitioning */
|
|
279
|
+
await partitioning.addPartitioningToSchema(metadata.schema.fields);
|
|
280
|
+
/** update table metadata with changes. */
|
|
275
281
|
await table.setMetadata(metadata);
|
|
282
|
+
logs.updatingMetadata(this.rawChangeLogTableName(), {
|
|
283
|
+
config: this.config,
|
|
284
|
+
documentIdColExists,
|
|
285
|
+
pathParamsColExists,
|
|
286
|
+
oldDataColExists,
|
|
287
|
+
});
|
|
276
288
|
}
|
|
277
289
|
}
|
|
278
290
|
else {
|
|
@@ -333,8 +345,16 @@ class FirestoreBigQueryEventHistoryTracker {
|
|
|
333
345
|
schema,
|
|
334
346
|
useLegacyQuery: !this.config.useNewSnapshotQuerySyntax,
|
|
335
347
|
});
|
|
336
|
-
|
|
348
|
+
if (!documentIdColExists) {
|
|
349
|
+
logs.addNewColumn(this.rawLatestView(), schema_1.documentIdField.name);
|
|
350
|
+
}
|
|
337
351
|
await view.setMetadata(metadata);
|
|
352
|
+
logs.updatingMetadata(this.rawLatestView(), {
|
|
353
|
+
config: this.config,
|
|
354
|
+
documentIdColExists,
|
|
355
|
+
pathParamsColExists,
|
|
356
|
+
oldDataColExists,
|
|
357
|
+
});
|
|
338
358
|
}
|
|
339
359
|
}
|
|
340
360
|
else {
|
package/lib/bigquery/schema.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getNewPartitionField = exports.RawChangelogSchema = exports.RawChangelogViewSchema = exports.documentPathParams = exports.documentIdField = exports.longitudeField = exports.latitudeField = exports.timestampField = exports.operationField = exports.eventIdField = exports.documentNameField = exports.dataField = void 0;
|
|
18
|
+
exports.getNewPartitionField = exports.RawChangelogSchema = exports.RawChangelogViewSchema = exports.oldDataField = exports.documentPathParams = exports.documentIdField = exports.longitudeField = exports.latitudeField = exports.timestampField = exports.operationField = exports.eventIdField = exports.documentNameField = exports.dataField = void 0;
|
|
19
19
|
const bigQueryField = (name, type, mode, fields) => ({
|
|
20
20
|
fields,
|
|
21
21
|
mode: mode || "NULLABLE",
|
|
@@ -43,6 +43,12 @@ exports.documentPathParams = {
|
|
|
43
43
|
type: "STRING",
|
|
44
44
|
description: "JSON string representing wildcard params with Firestore Document ids",
|
|
45
45
|
};
|
|
46
|
+
exports.oldDataField = {
|
|
47
|
+
name: "old_data",
|
|
48
|
+
mode: "NULLABLE",
|
|
49
|
+
type: "STRING",
|
|
50
|
+
description: "The full JSON representation of the document state before the indicated operation is applied. This field will be null for CREATE operations.",
|
|
51
|
+
};
|
|
46
52
|
/*
|
|
47
53
|
* We cannot specify a schema for view creation, and all view columns default
|
|
48
54
|
* to the NULLABLE mode.
|
package/lib/logs.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.failedToInitializeWait = exports.tableCreationError = exports.invalidClustering = exports.hourAndDatePartitioningWarning = exports.invalidTableReference = exports.invalidProjectIdWarning = exports.cannotPartitionExistingTable = exports.removedClustering = exports.updatedClustering = exports.bigQueryTableInsertErrors = exports.firestoreTimePartitioningParametersWarning = exports.firestoreTimePartitionFieldError = exports.addPartitionFieldColumn = exports.addNewColumn = exports.timestampMissingValue = exports.error = exports.dataTypeInvalid = exports.dataInserting = exports.dataInsertRetried = exports.dataInserted = exports.complete = exports.bigQueryViewValidating = exports.bigQueryViewValidated = exports.bigQueryViewUpToDate = exports.bigQueryViewUpdating = exports.bigQueryViewUpdated = exports.bigQueryViewAlreadyExists = exports.bigQueryViewCreating = exports.bigQueryViewCreated = exports.bigQueryUserDefinedFunctionCreated = exports.bigQueryUserDefinedFunctionCreating = exports.bigQueryTableValidating = exports.bigQueryTableValidated = exports.bigQueryTableUpToDate = exports.bigQueryTableUpdating = exports.bigQueryTableUpdated = exports.bigQueryTableCreating = exports.bigQueryTableCreated = exports.bigQueryTableAlreadyExists = exports.bigQuerySchemaViewCreated = exports.bigQueryLatestSnapshotViewQueryCreated = exports.bigQueryErrorRecordingDocumentChange = exports.bigQueryDatasetExists = exports.bigQueryDatasetCreating = exports.bigQueryDatasetCreated = exports.arrayFieldInvalid = void 0;
|
|
18
|
+
exports.updatingMetadata = exports.failedToInitializeWait = exports.tableCreationError = exports.invalidClustering = exports.hourAndDatePartitioningWarning = exports.invalidTableReference = exports.invalidProjectIdWarning = exports.cannotPartitionExistingTable = exports.removedClustering = exports.updatedClustering = exports.bigQueryTableInsertErrors = exports.firestoreTimePartitioningParametersWarning = exports.firestoreTimePartitionFieldError = exports.addPartitionFieldColumn = exports.addNewColumn = exports.timestampMissingValue = exports.error = exports.dataTypeInvalid = exports.dataInserting = exports.dataInsertRetried = exports.dataInserted = exports.complete = exports.bigQueryViewValidating = exports.bigQueryViewValidated = exports.bigQueryViewUpToDate = exports.bigQueryViewUpdating = exports.bigQueryViewUpdated = exports.bigQueryViewAlreadyExists = exports.bigQueryViewCreating = exports.bigQueryViewCreated = exports.bigQueryUserDefinedFunctionCreated = exports.bigQueryUserDefinedFunctionCreating = exports.bigQueryTableValidating = exports.bigQueryTableValidated = exports.bigQueryTableUpToDate = exports.bigQueryTableUpdating = exports.bigQueryTableUpdated = exports.bigQueryTableCreating = exports.bigQueryTableCreated = exports.bigQueryTableAlreadyExists = exports.bigQuerySchemaViewCreated = exports.bigQueryLatestSnapshotViewQueryCreated = exports.bigQueryErrorRecordingDocumentChange = exports.bigQueryDatasetExists = exports.bigQueryDatasetCreating = exports.bigQueryDatasetCreated = exports.arrayFieldInvalid = void 0;
|
|
19
19
|
const firebase_functions_1 = require("firebase-functions");
|
|
20
20
|
exports.arrayFieldInvalid = (fieldName) => {
|
|
21
21
|
firebase_functions_1.logger.warn(`Array field '${fieldName}' does not contain an array, skipping`);
|
|
@@ -173,3 +173,6 @@ exports.tableCreationError = (table, message) => {
|
|
|
173
173
|
exports.failedToInitializeWait = (message) => {
|
|
174
174
|
firebase_functions_1.logger.warn(`Failed while waiting to initialize.`, message);
|
|
175
175
|
};
|
|
176
|
+
exports.updatingMetadata = (tableName, resources) => {
|
|
177
|
+
firebase_functions_1.logger.info(`Updated Metadata on ${tableName}, ${JSON.stringify(resources)})`);
|
|
178
|
+
};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "github.com/firebase/extensions.git",
|
|
6
6
|
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.1.
|
|
8
|
+
"version": "1.1.20",
|
|
9
9
|
"description": "Core change-tracker library for Cloud Firestore Collection BigQuery Exports",
|
|
10
10
|
"main": "./lib/index.js",
|
|
11
11
|
"scripts": {
|