@@ -228,6 +228,10 @@ inline bool OGRArrowLayer::IsHandledListOrMapType(
228
228
itemTypeId == arrow::Type::HALF_FLOAT ||
229
229
itemTypeId == arrow::Type::FLOAT ||
230
230
itemTypeId == arrow::Type::DOUBLE ||
231
+ #if ARROW_VERSION_MAJOR >= 18
232
+ itemTypeId == arrow::Type::DECIMAL32 ||
233
+ itemTypeId == arrow::Type::DECIMAL64 ||
234
+ #endif
231
235
itemTypeId == arrow::Type::DECIMAL128 ||
232
236
itemTypeId == arrow::Type::DECIMAL256 ||
233
237
itemTypeId == arrow::Type::STRING ||
@@ -422,6 +426,10 @@ inline bool OGRArrowLayer::MapArrowTypeToOGR(
422
426
// nanosecond accuracy
423
427
break ;
424
428
429
+ #if ARROW_VERSION_MAJOR >= 18
430
+ case arrow::Type::DECIMAL32:
431
+ case arrow::Type::DECIMAL64:
432
+ #endif
425
433
case arrow::Type::DECIMAL128:
426
434
case arrow::Type::DECIMAL256:
427
435
{
@@ -468,6 +476,10 @@ inline bool OGRArrowLayer::MapArrowTypeToOGR(
468
476
eSubType = OFSTFloat32;
469
477
break ;
470
478
case arrow::Type::DOUBLE:
479
+ #if ARROW_VERSION_MAJOR >= 18
480
+ case arrow::Type::DECIMAL32:
481
+ case arrow::Type::DECIMAL64:
482
+ #endif
471
483
case arrow::Type::DECIMAL128:
472
484
case arrow::Type::DECIMAL256:
473
485
eType = OFTRealList;
@@ -1290,6 +1302,23 @@ static void AddToArray(CPLJSONArray &oArray, const arrow::Array *array,
1290
1302
static_cast <const arrow::DoubleArray *>(array)->Value (nIdx));
1291
1303
break ;
1292
1304
}
1305
+
1306
+ #if ARROW_VERSION_MAJOR >= 18
1307
+ case arrow::Type::DECIMAL32:
1308
+ {
1309
+ oArray.Add (CPLAtof (static_cast <const arrow::Decimal32Array *>(array)
1310
+ ->FormatValue (nIdx)
1311
+ .c_str ()));
1312
+ break ;
1313
+ }
1314
+ case arrow::Type::DECIMAL64:
1315
+ {
1316
+ oArray.Add (CPLAtof (static_cast <const arrow::Decimal64Array *>(array)
1317
+ ->FormatValue (nIdx)
1318
+ .c_str ()));
1319
+ break ;
1320
+ }
1321
+ #endif
1293
1322
case arrow::Type::DECIMAL128:
1294
1323
{
1295
1324
oArray.Add (
@@ -1470,6 +1499,25 @@ static void AddToDict(CPLJSONObject &oDict, const std::string &osKey,
1470
1499
static_cast <const arrow::DoubleArray *>(array)->Value (nIdx));
1471
1500
break ;
1472
1501
}
1502
+
1503
+ #if ARROW_VERSION_MAJOR >= 18
1504
+ case arrow::Type::DECIMAL32:
1505
+ {
1506
+ oDict.Add (osKey,
1507
+ CPLAtof (static_cast <const arrow::Decimal32Array *>(array)
1508
+ ->FormatValue (nIdx)
1509
+ .c_str ()));
1510
+ break ;
1511
+ }
1512
+ case arrow::Type::DECIMAL64:
1513
+ {
1514
+ oDict.Add (osKey,
1515
+ CPLAtof (static_cast <const arrow::Decimal64Array *>(array)
1516
+ ->FormatValue (nIdx)
1517
+ .c_str ()));
1518
+ break ;
1519
+ }
1520
+ #endif
1473
1521
case arrow::Type::DECIMAL128:
1474
1522
{
1475
1523
oDict.Add (osKey,
@@ -1757,6 +1805,48 @@ static void ReadList(OGRFeature *poFeature, int i, int64_t nIdxInArray,
1757
1805
break ;
1758
1806
}
1759
1807
1808
+ #if ARROW_VERSION_MAJOR >= 18
1809
+ case arrow::Type::DECIMAL32:
1810
+ {
1811
+ const auto values = std::static_pointer_cast<arrow::Decimal32Array>(
1812
+ array->values ());
1813
+ const auto nIdxStart = array->value_offset (nIdxInArray);
1814
+ const int nCount = array->value_length (nIdxInArray);
1815
+ std::vector<double > aValues;
1816
+ aValues.reserve (nCount);
1817
+ for (int k = 0 ; k < nCount; k++)
1818
+ {
1819
+ if (values->IsNull (nIdxStart + k))
1820
+ aValues.push_back (std::numeric_limits<double >::quiet_NaN ());
1821
+ else
1822
+ aValues.push_back (
1823
+ CPLAtof (values->FormatValue (nIdxStart + k).c_str ()));
1824
+ }
1825
+ poFeature->SetField (i, nCount, aValues.data ());
1826
+ break ;
1827
+ }
1828
+
1829
+ case arrow::Type::DECIMAL64:
1830
+ {
1831
+ const auto values = std::static_pointer_cast<arrow::Decimal64Array>(
1832
+ array->values ());
1833
+ const auto nIdxStart = array->value_offset (nIdxInArray);
1834
+ const int nCount = array->value_length (nIdxInArray);
1835
+ std::vector<double > aValues;
1836
+ aValues.reserve (nCount);
1837
+ for (int k = 0 ; k < nCount; k++)
1838
+ {
1839
+ if (values->IsNull (nIdxStart + k))
1840
+ aValues.push_back (std::numeric_limits<double >::quiet_NaN ());
1841
+ else
1842
+ aValues.push_back (
1843
+ CPLAtof (values->FormatValue (nIdxStart + k).c_str ()));
1844
+ }
1845
+ poFeature->SetField (i, nCount, aValues.data ());
1846
+ break ;
1847
+ }
1848
+ #endif
1849
+
1760
1850
case arrow::Type::DECIMAL128:
1761
1851
{
1762
1852
const auto values =
@@ -2406,6 +2496,26 @@ inline OGRFeature *OGRArrowLayer::ReadFeature(
2406
2496
break ;
2407
2497
}
2408
2498
2499
+ #if ARROW_VERSION_MAJOR >= 18
2500
+ case arrow::Type::DECIMAL32:
2501
+ {
2502
+ const auto castArray =
2503
+ static_cast <const arrow::Decimal32Array *>(array);
2504
+ poFeature->SetField (
2505
+ i, CPLAtof (castArray->FormatValue (nIdxInBatch).c_str ()));
2506
+ break ;
2507
+ }
2508
+
2509
+ case arrow::Type::DECIMAL64:
2510
+ {
2511
+ const auto castArray =
2512
+ static_cast <const arrow::Decimal64Array *>(array);
2513
+ poFeature->SetField (
2514
+ i, CPLAtof (castArray->FormatValue (nIdxInBatch).c_str ()));
2515
+ break ;
2516
+ }
2517
+ #endif
2518
+
2409
2519
case arrow::Type::DECIMAL128:
2410
2520
{
2411
2521
const auto castArray =
@@ -3900,6 +4010,34 @@ inline bool OGRArrowLayer::SkipToNextFeatureDueToAttributeFilter() const
3900
4010
break ;
3901
4011
}
3902
4012
4013
+ #if ARROW_VERSION_MAJOR >= 18
4014
+ case arrow::Type::DECIMAL32:
4015
+ {
4016
+ const auto castArray =
4017
+ static_cast <const arrow::Decimal32Array *>(array);
4018
+ if (!ConstraintEvaluator (
4019
+ constraint,
4020
+ CPLAtof (castArray->FormatValue (m_nIdxInBatch).c_str ())))
4021
+ {
4022
+ return true ;
4023
+ }
4024
+ break ;
4025
+ }
4026
+
4027
+ case arrow::Type::DECIMAL64:
4028
+ {
4029
+ const auto castArray =
4030
+ static_cast <const arrow::Decimal64Array *>(array);
4031
+ if (!ConstraintEvaluator (
4032
+ constraint,
4033
+ CPLAtof (castArray->FormatValue (m_nIdxInBatch).c_str ())))
4034
+ {
4035
+ return true ;
4036
+ }
4037
+ break ;
4038
+ }
4039
+ #endif
4040
+
3903
4041
case arrow::Type::DECIMAL128:
3904
4042
{
3905
4043
const auto castArray =
0 commit comments