The following will cause a class cast exception (can't cast double to integer)
var ds = sparkSession.createDataset([1,2,3], Encoders.INT());
ds =ds.map( function(value) {
return value + 1;
}, Encoders.INT());
This is because the return value from js defaults to double. The lambda function should be aware of the encoder type, and do the appropriate conversion.