From 8f4514d4dec66d0439578e14b25174fc6469bfbc Mon Sep 17 00:00:00 2001 From: Jelena Furundzic Date: Thu, 14 Mar 2024 14:49:30 -0700 Subject: [PATCH] Fix null pointer issue --- .../client/core/arrow/AbstractArrowVectorConverter.java | 6 +++--- .../snowflake/client/core/arrow/BigIntToFixedConverter.java | 2 +- .../snowflake/client/core/arrow/IntToFixedConverter.java | 2 +- .../client/core/arrow/SmallIntToFixedConverter.java | 2 +- .../client/core/arrow/TinyIntToFixedConverter.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/arrow/AbstractArrowVectorConverter.java b/src/main/java/net/snowflake/client/core/arrow/AbstractArrowVectorConverter.java index e5eed31ff..5de7876b2 100644 --- a/src/main/java/net/snowflake/client/core/arrow/AbstractArrowVectorConverter.java +++ b/src/main/java/net/snowflake/client/core/arrow/AbstractArrowVectorConverter.java @@ -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; @@ -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; diff --git a/src/main/java/net/snowflake/client/core/arrow/BigIntToFixedConverter.java b/src/main/java/net/snowflake/client/core/arrow/BigIntToFixedConverter.java index 513e93552..c38ef2d68 100644 --- a/src/main/java/net/snowflake/client/core/arrow/BigIntToFixedConverter.java +++ b/src/main/java/net/snowflake/client/core/arrow/BigIntToFixedConverter.java @@ -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); diff --git a/src/main/java/net/snowflake/client/core/arrow/IntToFixedConverter.java b/src/main/java/net/snowflake/client/core/arrow/IntToFixedConverter.java index 84b3845b1..b7464eb6a 100644 --- a/src/main/java/net/snowflake/client/core/arrow/IntToFixedConverter.java +++ b/src/main/java/net/snowflake/client/core/arrow/IntToFixedConverter.java @@ -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); diff --git a/src/main/java/net/snowflake/client/core/arrow/SmallIntToFixedConverter.java b/src/main/java/net/snowflake/client/core/arrow/SmallIntToFixedConverter.java index 5ccdba3b0..25122c81d 100644 --- a/src/main/java/net/snowflake/client/core/arrow/SmallIntToFixedConverter.java +++ b/src/main/java/net/snowflake/client/core/arrow/SmallIntToFixedConverter.java @@ -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); diff --git a/src/main/java/net/snowflake/client/core/arrow/TinyIntToFixedConverter.java b/src/main/java/net/snowflake/client/core/arrow/TinyIntToFixedConverter.java index 4103835e9..46b2cdea8 100644 --- a/src/main/java/net/snowflake/client/core/arrow/TinyIntToFixedConverter.java +++ b/src/main/java/net/snowflake/client/core/arrow/TinyIntToFixedConverter.java @@ -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);