hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Oliver (JIRA)" <>
Subject [jira] [Created] (HIVE-7134) Implement ResultSet.getBytes()
Date Wed, 28 May 2014 14:58:01 GMT
Bill Oliver created HIVE-7134:

             Summary: Implement ResultSet.getBytes()
                 Key: HIVE-7134
             Project: Hive
          Issue Type: Improvement
            Reporter: Bill Oliver

I'd like to see an implementation of ResultSet.getBytes().

Here is my (untested) implementation. This could certainly be improved upon.

	public byte[] getBytes(int columnIndex) throws SQLException {
		Object value = getColumnValue(columnIndex);
		if (wasNull) {
			return null;
		if (value instanceof byte[]) {
			return (byte[]) value;

		try {
			// this implementation will work on any Object that implements
			// includes Number, Date, Timestamp, or String
			ByteArrayOutputStream b = new ByteArrayOutputStream();
			ObjectOutputStream o = new ObjectOutputStream(b);
			return b.toByteArray();
		} catch (IOException e) {
			throw new SQLException(e);

  public byte[] getBytes(String columnName) throws SQLException {
    return getBytes(findColumn(columnName));

This message was sent by Atlassian JIRA

View raw message