@@ -988,6 +988,7 @@ VectorPtr importFromArrowImpl(
988988 memory::MemoryPool* pool,
989989 bool isViewer);
990990
991+ template <typename T>
991992VectorPtr createDecimalVector (
992993 memory::MemoryPool* pool,
993994 const TypePtr& type,
@@ -1003,14 +1004,13 @@ VectorPtr createDecimalVector(
10031004 VectorPtr base = BaseVector::create (type, arrowArray.length , pool);
10041005 base->setNulls (nulls);
10051006
1006- auto flatVector =
1007- std::dynamic_pointer_cast<FlatVector<UnscaledShortDecimal>>(base);
1007+ auto flatVector = std::dynamic_pointer_cast<FlatVector<T>>(base);
10081008
10091009 for (int i = 0 ; i < arrowArray.length ; i++) {
10101010 if (!base->isNullAt (i)) {
10111011 int128_t result;
10121012 memcpy (&result, src + i * sizeof (int128_t ), sizeof (int128_t ));
1013- flatVector->set (i, UnscaledShortDecimal ( static_cast < int64_t >( result) ));
1013+ flatVector->set (i, T ( result));
10141014 }
10151015 }
10161016
@@ -1226,30 +1226,27 @@ VectorPtr importFromArrowImpl(
12261226 static_cast <const char *>(arrowArray.buffers [2 ]), // values
12271227 arrowArray.null_count ,
12281228 wrapInBufferView);
1229- }
1230- // Row/structs.
1231- if (type->isRow ()) {
1229+ } else if (type->isRow ()) { // Row/structs.
12321230 return createRowVector (
12331231 pool,
12341232 std::dynamic_pointer_cast<const RowType>(type),
12351233 nulls,
12361234 arrowSchema,
12371235 arrowArray,
12381236 isViewer);
1239- }
1240- if (type->isArray ()) {
1237+ } else if (type->isArray ()) {
12411238 return createArrayVector (
12421239 pool, type, nulls, arrowSchema, arrowArray, isViewer, wrapInBufferView);
1243- }
1244- if (type->isMap ()) {
1240+ } else if (type->isMap ()) {
12451241 return createMapVector (
12461242 pool, type, nulls, arrowSchema, arrowArray, isViewer, wrapInBufferView);
1247- }
1248- if (type->isShortDecimal ()) {
1249- return createDecimalVector (
1243+ } else if (type->isShortDecimal ()) {
1244+ return createDecimalVector<UnscaledShortDecimal>(
12501245 pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
1251- }
1252- if (type->kind () == TypeKind::TIMESTAMP) {
1246+ } else if (type->isLongDecimal ()) {
1247+ return createDecimalVector<UnscaledLongDecimal>(
1248+ pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
1249+ } else if (type->kind () == TypeKind::TIMESTAMP) {
12531250 return createTimestampVector (
12541251 pool, type, nulls, arrowSchema, arrowArray, wrapInBufferView);
12551252 }
0 commit comments