@Test public void testInt9ShouldBeLong() throws SQLException, IllegalArgumentException, IllegalAccessException { final ResultSetMetaData metadata = mock(ResultSetMetaData.class); when(metadata.getColumnCount()).thenReturn(1); when(metadata.getColumnType(1)).thenReturn(Types.INTEGER); when(metadata.getPrecision(1)).thenReturn(9); when(metadata.isSigned(1)).thenReturn(false); when(metadata.getColumnName(1)).thenReturn("Col1"); when(metadata.getTableName(1)).thenReturn("Table1"); final ResultSet rs = mock(ResultSet.class); when(rs.getMetaData()).thenReturn(metadata); Schema schema = JdbcCommon.createSchema(rs); Assert.assertNotNull(schema); Schema.Field field = schema.getField("Col1"); Schema fieldSchema = field.schema(); Assert.assertEquals(2, fieldSchema.getTypes().size()); boolean foundLongSchema = false; boolean foundNullSchema = false; for (Schema type : fieldSchema.getTypes()) { if (type.getType().equals(Schema.Type.LONG)) { foundLongSchema = true; } else if (type.getType().equals(Schema.Type.NULL)) { foundNullSchema = true; } } assertTrue(foundLongSchema); assertTrue(foundNullSchema); }
public static Schema createSchema(final ResultSet rs) throws SQLException { return createSchema(rs, null, false); }
JdbcCommon { public static Schema createSchema(final ResultSet rs) throws SQLException { return createSchema(rs, null, false); } }
JdbcCommon { public static Schema createSchema(final ResultSet rs) throws SQLException { return createSchema(rs, null, false); }  }
JdbcCommon { public static Schema createSchema(final ResultSet rs) throws SQLException { return createSchema(rs, null, false); }  static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, final int maxRows, boolean convertNames); static void createEmptyAvroStream(final OutputStream outStream); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, final AvroConversionOptions options, final ResultSetRowCallback callback); static Schema createSchema(final ResultSet rs); static Schema createSchema(final ResultSet rs, String recordName, boolean convertNames); static Schema createSchema(final ResultSet rs, AvroConversionOptions options); static String normalizeNameForAvro(String inputName); static void setParameters(final PreparedStatement stmt, final Map<String, String> attributes); static void setParameter(final PreparedStatement stmt, final String attrName, final int parameterIndex, final String parameterValue, final int jdbcType,
                              final String valueFormat); static DateTimeFormatter getDateTimeFormatter(String pattern); }
JdbcCommon { public static Schema createSchema(final ResultSet rs) throws SQLException { return createSchema(rs, null, false); }  static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, boolean convertNames); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, String recordName, ResultSetRowCallback callback, final int maxRows, boolean convertNames); static void createEmptyAvroStream(final OutputStream outStream); static long convertToAvroStream(final ResultSet rs, final OutputStream outStream, final AvroConversionOptions options, final ResultSetRowCallback callback); static Schema createSchema(final ResultSet rs); static Schema createSchema(final ResultSet rs, String recordName, boolean convertNames); static Schema createSchema(final ResultSet rs, AvroConversionOptions options); static String normalizeNameForAvro(String inputName); static void setParameters(final PreparedStatement stmt, final Map<String, String> attributes); static void setParameter(final PreparedStatement stmt, final String attrName, final int parameterIndex, final String parameterValue, final int jdbcType,
                              final String valueFormat); static DateTimeFormatter getDateTimeFormatter(String pattern); static final Pattern LONG_PATTERN; static final Pattern SQL_TYPE_ATTRIBUTE_PATTERN; static final Pattern NUMBER_PATTERN; static final String MIME_TYPE_AVRO_BINARY; static final PropertyDescriptor NORMALIZE_NAMES_FOR_AVRO; static final PropertyDescriptor USE_AVRO_LOGICAL_TYPES; static final PropertyDescriptor DEFAULT_PRECISION; static final PropertyDescriptor DEFAULT_SCALE; }