@Test(expected = IllegalArgumentException.class) public void testBuildPartialRowNullPrimaryKey() { buildPartialRow(null, "foo", (short) 10); }
@VisibleForTesting void buildPartialRow(Schema schema, PartialRow row, Record record, List<String> fieldNames) { for (String colName : fieldNames) { int colIdx = this.getColumnIndex(schema, colName); if (colIdx != -1) { ColumnSchema colSchema = schema.getColumnByIndex(colIdx); Type colType = colSchema.getType(); if (record.getValue(colName) == null) { row.setNull(colName); continue; } switch (colType.getDataType(colSchema.getTypeAttributes())) { case BOOL: row.addBoolean(colIdx, record.getAsBoolean(colName)); break; case FLOAT: row.addFloat(colIdx, record.getAsFloat(colName)); break; case DOUBLE: row.addDouble(colIdx, record.getAsDouble(colName)); break; case BINARY: row.addBinary(colIdx, record.getAsString(colName).getBytes()); break; case INT8: row.addByte(colIdx, record.getAsInt(colName).byteValue()); break; case INT16: row.addShort(colIdx, record.getAsInt(colName).shortValue()); break; case INT32: row.addInt(colIdx, record.getAsInt(colName)); break; case INT64: case UNIXTIME_MICROS: row.addLong(colIdx, record.getAsLong(colName)); break; case STRING: row.addString(colIdx, record.getAsString(colName)); break; case DECIMAL32: case DECIMAL64: case DECIMAL128: row.addDecimal(colIdx, new BigDecimal(record.getAsString(colName))); break; default: throw new IllegalStateException(String.format("unknown column type %s", colType)); } } } }
PutKudu extends AbstractKudu { @VisibleForTesting void buildPartialRow(Schema schema, PartialRow row, Record record, List<String> fieldNames) { for (String colName : fieldNames) { int colIdx = this.getColumnIndex(schema, colName); if (colIdx != -1) { ColumnSchema colSchema = schema.getColumnByIndex(colIdx); Type colType = colSchema.getType(); if (record.getValue(colName) == null) { row.setNull(colName); continue; } switch (colType.getDataType(colSchema.getTypeAttributes())) { case BOOL: row.addBoolean(colIdx, record.getAsBoolean(colName)); break; case FLOAT: row.addFloat(colIdx, record.getAsFloat(colName)); break; case DOUBLE: row.addDouble(colIdx, record.getAsDouble(colName)); break; case BINARY: row.addBinary(colIdx, record.getAsString(colName).getBytes()); break; case INT8: row.addByte(colIdx, record.getAsInt(colName).byteValue()); break; case INT16: row.addShort(colIdx, record.getAsInt(colName).shortValue()); break; case INT32: row.addInt(colIdx, record.getAsInt(colName)); break; case INT64: case UNIXTIME_MICROS: row.addLong(colIdx, record.getAsLong(colName)); break; case STRING: row.addString(colIdx, record.getAsString(colName)); break; case DECIMAL32: case DECIMAL64: case DECIMAL128: row.addDecimal(colIdx, new BigDecimal(record.getAsString(colName))); break; default: throw new IllegalStateException(String.format("unknown column type %s", colType)); } } } } }
PutKudu extends AbstractKudu { @VisibleForTesting void buildPartialRow(Schema schema, PartialRow row, Record record, List<String> fieldNames) { for (String colName : fieldNames) { int colIdx = this.getColumnIndex(schema, colName); if (colIdx != -1) { ColumnSchema colSchema = schema.getColumnByIndex(colIdx); Type colType = colSchema.getType(); if (record.getValue(colName) == null) { row.setNull(colName); continue; } switch (colType.getDataType(colSchema.getTypeAttributes())) { case BOOL: row.addBoolean(colIdx, record.getAsBoolean(colName)); break; case FLOAT: row.addFloat(colIdx, record.getAsFloat(colName)); break; case DOUBLE: row.addDouble(colIdx, record.getAsDouble(colName)); break; case BINARY: row.addBinary(colIdx, record.getAsString(colName).getBytes()); break; case INT8: row.addByte(colIdx, record.getAsInt(colName).byteValue()); break; case INT16: row.addShort(colIdx, record.getAsInt(colName).shortValue()); break; case INT32: row.addInt(colIdx, record.getAsInt(colName)); break; case INT64: case UNIXTIME_MICROS: row.addLong(colIdx, record.getAsLong(colName)); break; case STRING: row.addString(colIdx, record.getAsString(colName)); break; case DECIMAL32: case DECIMAL64: case DECIMAL128: row.addDecimal(colIdx, new BigDecimal(record.getAsString(colName))); break; default: throw new IllegalStateException(String.format("unknown column type %s", colType)); } } } }  }
PutKudu extends AbstractKudu { @VisibleForTesting void buildPartialRow(Schema schema, PartialRow row, Record record, List<String> fieldNames) { for (String colName : fieldNames) { int colIdx = this.getColumnIndex(schema, colName); if (colIdx != -1) { ColumnSchema colSchema = schema.getColumnByIndex(colIdx); Type colType = colSchema.getType(); if (record.getValue(colName) == null) { row.setNull(colName); continue; } switch (colType.getDataType(colSchema.getTypeAttributes())) { case BOOL: row.addBoolean(colIdx, record.getAsBoolean(colName)); break; case FLOAT: row.addFloat(colIdx, record.getAsFloat(colName)); break; case DOUBLE: row.addDouble(colIdx, record.getAsDouble(colName)); break; case BINARY: row.addBinary(colIdx, record.getAsString(colName).getBytes()); break; case INT8: row.addByte(colIdx, record.getAsInt(colName).byteValue()); break; case INT16: row.addShort(colIdx, record.getAsInt(colName).shortValue()); break; case INT32: row.addInt(colIdx, record.getAsInt(colName)); break; case INT64: case UNIXTIME_MICROS: row.addLong(colIdx, record.getAsLong(colName)); break; case STRING: row.addString(colIdx, record.getAsString(colName)); break; case DECIMAL32: case DECIMAL64: case DECIMAL128: row.addDecimal(colIdx, new BigDecimal(record.getAsString(colName))); break; default: throw new IllegalStateException(String.format("unknown column type %s", colType)); } } } }  @Override Set<Relationship> getRelationships(); }
PutKudu extends AbstractKudu { @VisibleForTesting void buildPartialRow(Schema schema, PartialRow row, Record record, List<String> fieldNames) { for (String colName : fieldNames) { int colIdx = this.getColumnIndex(schema, colName); if (colIdx != -1) { ColumnSchema colSchema = schema.getColumnByIndex(colIdx); Type colType = colSchema.getType(); if (record.getValue(colName) == null) { row.setNull(colName); continue; } switch (colType.getDataType(colSchema.getTypeAttributes())) { case BOOL: row.addBoolean(colIdx, record.getAsBoolean(colName)); break; case FLOAT: row.addFloat(colIdx, record.getAsFloat(colName)); break; case DOUBLE: row.addDouble(colIdx, record.getAsDouble(colName)); break; case BINARY: row.addBinary(colIdx, record.getAsString(colName).getBytes()); break; case INT8: row.addByte(colIdx, record.getAsInt(colName).byteValue()); break; case INT16: row.addShort(colIdx, record.getAsInt(colName).shortValue()); break; case INT32: row.addInt(colIdx, record.getAsInt(colName)); break; case INT64: case UNIXTIME_MICROS: row.addLong(colIdx, record.getAsLong(colName)); break; case STRING: row.addString(colIdx, record.getAsString(colName)); break; case DECIMAL32: case DECIMAL64: case DECIMAL128: row.addDecimal(colIdx, new BigDecimal(record.getAsString(colName))); break; default: throw new IllegalStateException(String.format("unknown column type %s", colType)); } } } }  @Override Set<Relationship> getRelationships();  }