Retrieving Multiple Versions of Data
By default, the Simba HBase ODBC Driver only retrieves the latest version of the queried data. However, you can retrieve multiple versions of the same data by using the SQLINTEGER statement attribute HB_ATTR_MAX_VERSION to specify the number of versions to retrieve. The HB_ATTR_MAX_VERSION attribute is provided by the connector, and it has an identifier of 40000.
Note:
For information about how to set statement attributes, see "SQLSetStmtAttr Function" in the ODBC API Reference: https://msdn.microsoft.com/en-us/library/ms712631(v=vs.85).aspx.
If HB_ATTR_MAX_VERSION is set to a value greater than 1, then the connector returns additional columns for each version of the data, up to the requested HB_ATTR_MAX_VERSION value. If values do not exist for the requested version of the data, then null values are returned.
For example, consider the following raw data in JSON format using arbitrary integer timestamps:
{"row": {"family1": {"val1": {4: "val1Oldest", 15: "val1Latest"}, "val2": {15: "val2Latest"}}, "family2": {"val3": {1: "val3Oldest", 15: "val3Latest"}}}}
Querying the data using the default HB_ATTR_MAX_VERSION value of 1 returns the following result set:
family1:val1 | family1:val2 | family2:val3 |
---|---|---|
val1Latest |
val2Latest |
val3Latest |
To retrieve the two most recent versions of the same data, set HB_ATTR_MAX_VERSION to 2. Querying the data again returns the following result set:
family1: val1 |
family1: val1_1 |
family1: val2 |
family1: val2_1 |
family2: val3 |
family2: val3__1 |
---|---|---|---|---|---|
val1Latest |
val1Oldest |
val2Latest |
null |
val3Latest |
val3Oldest |
The column with the current version of the data is named without a suffix. Additional columns are named with a suffix that indicates the distance from the most recent version. For example, the second most recent value is in the _1 column, the third most recent in the _2 column, and so on.