Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.sql.Struct;
import java.sql.Time;
Expand Down Expand Up @@ -182,17 +183,17 @@ public Struct getStruct() {
}

@Override
public Date getDate(final Calendar calendar) {
public Date getDate(final Calendar calendar) throws SQLException {
throw getOperationNotSupported(this.getClass());
}

@Override
public Time getTime(final Calendar calendar) {
public Time getTime(final Calendar calendar) throws SQLException {
throw getOperationNotSupported(this.getClass());
}

@Override
public Timestamp getTimestamp(final Calendar calendar) {
public Timestamp getTimestamp(final Calendar calendar) throws SQLException {
throw getOperationNotSupported(this.getClass());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.sql.Struct;
import java.sql.Time;
Expand Down Expand Up @@ -57,8 +58,7 @@ public abstract class AbstractArrowFlightJdbcUnionVectorAccessor extends ArrowFl
new ArrowFlightJdbcNullVectorAccessor((boolean wasNull) -> {
});

protected AbstractArrowFlightJdbcUnionVectorAccessor(
IntSupplier currentRowSupplier,
protected AbstractArrowFlightJdbcUnionVectorAccessor(IntSupplier currentRowSupplier,
ArrowFlightJdbcAccessorFactory.WasNullConsumer setCursorWasNull) {
super(currentRowSupplier, setCursorWasNull);
}
Expand Down Expand Up @@ -213,17 +213,17 @@ public Struct getStruct() {
}

@Override
public Date getDate(Calendar calendar) {
public Date getDate(Calendar calendar) throws SQLException {
return getAccessor().getDate(calendar);
}

@Override
public Time getTime(Calendar calendar) {
public Time getTime(Calendar calendar) throws SQLException {
return getAccessor().getTime(calendar);
}

@Override
public Timestamp getTimestamp(Calendar calendar) {
public Timestamp getTimestamp(Calendar calendar) throws SQLException {
return getAccessor().getTimestamp(calendar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.Reader;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
Expand Down Expand Up @@ -156,38 +157,50 @@ public Reader getCharacterStream() {
}

@Override
public Date getDate(Calendar calendar) {
Date date = Date.valueOf(getString());
if (calendar == null) {
return date;
}
public Date getDate(Calendar calendar) throws SQLException {
try {
Date date = Date.valueOf(getString());
if (calendar == null) {
return date;
}

// Use Calendar to apply time zone's offset
long milliseconds = date.getTime();
return new Date(DateTimeUtils.applyCalendarOffset(milliseconds, calendar));
// Use Calendar to apply time zone's offset
long milliseconds = date.getTime();
return new Date(DateTimeUtils.applyCalendarOffset(milliseconds, calendar));
} catch (Exception e) {
throw new SQLException(e);
}
}

@Override
public Time getTime(Calendar calendar) {
Time time = Time.valueOf(getString());
if (calendar == null) {
return time;
}
public Time getTime(Calendar calendar) throws SQLException {
try {
Time time = Time.valueOf(getString());
if (calendar == null) {
return time;
}

// Use Calendar to apply time zone's offset
long milliseconds = time.getTime();
return new Time(DateTimeUtils.applyCalendarOffset(milliseconds, calendar));
// Use Calendar to apply time zone's offset
long milliseconds = time.getTime();
return new Time(DateTimeUtils.applyCalendarOffset(milliseconds, calendar));
} catch (Exception e) {
throw new SQLException(e);
}
}

@Override
public Timestamp getTimestamp(Calendar calendar) {
Timestamp timestamp = Timestamp.valueOf(getString());
if (calendar == null) {
return timestamp;
}
public Timestamp getTimestamp(Calendar calendar) throws SQLException {
try {
Timestamp timestamp = Timestamp.valueOf(getString());
if (calendar == null) {
return timestamp;
}

// Use Calendar to apply time zone's offset
long milliseconds = timestamp.getTime();
return new Timestamp(DateTimeUtils.applyCalendarOffset(milliseconds, calendar));
// Use Calendar to apply time zone's offset
long milliseconds = timestamp.getTime();
return new Timestamp(DateTimeUtils.applyCalendarOffset(milliseconds, calendar));
} catch (Exception e) {
throw new SQLException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -332,19 +333,19 @@ public void testShouldFailToGetNCharacterStream() {
}

@Test(expected = UnsupportedOperationException.class)
public void testShouldFailToGetDate() {
public void testShouldFailToGetDate() throws SQLException {
when(accessor.getDate(null)).thenCallRealMethod();
accessor.getDate(null);
}

@Test(expected = UnsupportedOperationException.class)
public void testShouldFailToGetTime() {
public void testShouldFailToGetTime() throws SQLException {
when(accessor.getTime(null)).thenCallRealMethod();
accessor.getTime(null);
}

@Test(expected = UnsupportedOperationException.class)
public void testShouldFailToGetTimestamp() {
public void testShouldFailToGetTimestamp() throws SQLException {
when(accessor.getTimestamp(null)).thenCallRealMethod();
accessor.getTimestamp(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.sql.SQLException;
import java.util.Calendar;
import java.util.Map;

Expand Down Expand Up @@ -230,21 +231,21 @@ public void testGetObjectWithClassUsesSpecificAccessor() {
}

@Test
public void testGetTimestampUsesSpecificAccessor() {
public void testGetTimestampUsesSpecificAccessor() throws SQLException {
Calendar calendar = Calendar.getInstance();
accessor.getTimestamp(calendar);
verify(innerAccessor).getTimestamp(calendar);
}

@Test
public void testGetTimeUsesSpecificAccessor() {
public void testGetTimeUsesSpecificAccessor() throws SQLException {
Calendar calendar = Calendar.getInstance();
accessor.getTime(calendar);
verify(innerAccessor).getTime(calendar);
}

@Test
public void testGetDateUsesSpecificAccessor() {
public void testGetDateUsesSpecificAccessor() throws SQLException {
Calendar calendar = Calendar.getInstance();
accessor.getDate(calendar);
verify(innerAccessor).getDate(calendar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public void testShouldGetDateThrowsExceptionForNonDateValue() throws Exception {
Text value = new Text("Invalid value for date.");
when(getter.get(0)).thenReturn(value);

thrown.expect(IllegalArgumentException.class);
thrown.expect(SQLException.class);
accessor.getDate(null);
}

Expand Down Expand Up @@ -513,7 +513,7 @@ public void testShouldGetTimeThrowsExceptionForNonTimeValue() throws Exception {
Text value = new Text("Invalid value for time.");
when(getter.get(0)).thenReturn(value);

thrown.expect(IllegalArgumentException.class);
thrown.expect(SQLException.class);
accessor.getTime(null);
}

Expand Down Expand Up @@ -549,7 +549,7 @@ public void testShouldGetTimestampThrowsExceptionForNonTimeValue() throws Except
Text value = new Text("Invalid value for timestamp.");
when(getter.get(0)).thenReturn(value);

thrown.expect(IllegalArgumentException.class);
thrown.expect(SQLException.class);
accessor.getTimestamp(null);
}

Expand Down