|
24 | 24 | import io.cdap.plugin.db.ColumnType; |
25 | 25 | import io.cdap.plugin.db.DBRecord; |
26 | 26 | import io.cdap.plugin.db.SchemaReader; |
27 | | -import org.slf4j.Logger; |
28 | | -import org.slf4j.LoggerFactory; |
29 | 27 |
|
30 | 28 | import java.io.IOException; |
31 | 29 | import java.io.InputStream; |
|
50 | 48 | */ |
51 | 49 | public class OracleSourceDBRecord extends DBRecord { |
52 | 50 |
|
53 | | - private static final Logger LOG = LoggerFactory.getLogger(OracleSourceDBRecord.class); |
54 | | - |
55 | 51 | public OracleSourceDBRecord(StructuredRecord record, List<ColumnType> columnTypes) { |
56 | 52 | this.record = record; |
57 | 53 | this.columnTypes = columnTypes; |
@@ -218,31 +214,16 @@ private void handleOracleSpecificType(ResultSet resultSet, StructuredRecord.Buil |
218 | 214 | if (Double.class.getTypeName().equals(resultSet.getMetaData().getColumnClassName(columnIndex))) { |
219 | 215 | recordBuilder.set(field.getName(), resultSet.getDouble(columnIndex)); |
220 | 216 | } else { |
221 | | - int scaleInSchema = getScale(field.getSchema()); |
222 | | - if (precision == 0 && scaleInSchema == 0) { |
223 | | - BigDecimal value = BigDecimal.valueOf(resultSet.getDouble(columnIndex)); |
224 | | - if (value != null && !containsIntegerValue(value)) { |
225 | | - LOG.warn(String.format("Precision loss detected in the field '%s'. " |
226 | | - + "Scale in the data='%s' scale present in the schema='%s'.", |
227 | | - field.getName(), |
228 | | - value.scale(), |
229 | | - scaleInSchema)); |
230 | | - } |
231 | | - } |
232 | 217 | // It's required to pass 'scale' parameter since in the case of Oracle, scale of 'BigDecimal' depends on the |
233 | 218 | // scale set in the logical schema. For example for value '77.12' if the scale set in the logical schema is |
234 | 219 | // set to 4 then the number will change to '77.1200'. Also if the value is '22.1274' and the logical schema |
235 | 220 | // scale is set to 2 then the decimal value used will be '22.13' after rounding. |
236 | | - BigDecimal decimal = resultSet.getBigDecimal(columnIndex, scaleInSchema); |
| 221 | + BigDecimal decimal = resultSet.getBigDecimal(columnIndex, getScale(field.getSchema())); |
237 | 222 | recordBuilder.setDecimal(field.getName(), decimal); |
238 | 223 | } |
239 | 224 | } |
240 | 225 | } |
241 | 226 |
|
242 | | - private boolean containsIntegerValue(BigDecimal value) { |
243 | | - return value.remainder(BigDecimal.ONE).compareTo(BigDecimal.ZERO) == 0; |
244 | | - } |
245 | | - |
246 | 227 | /** |
247 | 228 | * Get the scale set in Non-nullable schema associated with the schema |
248 | 229 | * */ |
|
0 commit comments