Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,62 @@ public void testVariantFieldIn() throws IOException {
.isTrue();
}

@TestTemplate
public void testVariantFieldLt() throws IOException {
assumeThat(format).isEqualTo(FileFormat.PARQUET);

VariantMetadata md = Variants.metadata("k");
Variant v0 = createVariantWithKey(md, "v0");
List<GenericRecord> records = createVariantRecords(v0);

boolean shouldRead = shouldReadVariant(lessThan("variant_field", v0), records);
assertThat(shouldRead)
.as("Should read: variant lt filters must be evaluated post scan")
.isTrue();
}

@TestTemplate
public void testVariantFieldLtEq() throws IOException {
assumeThat(format).isEqualTo(FileFormat.PARQUET);

VariantMetadata md = Variants.metadata("k");
Variant v0 = createVariantWithKey(md, "v0");
List<GenericRecord> records = createVariantRecords(v0);

boolean shouldRead = shouldReadVariant(lessThanOrEqual("variant_field", v0), records);
assertThat(shouldRead)
.as("Should read: variant ltEq filters must be evaluated post scan")
.isTrue();
}

@TestTemplate
public void testVariantFieldGt() throws IOException {
assumeThat(format).isEqualTo(FileFormat.PARQUET);

VariantMetadata md = Variants.metadata("k");
Variant v0 = createVariantWithKey(md, "v0");
List<GenericRecord> records = createVariantRecords(v0);

boolean shouldRead = shouldReadVariant(greaterThan("variant_field", v0), records);
assertThat(shouldRead)
.as("Should read: variant gt filters must be evaluated post scan")
.isTrue();
}

@TestTemplate
public void testVariantFieldGtEq() throws IOException {
assumeThat(format).isEqualTo(FileFormat.PARQUET);

VariantMetadata md = Variants.metadata("k");
Variant v0 = createVariantWithKey(md, "v0");
List<GenericRecord> records = createVariantRecords(v0);

boolean shouldRead = shouldReadVariant(greaterThanOrEqual("variant_field", v0), records);
assertThat(shouldRead)
.as("Should read: variant gtEq filters must be evaluated post scan")
.isTrue();
}

@TestTemplate
public void testUUID() {
assumeThat(format).as("Only valid for Parquet").isEqualTo(FileFormat.PARQUET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ public <T> Boolean notNaN(BoundReference<T> ref) {
public <T> Boolean lt(BoundReference<T> ref, Literal<T> lit) {
int id = ref.fieldId();

// Leave all nested column type and variant type filters to be
// evaluated post scan.
Type type = schema.findType(id);
if (type instanceof Type.NestedType || type.isVariantType()) {
return ROWS_MIGHT_MATCH;
}

Long valueCount = valueCounts.get(id);
if (valueCount == null) {
// the column is not present and is all nulls
Expand Down Expand Up @@ -267,6 +274,13 @@ public <T> Boolean lt(BoundReference<T> ref, Literal<T> lit) {
public <T> Boolean ltEq(BoundReference<T> ref, Literal<T> lit) {
int id = ref.fieldId();

// Leave all nested column type and variant type filters to be
// evaluated post scan.
Type type = schema.findType(id);
if (type instanceof Type.NestedType || type.isVariantType()) {
return ROWS_MIGHT_MATCH;
}

Long valueCount = valueCounts.get(id);
if (valueCount == null) {
// the column is not present and is all nulls
Expand Down Expand Up @@ -297,6 +311,13 @@ public <T> Boolean ltEq(BoundReference<T> ref, Literal<T> lit) {
public <T> Boolean gt(BoundReference<T> ref, Literal<T> lit) {
int id = ref.fieldId();

// Leave all nested column type and variant type filters to be
// evaluated post scan.
Type type = schema.findType(id);
if (type instanceof Type.NestedType || type.isVariantType()) {
return ROWS_MIGHT_MATCH;
}

Long valueCount = valueCounts.get(id);
if (valueCount == null) {
// the column is not present and is all nulls
Expand Down Expand Up @@ -327,6 +348,13 @@ public <T> Boolean gt(BoundReference<T> ref, Literal<T> lit) {
public <T> Boolean gtEq(BoundReference<T> ref, Literal<T> lit) {
int id = ref.fieldId();

// Leave all nested column type and variant type filters to be
// evaluated post scan.
Type type = schema.findType(id);
if (type instanceof Type.NestedType || type.isVariantType()) {
return ROWS_MIGHT_MATCH;
}

Long valueCount = valueCounts.get(id);
if (valueCount == null) {
// the column is not present and is all nulls
Expand Down
Loading