Skip to content

Commit

Permalink
feat: add support for RANGE type with Write API and adapt pkg (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarowolfx authored May 3, 2024
1 parent ce4f88c commit 51924ab
Show file tree
Hide file tree
Showing 12 changed files with 599 additions and 16 deletions.
12 changes: 12 additions & 0 deletions samples/append_rows_proto2.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ function main(
};
serializedRows.push(SampleData.encode(row).finish());

// Row 16
const timestampStart = new Date('2022-01-09T03:49:46.564Z').getTime();
const timestampEnd = new Date('2022-01-09T04:49:46.564Z').getTime();
row = {
rowNum: 16,
rangeCol: {
start: timestampStart * 1000,
end: timestampEnd * 1000,
},
};
serializedRows.push(SampleData.encode(row).finish());

offsetValue = 12;

// Send batch.
Expand Down
10 changes: 10 additions & 0 deletions samples/append_rows_table_to_proto2.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ function main(
};
rows.push(row);

// Row 16
row = {
row_num: 16,
range_col: {
start: new Date('2022-01-09T03:49:46.564Z'),
end: new Date('2022-01-09T04:49:46.564Z'),
},
};
rows.push(row);

offsetValue = 12;

// Send batch.
Expand Down
18 changes: 17 additions & 1 deletion samples/sample_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@
"type": "SampleStruct",
"id": 15
},
"range_col": {
"type": "SampleRange",
"id": 16
},
"row_num": {
"rule": "required",
"type": "int64",
"id": 16
"id": 17
}
},
"nested": {
Expand All @@ -81,6 +85,18 @@
"id": 1
}
}
},
"SampleRange": {
"fields": {
"start": {
"type": "int64",
"id": 1
},
"end": {
"type": "int64",
"id": 2
}
}
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion samples/sample_data.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ message SampleData {
optional int64 sub_int_col = 1;
}

message SampleRange {
optional int64 start = 1;
optional int64 end = 2;
}

// The following types map directly between protocol buffers and their
// corresponding BigQuery data types.
optional bool bool_col = 1;
Expand All @@ -55,7 +60,9 @@ message SampleData {
optional SampleStruct struct_col = 14;
repeated SampleStruct struct_list = 15;

optional SampleRange range_col = 16;

// Use the required keyword for client-side validation of required fields.
required int64 row_num = 16;
required int64 row_num = 17;
}
// [END bigquerystorage_append_rows_raw_proto2_definition]
Loading

0 comments on commit 51924ab

Please sign in to comment.