From 39d58de8ea068d128d3c081bb52e68d27aad9c2f Mon Sep 17 00:00:00 2001 From: Harry Brundage Date: Sat, 2 Nov 2024 18:53:53 +0000 Subject: [PATCH] feat: allow table creates to specific column types with the low level proto format Without this, table creates can't specify a value type ever, which is required if you want to use `AddToCell` mutations for server-side aggregations. With this in place, the call to create a table with an aggregated value type is nasty, but possible. Here's what it would look like: ``` const int64Type: google.bigtable.v2.IType = { int64Type: { encoding: { bigEndianBytes: {} }, }, }; bigtable.table("some_table").create({ families: [ { name: "aggregations", rule: { versions: 1, }, // hacky specification of the column family aggregation type -- the JS client doesn't have support for these types, but putting this here passes it down to the eventual protobuf call the client makes valueType: { aggregateType: { inputType: int64Type, stateType: int64Type, sum: {}, }, }, }, ], }); ``` --- src/instance.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/instance.ts b/src/instance.ts index 7d5569bd5..361c07ec8 100644 --- a/src/instance.ts +++ b/src/instance.ts @@ -522,6 +522,9 @@ Please use the format 'my-instance' or '${bigtable.projectName}/instances/my-ins if (family.rule) { columnFamily.gcRule = Family.formatRule_(family.rule); } + if (family.valueType) { + columnFamily.valueType = family.valueType; + } return families; }, {}