Skip to content

Commit

Permalink
SNOW-1865097 use explicit casts to compare doubles against integer li…
Browse files Browse the repository at this point in the history
…mits (#802)
  • Loading branch information
sfc-gh-mmishchenko authored Dec 20, 2024
1 parent 65ef675 commit 3f9afd7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cpp/lib/ArrowChunkIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ ArrowChunkIterator::getCellAsInt64(size_t colIdx, int64 * out_data, bool rawData
return status;
}

if ((floatData > SF_INT64_MAX) || (floatData < SF_INT64_MIN))
if (floatData > static_cast<float64>(SF_INT64_MAX) || floatData < static_cast<float64>(SF_INT64_MIN))
{
m_parent->setError(SF_STATUS_ERROR_OUT_OF_RANGE,
"Value out of range for int64.");
Expand Down Expand Up @@ -408,7 +408,7 @@ ArrowChunkIterator::getCellAsInt64(size_t colIdx, int64 * out_data, bool rawData
case arrow::Type::type::DOUBLE:
{
double dblData = m_columns[colIdx].arrowDouble->Value(m_currRowIndexInBatch);
if ((dblData > SF_INT64_MAX) || (dblData < SF_INT64_MIN))
if (dblData > static_cast<float64>(SF_INT64_MAX) || dblData < static_cast<float64>(SF_INT64_MIN))
{
m_parent->setError(SF_STATUS_ERROR_OUT_OF_RANGE,
"Value out of range for int64.");
Expand Down Expand Up @@ -542,7 +542,7 @@ ArrowChunkIterator::getCellAsUint64(size_t colIdx, uint64 * out_data)
case arrow::Type::type::DOUBLE:
{
double dblData = m_columns[colIdx].arrowDouble->Value(m_currRowIndexInBatch);
if ((dblData > SF_UINT64_MAX) || (dblData < SF_INT64_MIN))
if (dblData > static_cast<double>(SF_UINT64_MAX) || dblData < static_cast<double>(SF_INT64_MIN))
{
m_parent->setError(SF_STATUS_ERROR_OUT_OF_RANGE,
"Value out of range for uint64.");
Expand Down

0 comments on commit 3f9afd7

Please sign in to comment.