Skip to content

Commit 29e1568

Browse files
committed
changes
1 parent ece859a commit 29e1568

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

kernel/kernel-api/src/main/java/io/delta/kernel/internal/data/GenericRow.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ public MapValue getMap(int ordinal) {
137137

138138
@Override
139139
public VariantValue getVariant(int ordinal) {
140-
// TODO(r.chen): test this path somehow?
141140
throwIfUnsafeAccess(ordinal, VariantType.class, "variant");
142141
return (VariantValue) getValue(ordinal);
143142
}

kernel/kernel-api/src/main/java/io/delta/kernel/types/VariantType.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
import io.delta.kernel.annotation.Evolving;
1919

2020
/**
21-
* A variant type.
22-
* <p>
23-
* todo: more comments
21+
* A logical variant type.
2422
* @since 4.0.0
2523
*/
2624
@Evolving

kernel/kernel-defaults/src/main/java/io/delta/kernel/defaults/internal/data/vector/DefaultVariantVector.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public class DefaultVariantVector
3737
* Create an instance of {@link io.delta.kernel.data.ColumnVector} for array type.
3838
*
3939
* @param size number of elements in the vector.
40+
* @param type {@code variant} datatype definition.
4041
* @param nullability Optional array of nullability value for each element in the vector.
4142
* All values in the vector are considered non-null when parameter is
4243
* empty.
43-
* @param offsets Offsets into element vector on where the index of particular row
44-
* values start and end.
45-
* @param elementVector Vector containing the array elements.
44+
* @param value The child binary column vector representing each variant's values.
45+
* @param metadata The child binary column vector representing each variant's metadata.
4646
*/
4747
public DefaultVariantVector(
4848
int size,
@@ -84,6 +84,13 @@ public byte[] getMetadata() {
8484
};
8585
}
8686

87+
/**
88+
* Get the child column vector at the given {@code ordinal}. Variants should only have two
89+
* child vectors, one for value and one for metadata.
90+
*
91+
* @param ordinal
92+
* @return
93+
*/
8794
@Override
8895
public ColumnVector getChild(int ordinal) {
8996
checkArgument(ordinal >= 0 && ordinal < 2, "Invalid ordinal " + ordinal);

kernel/kernel-defaults/src/main/java/io/delta/kernel/defaults/internal/parquet/VariantConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ class VariantConverter
3434
private final BinaryColumnConverter valueConverter;
3535
private final BinaryColumnConverter metadataConverter;
3636

37-
// Working state
38-
private boolean isCurrentValueNull = true;
37+
// working state
3938
private int currentRowIndex;
4039
private boolean[] nullability;
40+
// If the value is null, start/end never get called which is a signal for null
41+
// Set the initial state to true and when start() is called set it to false.
42+
private boolean isCurrentValueNull = true;
4143

4244
/**
4345
* Create converter for {@link VariantType} column.
@@ -46,10 +48,8 @@ class VariantConverter
4648
*/
4749
VariantConverter(int initialBatchSize) {
4850
checkArgument(initialBatchSize > 0, "invalid initialBatchSize: %s", initialBatchSize);
49-
// Initialize the working state
5051
this.nullability = ParquetConverters.initNullabilityVector(initialBatchSize);
5152

52-
int parquetOrdinal = 0;
5353
this.valueConverter = new BinaryColumnConverter(BinaryType.BINARY, initialBatchSize);
5454
this.metadataConverter = new BinaryColumnConverter(BinaryType.BINARY, initialBatchSize);
5555
}

kernel/kernel-defaults/src/test/scala/io/delta/kernel/defaults/internal/parquet/ParquetFileReaderSuite.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ class ParquetFileReaderSuite extends AnyFunSuite
192192
parse_json(cast(id as string)),
193193
null
194194
) as array_v""",
195-
"map('test', cast(null as variant)) as map_value_v",
196-
"map(cast(null as variant), parse_json(cast(id as string))) as map_key_v",
195+
"map('test', cast(null as variant)) as map_value_v"
197196
)
198197
}
199-
200-
// TODO(richardc-db): Add nested variant tests once `parse_json` expression is implemented.
201198
}

0 commit comments

Comments
 (0)