virajjasani commented on code in PR #1884:
URL: https://github.com/apache/phoenix/pull/1884#discussion_r1645201577
##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java:
##########
@@ -861,17 +1355,66 @@ private void assertNumRecords(int count, Connection
conn, String dql, String...
}
private void assertHBaseRowTimestamp(String tableName, long
expectedTimestamp) throws Exception {
+ long actualTimestamp = getEmptyKVLatestCellTimestamp(tableName);
+ assertEquals(expectedTimestamp, actualTimestamp);
+ }
+
+ private long getEmptyKVLatestCellTimestamp(String tableName) throws
Exception {
+ Connection conn = DriverManager.getConnection(getUrl());
+ PTable pTable = PhoenixRuntime.getTable(conn, tableName);
+ byte[] emptyCQ =
EncodedColumnsUtil.getEmptyKeyValueInfo(pTable).getFirst();
+ return getColumnLatestCellTimestamp(tableName, emptyCQ);
+ }
+
+ private long getColumnLatestCellTimestamp(String tableName, byte[] cq)
throws Exception {
Scan scan = new Scan();
- byte[] emptyKVQualifier =
EncodedColumnsUtil.getEmptyKeyValueInfo(true).getFirst();
try (org.apache.hadoop.hbase.client.Connection hconn =
- ConnectionFactory.createConnection(config)) {
+ ConnectionFactory.createConnection(config)) {
Table table = hconn.getTable(TableName.valueOf(tableName));
ResultScanner resultScanner = table.getScanner(scan);
Result result = resultScanner.next();
- long actualTimestamp = result.getColumnLatestCell(
- QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES,
emptyKVQualifier).getTimestamp();
- assertEquals(expectedTimestamp, actualTimestamp);
+ return result.getColumnLatestCell(
+ QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES,
cq).getTimestamp();
+ }
+ }
+
+ private List<Long> getAllColumnsLatestCellTimestamp(Connection conn,
String tableName) throws Exception {
+ List<Long> timestampList = new ArrayList<>();
+ PTable pTable = conn.unwrap(PhoenixConnection.class).getTable(new
PTableKey(null, tableName));
+ List<PColumn> columns = pTable.getColumns();
+
+ // timestamp of the empty cell
+ timestampList.add(getEmptyKVLatestCellTimestamp(tableName));
+ // timestamps of all other columns
+ for (int i = 1; i < columns.size(); i++) {
+ byte[] cq = columns.get(i).getColumnQualifierBytes();
+ timestampList.add(getColumnLatestCellTimestamp(tableName, cq));
}
+ return timestampList;
+ }
+
+ private boolean isSetCorrectResultEnabledOnHBase() {
+ // true for HBase 2.4.18+, 2.5.9+, and 2.6.0+ versions, false otherwise
+ String hbaseVersion = VersionInfo.getVersion();
+ String[] versionArr = hbaseVersion.split("\\.");
+ int majorVersion = Integer.parseInt(versionArr[0]);
+ int minorVersion = Integer.parseInt(versionArr[1]);
+ int patchVersion = Integer.parseInt(versionArr[2].split("-hadoop")[0]);
Review Comment:
nit: could you also replace `-hadoop` with `-` (including the previous test
class i mentioned earlier)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]