Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DataConverter {
- ...
- case Types.NUMERIC:
- if (mapNumerics) {
- int precision = metadata.getPrecision(col);
- if (precision < 19) {
- Schema schema;
- if (metadata.getScale(col) == 0) { // integer
- if (precision > 9) {
- schema = (optional) ? Schema.OPTIONAL_INT64_SCHEMA :
- Schema.INT64_SCHEMA;
- } else if (precision > 4) {
- schema = (optional) ? Schema.OPTIONAL_INT32_SCHEMA :
- Schema.INT32_SCHEMA;
- } else if (precision > 2) {
- schema = (optional) ? Schema.OPTIONAL_INT16_SCHEMA :
- Schema.INT16_SCHEMA;
- } else {
- schema = (optional) ? Schema.OPTIONAL_INT8_SCHEMA :
- Schema.INT8_SCHEMA;
- }
- } else { // double
- schema = (optional) ? Schema.OPTIONAL_FLOAT64_SCHEMA :
- Schema.FLOAT64_SCHEMA;
- }
- builder.field(fieldName, schema);
- break;
- }
- }
- ...
- case Types.NUMERIC:
- if (mapNumerics) {
- ResultSetMetaData metadata = resultSet.getMetaData();
- int precision = metadata.getPrecision(col);
- if (precision < 19) {
- if (metadata.getScale(col) == 0) { // integer
- if (precision > 9) {
- colValue = resultSet.getLong(col);
- } else if (precision > 4) {
- colValue = resultSet.getInt(col);
- } else if (precision > 2) {
- colValue = resultSet.getShort(col);
- } else {
- colValue = resultSet.getByte(col);
- }
- break;
- } else { // double
- colValue = resultSet.getDouble(col);
- break;
- }
- }
- }
- ...
- }
Add Comment
Please, Sign In to add comment