Search code examples
google-cloud-platformgoogle-cloud-dataflowapache-beamgoogle-cloud-bigtable

Is there any way to dump boolean object in Cloud BigTable?


I have certain usecase where api service are retrieving BigTable rows using rowKey. The issue I'm going through is api service is trying to retrieve some columns with boolean value and doing boolean comparison in front-end side. Since BigTable doesn't support that datatype. The front-end service comparison part is not working as expected. I'm using the below code to store boolean value in BigTable.

                    Boolean value = Boolean.parseBoolean(newImageMap.get(Key).toString());
                    SetCell setCell = SetCell.newBuilder()
                            .setFamilyName(Utility.COLUMN_FAMILY)
                            .setColumnQualifier(Utility.str_to_bb(Key,StandardCharsets.UTF_8))
                            .setTimestampMicros(yearAgoMillis)
                            .setValue(ByteString.copyFrom(Bytes.toBytes(value)))
                        //  .setValue(Utility.str_to_bb(String.valueOf(value),StandardCharsets.UTF_8))
                            .build();

But the boolean value is stored as string in BigTable. You can see the stored value in below snapshot. Let me know in case there is a way-out to handle this type of use-cases. boolean-value-ss


Solution

  • Dumping boolean object in BigTable is not possible as BigTable doesn't support boolean datatype. Rather I will suggest you to make the changes in your driver code and type-case the datatype to suitable form and send it to front-end side, which would be more suitable. For that you have to pre-identify the boolean datatype from source end and stored it as configuration which will be an input to driver code. Let me know in case this solution works.