Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 5eaf38e

Browse files
fix: add a DATE type e2e test (#1511)
* fix:Add a DATE type test * fix:Add a DATE type test * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 4c532b0 commit 5eaf38e

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryTimeEncoderTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ public static void beforeClass() throws IOException {
8484
com.google.cloud.bigquery.Field.newBuilder(
8585
"test_datetime_micros", StandardSQLTypeName.DATETIME)
8686
.setMode(Mode.REPEATED)
87+
.build(),
88+
com.google.cloud.bigquery.Field.newBuilder(
89+
"test_date_repeated", StandardSQLTypeName.DATE)
90+
.setMode(Mode.REPEATED)
91+
.build(),
92+
com.google.cloud.bigquery.Field.newBuilder(
93+
"test_date", StandardSQLTypeName.DATE)
94+
.setMode(Mode.NULLABLE)
8795
.build())))
8896
.build();
8997
bigquery.create(tableInfo);
@@ -122,11 +130,25 @@ public void TestTimeEncoding()
122130
.setMode(TableFieldSchema.Mode.REPEATED)
123131
.setName("test_datetime_micros")
124132
.build();
133+
TableFieldSchema TEST_DATE_REPEATED =
134+
TableFieldSchema.newBuilder()
135+
.setType(TableFieldSchema.Type.DATE)
136+
.setMode(TableFieldSchema.Mode.REPEATED)
137+
.setName("test_date_repeated")
138+
.build();
139+
TableFieldSchema TEST_DATE =
140+
TableFieldSchema.newBuilder()
141+
.setType(TableFieldSchema.Type.DATE)
142+
.setMode(TableFieldSchema.Mode.NULLABLE)
143+
.setName("test_date")
144+
.build();
125145
TableSchema tableSchema =
126146
TableSchema.newBuilder()
127147
.addFields(0, TEST_STRING)
128148
.addFields(1, TEST_TIME)
129149
.addFields(2, TEST_DATETIME)
150+
.addFields(3, TEST_DATE_REPEATED)
151+
.addFields(4, TEST_DATE)
130152
.build();
131153
try (JsonStreamWriter jsonStreamWriter =
132154
JsonStreamWriter.newBuilder(parent.toString(), tableSchema).build()) {
@@ -157,6 +179,8 @@ public void TestTimeEncoding()
157179
CivilTimeEncoder.encodePacked64DatetimeMicros(
158180
LocalDateTime.of(2050, 1, 2, 3, 4, 5, 6_000)),
159181
}));
182+
row.put("test_date_repeated", new JSONArray(new int[] {0, 300, 14238}));
183+
row.put("test_date", 300);
160184
JSONArray jsonArr = new JSONArray(new JSONObject[] {row});
161185
ApiFuture<AppendRowsResponse> response = jsonStreamWriter.append(jsonArr, -1);
162186
Assert.assertFalse(response.get().getAppendResult().hasOffset());
@@ -179,6 +203,13 @@ public void TestTimeEncoding()
179203
"1995-05-19T10:30:45", currentRow.get(2).getRepeatedValue().get(1).getStringValue());
180204
assertEquals(
181205
"2000-01-01T00:00:00", currentRow.get(2).getRepeatedValue().get(2).getStringValue());
206+
207+
assertEquals("1970-01-01", currentRow.get(3).getRepeatedValue().get(0).getStringValue());
208+
assertEquals("1970-10-28", currentRow.get(3).getRepeatedValue().get(1).getStringValue());
209+
assertEquals("2008-12-25", currentRow.get(3).getRepeatedValue().get(2).getStringValue());
210+
211+
assertEquals("1970-10-28", currentRow.get(4).getStringValue());
212+
182213
assertEquals(
183214
"2026-03-11T05:45:12.009000",
184215
currentRow.get(2).getRepeatedValue().get(3).getStringValue());

0 commit comments

Comments
 (0)