@@ -244,6 +244,10 @@ inline bool OGRArrowLayer::IsHandledListOrMapType(
244
244
itemTypeId == arrow::Type::HALF_FLOAT ||
245
245
itemTypeId == arrow::Type::FLOAT ||
246
246
itemTypeId == arrow::Type::DOUBLE ||
247
+ #if ARROW_VERSION_MAJOR >= 18
248
+ itemTypeId == arrow::Type::DECIMAL32 ||
249
+ itemTypeId == arrow::Type::DECIMAL64 ||
250
+ #endif
247
251
itemTypeId == arrow::Type::DECIMAL128 ||
248
252
itemTypeId == arrow::Type::DECIMAL256 ||
249
253
itemTypeId == arrow::Type::STRING ||
@@ -427,6 +431,10 @@ inline bool OGRArrowLayer::MapArrowTypeToOGR(
427
431
// nanosecond accuracy
428
432
break ;
429
433
434
+ #if ARROW_VERSION_MAJOR >= 18
435
+ case arrow::Type::DECIMAL32:
436
+ case arrow::Type::DECIMAL64:
437
+ #endif
430
438
case arrow::Type::DECIMAL128:
431
439
case arrow::Type::DECIMAL256:
432
440
{
@@ -473,6 +481,10 @@ inline bool OGRArrowLayer::MapArrowTypeToOGR(
473
481
eSubType = OFSTFloat32;
474
482
break ;
475
483
case arrow::Type::DOUBLE:
484
+ #if ARROW_VERSION_MAJOR >= 18
485
+ case arrow::Type::DECIMAL32:
486
+ case arrow::Type::DECIMAL64:
487
+ #endif
476
488
case arrow::Type::DECIMAL128:
477
489
case arrow::Type::DECIMAL256:
478
490
eType = OFTRealList;
@@ -1279,6 +1291,23 @@ static void AddToArray(CPLJSONArray &oArray, const arrow::Array *array,
1279
1291
static_cast <const arrow::DoubleArray *>(array)->Value (nIdx));
1280
1292
break ;
1281
1293
}
1294
+
1295
+ #if ARROW_VERSION_MAJOR >= 18
1296
+ case arrow::Type::DECIMAL32:
1297
+ {
1298
+ oArray.Add (CPLAtof (static_cast <const arrow::Decimal32Array *>(array)
1299
+ ->FormatValue (nIdx)
1300
+ .c_str ()));
1301
+ break ;
1302
+ }
1303
+ case arrow::Type::DECIMAL64:
1304
+ {
1305
+ oArray.Add (CPLAtof (static_cast <const arrow::Decimal64Array *>(array)
1306
+ ->FormatValue (nIdx)
1307
+ .c_str ()));
1308
+ break ;
1309
+ }
1310
+ #endif
1282
1311
case arrow::Type::DECIMAL128:
1283
1312
{
1284
1313
oArray.Add (
@@ -1449,6 +1478,25 @@ static void AddToDict(CPLJSONObject &oDict, const std::string &osKey,
1449
1478
static_cast <const arrow::DoubleArray *>(array)->Value (nIdx));
1450
1479
break ;
1451
1480
}
1481
+
1482
+ #if ARROW_VERSION_MAJOR >= 18
1483
+ case arrow::Type::DECIMAL32:
1484
+ {
1485
+ oDict.Add (osKey,
1486
+ CPLAtof (static_cast <const arrow::Decimal32Array *>(array)
1487
+ ->FormatValue (nIdx)
1488
+ .c_str ()));
1489
+ break ;
1490
+ }
1491
+ case arrow::Type::DECIMAL64:
1492
+ {
1493
+ oDict.Add (osKey,
1494
+ CPLAtof (static_cast <const arrow::Decimal64Array *>(array)
1495
+ ->FormatValue (nIdx)
1496
+ .c_str ()));
1497
+ break ;
1498
+ }
1499
+ #endif
1452
1500
case arrow::Type::DECIMAL128:
1453
1501
{
1454
1502
oDict.Add (osKey,
@@ -1710,6 +1758,48 @@ static void ReadList(OGRFeature *poFeature, int i, int64_t nIdxInArray,
1710
1758
break ;
1711
1759
}
1712
1760
1761
+ #if ARROW_VERSION_MAJOR >= 18
1762
+ case arrow::Type::DECIMAL32:
1763
+ {
1764
+ const auto values = std::static_pointer_cast<arrow::Decimal32Array>(
1765
+ array->values ());
1766
+ const auto nIdxStart = array->value_offset (nIdxInArray);
1767
+ const int nCount = array->value_length (nIdxInArray);
1768
+ std::vector<double > aValues;
1769
+ aValues.reserve (nCount);
1770
+ for (int k = 0 ; k < nCount; k++)
1771
+ {
1772
+ if (values->IsNull (nIdxStart + k))
1773
+ aValues.push_back (std::numeric_limits<double >::quiet_NaN ());
1774
+ else
1775
+ aValues.push_back (
1776
+ CPLAtof (values->FormatValue (nIdxStart + k).c_str ()));
1777
+ }
1778
+ poFeature->SetField (i, nCount, aValues.data ());
1779
+ break ;
1780
+ }
1781
+
1782
+ case arrow::Type::DECIMAL64:
1783
+ {
1784
+ const auto values = std::static_pointer_cast<arrow::Decimal64Array>(
1785
+ array->values ());
1786
+ const auto nIdxStart = array->value_offset (nIdxInArray);
1787
+ const int nCount = array->value_length (nIdxInArray);
1788
+ std::vector<double > aValues;
1789
+ aValues.reserve (nCount);
1790
+ for (int k = 0 ; k < nCount; k++)
1791
+ {
1792
+ if (values->IsNull (nIdxStart + k))
1793
+ aValues.push_back (std::numeric_limits<double >::quiet_NaN ());
1794
+ else
1795
+ aValues.push_back (
1796
+ CPLAtof (values->FormatValue (nIdxStart + k).c_str ()));
1797
+ }
1798
+ poFeature->SetField (i, nCount, aValues.data ());
1799
+ break ;
1800
+ }
1801
+ #endif
1802
+
1713
1803
case arrow::Type::DECIMAL128:
1714
1804
{
1715
1805
const auto values =
@@ -2313,6 +2403,26 @@ inline OGRFeature *OGRArrowLayer::ReadFeature(
2313
2403
break ;
2314
2404
}
2315
2405
2406
+ #if ARROW_VERSION_MAJOR >= 18
2407
+ case arrow::Type::DECIMAL32:
2408
+ {
2409
+ const auto castArray =
2410
+ static_cast <const arrow::Decimal32Array *>(array);
2411
+ poFeature->SetField (
2412
+ i, CPLAtof (castArray->FormatValue (nIdxInBatch).c_str ()));
2413
+ break ;
2414
+ }
2415
+
2416
+ case arrow::Type::DECIMAL64:
2417
+ {
2418
+ const auto castArray =
2419
+ static_cast <const arrow::Decimal64Array *>(array);
2420
+ poFeature->SetField (
2421
+ i, CPLAtof (castArray->FormatValue (nIdxInBatch).c_str ()));
2422
+ break ;
2423
+ }
2424
+ #endif
2425
+
2316
2426
case arrow::Type::DECIMAL128:
2317
2427
{
2318
2428
const auto castArray =
@@ -3803,6 +3913,34 @@ inline bool OGRArrowLayer::SkipToNextFeatureDueToAttributeFilter() const
3803
3913
break ;
3804
3914
}
3805
3915
3916
+ #if ARROW_VERSION_MAJOR >= 18
3917
+ case arrow::Type::DECIMAL32:
3918
+ {
3919
+ const auto castArray =
3920
+ static_cast <const arrow::Decimal32Array *>(array);
3921
+ if (!ConstraintEvaluator (
3922
+ constraint,
3923
+ CPLAtof (castArray->FormatValue (m_nIdxInBatch).c_str ())))
3924
+ {
3925
+ return true ;
3926
+ }
3927
+ break ;
3928
+ }
3929
+
3930
+ case arrow::Type::DECIMAL64:
3931
+ {
3932
+ const auto castArray =
3933
+ static_cast <const arrow::Decimal64Array *>(array);
3934
+ if (!ConstraintEvaluator (
3935
+ constraint,
3936
+ CPLAtof (castArray->FormatValue (m_nIdxInBatch).c_str ())))
3937
+ {
3938
+ return true ;
3939
+ }
3940
+ break ;
3941
+ }
3942
+ #endif
3943
+
3806
3944
case arrow::Type::DECIMAL128:
3807
3945
{
3808
3946
const auto castArray =
0 commit comments