Skip to content

Commit 173e65a

Browse files
feat: add system tests for timestampOutputFormat options
Add 8 system tests to verify BigQuery `getRows` functionality with various combinations of `timestampOutputFormat` and `useInt64Timestamp`. Tests cover all format options: UNSPECIFIED, FLOAT64, INT64, ISO8601_STRING combined with boolean `useInt64Timestamp` values. Asserts that timestamps inserted with picosecond precision are retrieved correctly (truncated to microsecond precision as per BigQuery storage).
1 parent a6dd325 commit 173e65a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

system-test/timestamp_output_format.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ describe('Timestamp Output Format System Tests', () => {
2424
const tableId = `timestamp_table_${randomUUID().replace(/-/g, '_')}`;
2525
const dataset = bigquery.dataset(datasetId);
2626
const table = dataset.table(tableId);
27+
const expectedValue = '2023-01-01T12:00:00.123456Z';
2728

2829
before(async () => {
2930
await dataset.create();
3031
await table.create({
3132
schema: [{name: 'ts', type: 'TIMESTAMP'}],
3233
});
3334
// Insert a row to test retrieval
34-
await table.insert([{ts: '2023-01-01T12:00:00.123456Z'}]);
35+
await table.insert([{ts: '2023-01-01T12:00:00.123456789123Z'}]);
3536
});
3637

3738
after(async () => {
@@ -48,6 +49,7 @@ describe('Timestamp Output Format System Tests', () => {
4849
'formatOptions.useInt64Timestamp': true
4950
});
5051
assert(rows.length > 0);
52+
assert.strictEqual(rows[0].ts.value, expectedValue);
5153
});
5254

5355
it('should call getRows with TIMESTAMP_OUTPUT_FORMAT_UNSPECIFIED and useInt64Timestamp=false', async () => {
@@ -56,6 +58,7 @@ describe('Timestamp Output Format System Tests', () => {
5658
'formatOptions.useInt64Timestamp': false
5759
});
5860
assert(rows.length > 0);
61+
assert.strictEqual(rows[0].ts.value, expectedValue);
5962
});
6063

6164
it('should call getRows with FLOAT64 and useInt64Timestamp=true', async () => {
@@ -64,6 +67,7 @@ describe('Timestamp Output Format System Tests', () => {
6467
'formatOptions.useInt64Timestamp': true
6568
});
6669
assert(rows.length > 0);
70+
assert.strictEqual(rows[0].ts.value, expectedValue);
6771
});
6872

6973
it('should call getRows with FLOAT64 and useInt64Timestamp=false', async () => {
@@ -72,6 +76,7 @@ describe('Timestamp Output Format System Tests', () => {
7276
'formatOptions.useInt64Timestamp': false
7377
});
7478
assert(rows.length > 0);
79+
assert.strictEqual(rows[0].ts.value, expectedValue);
7580
});
7681

7782
it('should call getRows with INT64 and useInt64Timestamp=true', async () => {
@@ -80,6 +85,7 @@ describe('Timestamp Output Format System Tests', () => {
8085
'formatOptions.useInt64Timestamp': true
8186
});
8287
assert(rows.length > 0);
88+
assert.strictEqual(rows[0].ts.value, expectedValue);
8389
});
8490

8591
it('should call getRows with INT64 and useInt64Timestamp=false', async () => {
@@ -88,6 +94,7 @@ describe('Timestamp Output Format System Tests', () => {
8894
'formatOptions.useInt64Timestamp': false
8995
});
9096
assert(rows.length > 0);
97+
assert.strictEqual(rows[0].ts.value, expectedValue);
9198
});
9299

93100
it('should call getRows with ISO8601_STRING and useInt64Timestamp=true', async () => {
@@ -96,6 +103,7 @@ describe('Timestamp Output Format System Tests', () => {
96103
'formatOptions.useInt64Timestamp': true
97104
});
98105
assert(rows.length > 0);
106+
assert.strictEqual(rows[0].ts.value, expectedValue);
99107
});
100108

101109
it('should call getRows with ISO8601_STRING and useInt64Timestamp=false', async () => {
@@ -104,5 +112,6 @@ describe('Timestamp Output Format System Tests', () => {
104112
'formatOptions.useInt64Timestamp': false
105113
});
106114
assert(rows.length > 0);
115+
assert.strictEqual(rows[0].ts.value, expectedValue);
107116
});
108117
});

0 commit comments

Comments
 (0)