Skip to content

Commit 4e134e5

Browse files
committed
ARROW-1091: Decimal scale and precision are flipped
Author: Julien Le Dem <julien@apache.org> Closes apache#735 from julienledem/template_cleanup_followup and squashes the following commits: e968a68 [Julien Le Dem] add test 2911ea2 [Julien Le Dem] ARROW-1091: Decimal scale and precision are flipped
1 parent 316930c commit 4e134e5

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎java/vector/src/main/codegen/data/ValueVectorTypes.tdd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
{
117117
class: "Decimal",
118118
maxPrecisionDigits: 38, nDecimalDigits: 4, friendlyType: "BigDecimal",
119-
typeParams: [ {name: "scale", type: "int"}, { name: "precision", type: "int"}],
119+
typeParams: [ {name: "precision", type: "int"}, { name: "scale", type: "int"}],
120120
arrowType: "org.apache.arrow.vector.types.pojo.ArrowType.Decimal",
121121
fields: [{name: "start", type: "int"}, {name: "buffer", type: "ArrowBuf"}]
122122
}

‎java/vector/src/main/codegen/templates/NullableValueVectors.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ public void setSkipNull(int index, Nullable${minor.class}Holder holder){
593593
values.getMutator().set(index, holder);
594594
}
595595

596-
597596
public void set(int index, Nullable${minor.class}Holder holder){
598597
final ${valuesName}.Mutator valuesMutator = values.getMutator();
599598
<#if type.major == "VarLen">
@@ -666,11 +665,8 @@ public void setSafe(int index, ${minor.class}Holder value) {
666665
<#if type.major == "VarLen">lastSet = index;</#if>
667666
}
668667

669-
<#if !(type.major == "VarLen" || minor.class == "IntervalYear" || minor.class == "IntervalDay")>
668+
<#if !(type.major == "VarLen" || minor.class == "IntervalDay")>
670669
public void setSafe(int index, ${minor.javaType!type.javaType} value) {
671-
<#if type.major == "VarLen">
672-
fillEmpties(index);
673-
</#if>
674670
bits.getMutator().setSafeToOne(index);
675671
values.getMutator().setSafe(index, value);
676672
setCount++;

‎java/vector/src/test/java/org/apache/arrow/vector/TestDecimalVector.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public class TestDecimalVector {
4545
public void test() {
4646
BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE);
4747
NullableDecimalVector decimalVector = TestUtils.newVector(NullableDecimalVector.class, "decimal", new ArrowType.Decimal(10, scale), allocator);
48+
try (NullableDecimalVector oldConstructor = new NullableDecimalVector("decimal", allocator, 10, scale);) {
49+
assertEquals(decimalVector.getField().getType(), oldConstructor.getField().getType());
50+
}
4851
decimalVector.allocateNew();
4952
BigDecimal[] values = new BigDecimal[intValues.length];
5053
for (int i = 0; i < intValues.length; i++) {

0 commit comments

Comments
 (0)