HiveTableSchema schema = HiveTableSchemas.lookup(hiveServer.getClient(),
null, hiveTableDesc);
List<HiveWritableRecord> writeRecords = Lists.newArrayList();
HiveWritableRecord writeRecord = HiveRecordFactory.newWritableRecord(schema);
writeRecords.add(writeRecord);
HiveReadableRecord readRecord;
writeRecord.set(0, (byte) 4);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4, readRecord.getLong(0));
checkSetThrows(writeRecord, 0, (short) 4);
checkSetThrows(writeRecord, 0, 4);
checkSetThrows(writeRecord, 0, (long) 4);
checkSetThrows(writeRecord, 0, 4.2f);
checkSetThrows(writeRecord, 0, 4.2d);
recreateTable();
writeRecord.set(0, null);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertTrue(readRecord.isNull(0));
recreateTable();
writeRecord.set(1, (byte) 4);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4, readRecord.getLong(1));
recreateTable();
writeRecord.set(1, (short) 4);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4, readRecord.getLong(1));
checkSetThrows(writeRecord, 1, 4);
checkSetThrows(writeRecord, 1, (long) 4);
checkSetThrows(writeRecord, 1, 4.2f);
checkSetThrows(writeRecord, 1, 4.2d);
recreateTable();
writeRecord.set(1, null);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertTrue(readRecord.isNull(1));
recreateTable();
writeRecord.set((byte) 2, 4);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4, readRecord.getLong(2));
recreateTable();
writeRecord.set((short) 2, 4);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4, readRecord.getLong(2));
recreateTable();
writeRecord.set(2, 4);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4, readRecord.getLong(2));
checkSetThrows(writeRecord, 2, (long) 4);
checkSetThrows(writeRecord, 2, 4.2f);
checkSetThrows(writeRecord, 2, 4.2d);
recreateTable();
writeRecord.set(2, null);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertTrue(readRecord.isNull(2));
checkSetThrows(writeRecord, 3, 4.2f);
checkSetThrows(writeRecord, 3, 4.2d);
recreateTable();
writeRecord.set(4, 4.2f);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertEquals(4.2, readRecord.getDouble(4), DELTA);
checkSetThrows(writeRecord, 4, 4.2d);
recreateTable();
writeRecord.set(4, null);
HiveOutput.writeTable(outputDesc, writeRecords);
readRecord = readSingleRecord(inputDesc);
assertTrue(readRecord.isNull(4));
}