Skip to content

Commit

Permalink
Fix null pointer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jf committed Mar 14, 2024
1 parent f6ac9a5 commit 8f4514d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.sql.Timestamp;
import java.util.TimeZone;
import net.snowflake.client.core.DataConversionContext;
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.client.core.SFException;
import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.client.jdbc.SnowflakeUtil;
Expand Down Expand Up @@ -146,9 +147,8 @@ public BigDecimal toBigDecimal(int index) throws SFException {
ErrorCode.INVALID_VALUE_CONVERT, logicalTypeStr, SnowflakeUtil.BIG_DECIMAL_STR, "");
}

public boolean shouldTreatDecimalAsInt(DataConversionContext context) {
if (!context.getSession().isJdbcArrowTreatDecimalAsInt()
&& !context.getSession().isJdbcTreatDecimalAsInt()) {
public boolean shouldTreatDecimalAsInt(SFBaseSession session) {
if (!session.isJdbcArrowTreatDecimalAsInt() && !session.isJdbcTreatDecimalAsInt()) {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public BigDecimal toBigDecimal(int index) {
public Object toObject(int index) throws SFException {
if (bigIntVector.isNull(index)) {
return null;
} else if (!shouldTreatDecimalAsInt(context)) {
} else if (!shouldTreatDecimalAsInt(context.getSession())) {
return BigDecimal.valueOf(getLong(index), sfScale);
}
return getLong(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public BigDecimal toBigDecimal(int index) throws SFException {
public Object toObject(int index) throws SFException {
if (isNull(index)) {
return null;
} else if (!shouldTreatDecimalAsInt(context)) {
} else if (!shouldTreatDecimalAsInt(context.getSession())) {
return BigDecimal.valueOf((long) getInt(index), sfScale);
}
return (long) getInt(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public double toDouble(int index) throws SFException {
public Object toObject(int index) throws SFException {
if (isNull(index)) {
return null;
} else if (!shouldTreatDecimalAsInt(context)) {
} else if (!shouldTreatDecimalAsInt(context.getSession())) {
return BigDecimal.valueOf((long) getShort(index), sfScale);
}
return (long) getShort(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public BigDecimal toBigDecimal(int index) throws SFException {
public Object toObject(int index) throws SFException {
if (isNull(index)) {
return null;
} else if (!shouldTreatDecimalAsInt(context)) {
} else if (!shouldTreatDecimalAsInt(context.getSession())) {
return BigDecimal.valueOf((long) getByte(index), sfScale);
}
return (long) toByte(index);
Expand Down

0 comments on commit 8f4514d

Please sign in to comment.