Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.1

- Updating an existing `_raw_latest` view now builds the snapshot query with the configured BigQuery project. That path dropped `bqProjectId`, so the query fell back to `process.env.PROJECT_ID`, which is only set for extensions. On a kit, or any caller that passes `bqProjectId` but does not set `PROJECT_ID`, the query referenced `undefined.<dataset>.<table>` and BigQuery rejected the update. For an extension whose `BIGQUERY_PROJECT_ID` differs from `PROJECT_ID`, the update previously built the view against the functions project instead of the BigQuery project.

## 2.2.0

- Works on `firebase-admin` 14. 2.1.1 widened the range but the package still used the namespaced API (`admin.apps`, `admin.firestore.Timestamp`), which firebase-admin 14 removes, so it threw at import wherever it was resolved against admin 14. Every use is now the modular API from `firebase-admin/app` and `firebase-admin/firestore`, which works on 13 and 14 alike.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "git+https://github.com/firebase/extensions.git",
"directory": "firestore-bigquery-export/firestore-bigquery-change-tracker"
},
"version": "2.2.0",
"version": "2.2.1",
"engines": {
"node": ">=18"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,44 @@ describe("initializeLatestView", () => {

expect(initializeLatestMaterializedView).not.toHaveBeenCalled();
});

it("uses the BigQuery project when updating an existing view", async () => {
const originalProjectId = process.env.PROJECT_ID;
process.env.PROJECT_ID = "function-project";
const metadata = {
schema: {
fields: [{ name: "document_id" }, { name: "old_data" }],
},
view: { query: "SELECT FIRST_VALUE(data)" },
};
mockView.getMetadata.mockResolvedValueOnce([metadata]);

try {
await initializeLatestView({
bq: { projectId: "bigquery-project" } as any,
dataset: { id: "test_dataset" } as any,
view: mockView as any,
viewExists: true,
rawChangeLogTableName: "test_raw_table",
rawLatestViewName: "test_raw_view",
changeTrackerConfig: {
...mockConfig,
useNewSnapshotQuerySyntax: true,
},
});

expect(mockView.setMetadata).toHaveBeenCalledWith(metadata);
expect(metadata.view.query).toContain(
"`bigquery-project.test_dataset.test_raw_table`"
);
expect(metadata.view.query).not.toContain("function-project");
} finally {
if (originalProjectId === undefined) {
delete process.env.PROJECT_ID;
} else {
process.env.PROJECT_ID = originalProjectId;
}
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export async function initializeLatestView({
datasetId: config.datasetId,
tableName: rawChangeLogTableName,
schema,
bqProjectId: bq.projectId,
useLegacyQuery: !config.useNewSnapshotQuerySyntax,
});

Expand Down
Loading