boolean isPrimaryKey(int col) {
    if (primaryKeys[col] == null) {
      try {
        // this doesn't always work, since some JDBC drivers (e.g.,
        // Oracle's) return a blank string from getDbTableName.
        String table = rsMeta.getTableName(col + 1);
        String column = rsMeta.getColumnName(col + 1);

        if (table == null || table.isEmpty() || column == null || column.isEmpty()) {
          primaryKeys[col] = Boolean.FALSE;
        } else {
          ResultSet pks = beeLine.getDatabaseConnection().getDatabaseMetaData().getPrimaryKeys(
              beeLine.getDatabaseConnection().getDatabaseMetaData().getConnection().getCatalog(), null, table);

          primaryKeys[col] = Boolean.FALSE;
          try {
            while (pks.next()) {
              if (column.equalsIgnoreCase(pks.getString("COLUMN_NAME"))) {
                primaryKeys[col] = Boolean.TRUE;
                break;
              }
            }
          } finally {
            pks.close();
          }
        }
      } catch (SQLException sqle) {
        primaryKeys[col] = Boolean.FALSE;
      }
    }
    return primaryKeys[col].booleanValue();
  }
Return whether the specified column (0-based index) is
a primary key. Since this method depends on whether the
JDBC driver property implements {@link ResultSetMetaData#getTableName} (many do not), it
is not reliable for all databases.
beeline/src/java/org/apache/hive/beeline/Rows.java