3232import io .opentelemetry .api .trace .SpanContext ;
3333import io .opentelemetry .context .Context ;
3434import io .opentelemetry .context .Scope ;
35+ import java .io .ByteArrayInputStream ;
3536import java .io .InputStream ;
3637import java .io .Reader ;
3738import java .io .StringReader ;
3839import java .math .BigDecimal ;
40+ import java .nio .charset .Charset ;
3941import java .nio .charset .StandardCharsets ;
4042import java .sql .Array ;
4143import java .sql .Blob ;
5153import java .time .ZoneId ;
5254import java .util .Calendar ;
5355import java .util .List ;
56+ import javax .sql .rowset .serial .SerialBlob ;
57+ import javax .sql .rowset .serial .SerialClob ;
5458
5559public abstract class BigQueryBaseResultSet extends BigQueryNoOpsResultSet
5660 implements BigQueryResultSet {
@@ -341,7 +345,8 @@ public boolean getBoolean(int columnIndex) throws SQLException {
341345
342346 try {
343347 Object value = getObject (columnIndex );
344- return BigQueryTypeRegistry .convert (value , Boolean .class );
348+ Boolean result = BigQueryTypeRegistry .convert (value , Boolean .class );
349+ return result != null && result ;
345350 } catch (BigQueryJdbcException e ) {
346351 throw createCoercionException (columnIndex , Boolean .class , e );
347352 }
@@ -352,7 +357,8 @@ public byte getByte(int columnIndex) throws SQLException {
352357 LOG .finestTrace ("getByte" );
353358 try {
354359 Object value = getObject (columnIndex );
355- return BigQueryTypeRegistry .convert (value , Byte .class );
360+ Byte result = BigQueryTypeRegistry .convert (value , Byte .class );
361+ return result != null ? result : 0 ;
356362 } catch (BigQueryJdbcException e ) {
357363 throw createCoercionException (columnIndex , Byte .class , e );
358364 }
@@ -363,7 +369,8 @@ public short getShort(int columnIndex) throws SQLException {
363369 LOG .finestTrace ("getShort" );
364370 try {
365371 Object value = getObject (columnIndex );
366- return BigQueryTypeRegistry .convert (value , Short .class );
372+ Short result = BigQueryTypeRegistry .convert (value , Short .class );
373+ return result != null ? result : 0 ;
367374 } catch (BigQueryJdbcException e ) {
368375 throw createCoercionException (columnIndex , Short .class , e );
369376 }
@@ -374,7 +381,8 @@ public int getInt(int columnIndex) throws SQLException {
374381 LOG .finestTrace ("getInt" );
375382 try {
376383 Object value = getObject (columnIndex );
377- return BigQueryTypeRegistry .convert (value , Integer .class );
384+ Integer result = BigQueryTypeRegistry .convert (value , Integer .class );
385+ return result != null ? result : 0 ;
378386 } catch (BigQueryJdbcException e ) {
379387 throw createCoercionException (columnIndex , Integer .class , e );
380388 }
@@ -385,7 +393,8 @@ public long getLong(int columnIndex) throws SQLException {
385393 LOG .finestTrace ("getLong" );
386394 try {
387395 Object value = getObject (columnIndex );
388- return BigQueryTypeRegistry .convert (value , Long .class );
396+ Long result = BigQueryTypeRegistry .convert (value , Long .class );
397+ return result != null ? result : 0L ;
389398 } catch (BigQueryJdbcException e ) {
390399 throw createCoercionException (columnIndex , Long .class , e );
391400 }
@@ -396,7 +405,8 @@ public float getFloat(int columnIndex) throws SQLException {
396405 LOG .finestTrace ("getFloat" );
397406 try {
398407 Object value = getObject (columnIndex );
399- return BigQueryTypeRegistry .convert (value , Float .class );
408+ Float result = BigQueryTypeRegistry .convert (value , Float .class );
409+ return result != null ? result : 0.0f ;
400410 } catch (BigQueryJdbcException e ) {
401411 throw createCoercionException (columnIndex , Float .class , e );
402412 }
@@ -407,7 +417,8 @@ public double getDouble(int columnIndex) throws SQLException {
407417 LOG .finestTrace ("getDouble" );
408418 try {
409419 Object value = getObject (columnIndex );
410- return BigQueryTypeRegistry .convert (value , Double .class );
420+ Double result = BigQueryTypeRegistry .convert (value , Double .class );
421+ return result != null ? result : 0.0d ;
411422 } catch (BigQueryJdbcException e ) {
412423 throw createCoercionException (columnIndex , Double .class , e );
413424 }
@@ -442,9 +453,9 @@ public Date getDate(int columnIndex) throws SQLException {
442453 LOG .finestTrace ("getDate" );
443454 try {
444455 Object value = getObject (columnIndex );
445- return BigQueryTypeRegistry .convert (value , java . sql . Date .class );
456+ return BigQueryTypeRegistry .convert (value , Date .class );
446457 } catch (BigQueryJdbcException e ) {
447- throw createCoercionException (columnIndex , java . sql . Date .class , e );
458+ throw createCoercionException (columnIndex , Date .class , e );
448459 }
449460 }
450461
@@ -453,13 +464,13 @@ public Time getTime(int columnIndex) throws SQLException {
453464 LOG .finestTrace ("getTime" );
454465 StandardSQLTypeName type = getStandardSQLTypeName (columnIndex );
455466 if (type == StandardSQLTypeName .INT64 ) {
456- throw createCoercionException (columnIndex , java . sql . Time .class , null );
467+ throw createCoercionException (columnIndex , Time .class , null );
457468 }
458469 try {
459470 Object value = getObject (columnIndex );
460- return BigQueryTypeRegistry .convert (value , java . sql . Time .class );
471+ return BigQueryTypeRegistry .convert (value , Time .class );
461472 } catch (BigQueryJdbcException e ) {
462- throw createCoercionException (columnIndex , java . sql . Time .class , e );
473+ throw createCoercionException (columnIndex , Time .class , e );
463474 }
464475 }
465476
@@ -468,13 +479,13 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException {
468479 LOG .finestTrace ("getTimestamp" );
469480 StandardSQLTypeName type = getStandardSQLTypeName (columnIndex );
470481 if (type == StandardSQLTypeName .INT64 ) {
471- throw createCoercionException (columnIndex , java . sql . Timestamp .class , null );
482+ throw createCoercionException (columnIndex , Timestamp .class , null );
472483 }
473484 try {
474485 Object value = getObject (columnIndex );
475- return BigQueryTypeRegistry .convert (value , java . sql . Timestamp .class );
486+ return BigQueryTypeRegistry .convert (value , Timestamp .class );
476487 } catch (BigQueryJdbcException e ) {
477- throw createCoercionException (columnIndex , java . sql . Timestamp .class , e );
488+ throw createCoercionException (columnIndex , Timestamp .class , e );
478489 }
479490 }
480491
@@ -503,14 +514,14 @@ public Array getArray(int columnIndex) throws SQLException {
503514 public Blob getBlob (int columnIndex ) throws SQLException {
504515 LOG .finestTrace ("getBlob" );
505516 byte [] value = getBytes (columnIndex );
506- return new javax . sql . rowset . serial . SerialBlob (value );
517+ return value == null ? null : new SerialBlob (value );
507518 }
508519
509520 @ Override
510521 public Clob getClob (int columnIndex ) throws SQLException {
511522 LOG .finestTrace ("getClob" );
512523 String value = getString (columnIndex );
513- return new javax . sql . rowset . serial . SerialClob (value .toCharArray ());
524+ return value == null ? null : new SerialClob (value .toCharArray ());
514525 }
515526
516527 @ Override
@@ -520,12 +531,12 @@ public Reader getCharacterStream(int columnIndex) throws SQLException {
520531 return value == null ? null : new StringReader (value );
521532 }
522533
523- private InputStream getInputStream (String value , java . nio . charset . Charset charset ) {
534+ private InputStream getInputStream (String value , Charset charset ) {
524535 LOG .finestTrace ("getInputStream" );
525536 if (value == null ) {
526537 return null ;
527538 }
528- return new java . io . ByteArrayInputStream (value .getBytes (charset ));
539+ return new ByteArrayInputStream (value .getBytes (charset ));
529540 }
530541
531542 @ Override
@@ -546,7 +557,7 @@ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
546557 public InputStream getBinaryStream (int columnIndex ) throws SQLException {
547558 LOG .finestTrace ("getBinaryStream" );
548559 byte [] bytes = getBytes (columnIndex );
549- return bytes == null ? null : new java . io . ByteArrayInputStream (bytes );
560+ return bytes == null ? null : new ByteArrayInputStream (bytes );
550561 }
551562
552563 @ Override
0 commit comments