Skip to content

Commit 4b30fd4

Browse files
authored
chore: remove dead useDecimal128 plumbing (#4382)
1 parent 354ad46 commit 4b30fd4

20 files changed

Lines changed: 75 additions & 134 deletions

native/core/src/execution/columnar_to_row.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,10 +1052,10 @@ impl ColumnarToRowContext {
10521052
})
10531053
}
10541054
(DataType::Int32, DataType::Decimal128(precision, scale)) => {
1055-
// Parquet stores small-precision decimals as Int32 for efficiency.
1056-
// When COMET_USE_DECIMAL_128 is false, BatchReader produces these types.
1057-
// The Int32 value is already scaled (e.g., -1 means -0.01 for scale 2).
1058-
// We need to reinterpret (not cast) to Decimal128 preserving the value.
1055+
// Parquet stores small-precision decimals as Int32 for efficiency, and the
1056+
// reader may surface them as the physical Int32 type. The value is already
1057+
// scaled (e.g., -1 means -0.01 for scale 2). Reinterpret (not cast) to
1058+
// Decimal128 preserving the value.
10591059
let int_array = array.as_any().downcast_ref::<Int32Array>().ok_or_else(|| {
10601060
CometError::Internal("Failed to downcast to Int32Array".to_string())
10611061
})?;
@@ -2581,8 +2581,7 @@ mod tests {
25812581
#[test]
25822582
fn test_convert_int32_to_decimal128() {
25832583
// Test that Int32 arrays are correctly cast to Decimal128 when schema expects Decimal128.
2584-
// This can happen when COMET_USE_DECIMAL_128 is false and the parquet reader produces
2585-
// Int32 for small-precision decimals.
2584+
// This can happen when the parquet reader surfaces small-precision decimals as Int32.
25862585

25872586
// Create an Int32 array representing decimals: [-1, -2, -3] which at scale 2 means
25882587
// [-0.01, -0.02, -0.03]
@@ -2619,8 +2618,7 @@ mod tests {
26192618
#[test]
26202619
fn test_convert_int64_to_decimal128() {
26212620
// Test that Int64 arrays are correctly cast to Decimal128 when schema expects Decimal128.
2622-
// This can happen when COMET_USE_DECIMAL_128 is false and the parquet reader produces
2623-
// Int64 for medium-precision decimals.
2621+
// This can happen when the parquet reader surfaces medium-precision decimals as Int64.
26242622

26252623
// Create an Int64 array representing decimals
26262624
let int_array: ArrayRef = Arc::new(Int64Array::from(vec![-100i64, -200, -300]));

native/core/src/parquet/parquet_support.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ pub struct SparkParquetOptions {
7474
pub allow_incompat: bool,
7575
/// Support casting unsigned ints to signed ints (used by Parquet SchemaAdapter)
7676
pub allow_cast_unsigned_ints: bool,
77-
/// Whether to always represent decimals using 128 bits. If false, the native reader may represent decimals using 32 or 64 bits, depending on the precision.
78-
pub use_decimal_128: bool,
7977
/// Whether to read dates/timestamps that were written in the legacy hybrid Julian + Gregorian calendar as it is. If false, throw exceptions instead. If the spark type is TimestampNTZ, this should be true.
8078
pub use_legacy_date_timestamp_or_ntz: bool,
8179
// Whether schema field names are case sensitive
@@ -105,7 +103,6 @@ impl SparkParquetOptions {
105103
timezone: timezone.to_string(),
106104
allow_incompat,
107105
allow_cast_unsigned_ints: false,
108-
use_decimal_128: false,
109106
use_legacy_date_timestamp_or_ntz: false,
110107
case_sensitive: false,
111108
return_null_struct_if_all_fields_missing: true,
@@ -121,7 +118,6 @@ impl SparkParquetOptions {
121118
timezone: "".to_string(),
122119
allow_incompat,
123120
allow_cast_unsigned_ints: false,
124-
use_decimal_128: false,
125121
use_legacy_date_timestamp_or_ntz: false,
126122
case_sensitive: false,
127123
return_null_struct_if_all_fields_missing: true,

spark/src/main/java/org/apache/comet/vector/CometDecodedVector.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ public abstract class CometDecodedVector extends CometVector {
4040
private byte validityByteCache;
4141
protected boolean isUuid;
4242

43-
protected CometDecodedVector(ValueVector vector, Field valueField, boolean useDecimal128) {
44-
this(vector, valueField, useDecimal128, false);
43+
protected CometDecodedVector(ValueVector vector, Field valueField) {
44+
this(vector, valueField, false);
4545
}
4646

47-
protected CometDecodedVector(
48-
ValueVector vector, Field valueField, boolean useDecimal128, boolean isUuid) {
49-
super(Utils.fromArrowField(valueField), useDecimal128);
47+
protected CometDecodedVector(ValueVector vector, Field valueField, boolean isUuid) {
48+
super(Utils.fromArrowField(valueField));
5049
this.valueVector = vector;
5150
this.numNulls = valueVector.getNullCount();
5251
this.numValues = valueVector.getValueCount();

spark/src/main/java/org/apache/comet/vector/CometDelegateVector.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,11 @@ public class CometDelegateVector extends CometVector {
3333
protected CometVector delegate;
3434

3535
public CometDelegateVector(DataType dataType) {
36-
this(dataType, null, false);
36+
this(dataType, null);
3737
}
3838

39-
public CometDelegateVector(DataType dataType, boolean useDecimal128) {
40-
this(dataType, null, useDecimal128);
41-
}
42-
43-
public CometDelegateVector(DataType dataType, CometVector delegate, boolean useDecimal128) {
44-
super(dataType, useDecimal128);
39+
public CometDelegateVector(DataType dataType, CometVector delegate) {
40+
super(dataType);
4541
if (delegate instanceof CometDelegateVector) {
4642
throw new IllegalArgumentException("cannot have nested delegation");
4743
}

spark/src/main/java/org/apache/comet/vector/CometDictionaryVector.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,17 @@ public class CometDictionaryVector extends CometDecodedVector {
3535
private final boolean isAlias;
3636

3737
public CometDictionaryVector(
38-
CometPlainVector indices,
39-
CometDictionary values,
40-
DictionaryProvider provider,
41-
boolean useDecimal128) {
42-
this(indices, values, provider, useDecimal128, false, false);
38+
CometPlainVector indices, CometDictionary values, DictionaryProvider provider) {
39+
this(indices, values, provider, false, false);
4340
}
4441

4542
public CometDictionaryVector(
4643
CometPlainVector indices,
4744
CometDictionary values,
4845
DictionaryProvider provider,
49-
boolean useDecimal128,
5046
boolean isAlias,
5147
boolean isUuid) {
52-
super(indices.valueVector, values.getValueVector().getField(), useDecimal128, isUuid);
48+
super(indices.valueVector, values.getValueVector().getField(), isUuid);
5349
Preconditions.checkArgument(
5450
indices.valueVector instanceof IntVector, "'indices' should be a IntVector");
5551
this.values = values;
@@ -131,11 +127,11 @@ byte[] getBinaryDecimal(int i) {
131127
public CometVector slice(int offset, int length) {
132128
TransferPair tp = indices.valueVector.getTransferPair(indices.valueVector.getAllocator());
133129
tp.splitAndTransfer(offset, length);
134-
CometPlainVector sliced = new CometPlainVector(tp.getTo(), useDecimal128);
130+
CometPlainVector sliced = new CometPlainVector(tp.getTo());
135131

136132
// Set the alias flag to true so that the sliced vector will not close the dictionary vector.
137133
// Otherwise, if the dictionary is closed, the sliced vector will not be able to access the
138134
// dictionary.
139-
return new CometDictionaryVector(sliced, values, provider, useDecimal128, true, isUuid);
135+
return new CometDictionaryVector(sliced, values, provider, true, isUuid);
140136
}
141137
}

spark/src/main/java/org/apache/comet/vector/CometListVector.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ public class CometListVector extends CometDecodedVector {
3333
final ColumnVector dataColumnVector;
3434
final DictionaryProvider dictionaryProvider;
3535

36-
public CometListVector(
37-
ValueVector vector, boolean useDecimal128, DictionaryProvider dictionaryProvider) {
38-
super(vector, vector.getField(), useDecimal128);
36+
public CometListVector(ValueVector vector, DictionaryProvider dictionaryProvider) {
37+
super(vector, vector.getField());
3938

4039
this.listVector = ((ListVector) vector);
4140
this.dataVector = listVector.getDataVector();
4241
this.dictionaryProvider = dictionaryProvider;
43-
this.dataColumnVector = getVector(dataVector, useDecimal128, dictionaryProvider);
42+
this.dataColumnVector = getVector(dataVector, dictionaryProvider);
4443
}
4544

4645
@Override
@@ -57,6 +56,6 @@ public CometVector slice(int offset, int length) {
5756
TransferPair tp = this.valueVector.getTransferPair(this.valueVector.getAllocator());
5857
tp.splitAndTransfer(offset, length);
5958

60-
return new CometListVector(tp.getTo(), useDecimal128, dictionaryProvider);
59+
return new CometListVector(tp.getTo(), dictionaryProvider);
6160
}
6261
}

spark/src/main/java/org/apache/comet/vector/CometMapVector.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ public class CometMapVector extends CometDecodedVector {
3737
final ColumnVector keys;
3838
final ColumnVector values;
3939

40-
public CometMapVector(
41-
ValueVector vector, boolean useDecimal128, DictionaryProvider dictionaryProvider) {
42-
super(vector, vector.getField(), useDecimal128);
40+
public CometMapVector(ValueVector vector, DictionaryProvider dictionaryProvider) {
41+
super(vector, vector.getField());
4342

4443
this.mapVector = ((MapVector) vector);
4544
this.dataVector = mapVector.getDataVector();
4645
this.dictionaryProvider = dictionaryProvider;
4746

4847
if (dataVector instanceof StructVector) {
49-
this.dataColumnVector = new CometStructVector(dataVector, useDecimal128, dictionaryProvider);
48+
this.dataColumnVector = new CometStructVector(dataVector, dictionaryProvider);
5049

5150
if (dataColumnVector.children.size() != 2) {
5251
throw new RuntimeException(
@@ -77,6 +76,6 @@ public CometVector slice(int offset, int length) {
7776
TransferPair tp = this.valueVector.getTransferPair(this.valueVector.getAllocator());
7877
tp.splitAndTransfer(offset, length);
7978

80-
return new CometMapVector(tp.getTo(), useDecimal128, dictionaryProvider);
79+
return new CometMapVector(tp.getTo(), dictionaryProvider);
8180
}
8281
}

spark/src/main/java/org/apache/comet/vector/CometPlainVector.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,16 @@ public class CometPlainVector extends CometDecodedVector {
4040

4141
private boolean isReused;
4242

43-
public CometPlainVector(ValueVector vector, boolean useDecimal128) {
44-
this(vector, useDecimal128, false);
43+
public CometPlainVector(ValueVector vector) {
44+
this(vector, false);
4545
}
4646

47-
public CometPlainVector(ValueVector vector, boolean useDecimal128, boolean isUuid) {
48-
this(vector, useDecimal128, isUuid, false);
47+
public CometPlainVector(ValueVector vector, boolean isUuid) {
48+
this(vector, isUuid, false);
4949
}
5050

51-
public CometPlainVector(
52-
ValueVector vector, boolean useDecimal128, boolean isUuid, boolean isReused) {
53-
super(vector, vector.getField(), useDecimal128, isUuid);
51+
public CometPlainVector(ValueVector vector, boolean isUuid, boolean isReused) {
52+
super(vector, vector.getField(), isUuid);
5453
// NullType doesn't have data buffer.
5554
if (vector instanceof NullVector) {
5655
this.valueBufferAddress = -1;
@@ -184,7 +183,7 @@ public CometVector slice(int offset, int length) {
184183
TransferPair tp = this.valueVector.getTransferPair(this.valueVector.getAllocator());
185184
tp.splitAndTransfer(offset, length);
186185

187-
return new CometPlainVector(tp.getTo(), useDecimal128);
186+
return new CometPlainVector(tp.getTo());
188187
}
189188

190189
private static UUID convertToUuid(byte[] buf) {

spark/src/main/java/org/apache/comet/vector/CometSelectionVector.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ public class CometSelectionVector extends CometVector {
7171
* @throws IllegalArgumentException if any index is out of bounds
7272
*/
7373
public CometSelectionVector(CometVector values, int[] indices, int numValues) {
74-
// Use the values vector's datatype, useDecimal128, and dictionary provider
75-
super(values.dataType(), values.useDecimal128);
74+
super(values.dataType());
7675

7776
this.values = values;
7877
this.selectionIndices = indices;
@@ -97,8 +96,7 @@ public CometSelectionVector(CometVector values, int[] indices, int numValues) {
9796
}
9897
indicesVector.setValueCount(numValues);
9998

100-
this.indices =
101-
CometVector.getVector(indicesVector, values.useDecimal128, values.getDictionaryProvider());
99+
this.indices = CometVector.getVector(indicesVector, values.getDictionaryProvider());
102100
}
103101

104102
/**

spark/src/main/java/org/apache/comet/vector/CometStructVector.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ public class CometStructVector extends CometDecodedVector {
3333
final List<ColumnVector> children;
3434
final DictionaryProvider dictionaryProvider;
3535

36-
public CometStructVector(
37-
ValueVector vector, boolean useDecimal128, DictionaryProvider dictionaryProvider) {
38-
super(vector, vector.getField(), useDecimal128);
36+
public CometStructVector(ValueVector vector, DictionaryProvider dictionaryProvider) {
37+
super(vector, vector.getField());
3938

4039
StructVector structVector = ((StructVector) vector);
4140

@@ -44,7 +43,7 @@ public CometStructVector(
4443

4544
for (int i = 0; i < size; ++i) {
4645
ValueVector value = structVector.getVectorById(i);
47-
children.add(getVector(value, useDecimal128, dictionaryProvider));
46+
children.add(getVector(value, dictionaryProvider));
4847
}
4948
this.children = children;
5049
this.dictionaryProvider = dictionaryProvider;
@@ -60,6 +59,6 @@ public CometVector slice(int offset, int length) {
6059
TransferPair tp = this.valueVector.getTransferPair(this.valueVector.getAllocator());
6160
tp.splitAndTransfer(offset, length);
6261

63-
return new CometStructVector(tp.getTo(), useDecimal128, dictionaryProvider);
62+
return new CometStructVector(tp.getTo(), dictionaryProvider);
6463
}
6564
}

0 commit comments

Comments
 (0)