Skip to content
Closed
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 @@ -167,6 +167,11 @@ private <T extends Comparable<T>> void validateColumn(Column<T> column) {
}

ColumnDescriptor descriptor = getColumnDescriptor(path);
if (descriptor == null) {
// the column is missing from the schema. evaluation uses calls
// updateNull() a value is missing, so this will be handled correctly.
return;
}

if (descriptor.getMaxRepetitionLevel() > 0) {
throw new IllegalArgumentException("FilterPredicates do not currently support repeated columns. "
Expand All @@ -177,8 +182,6 @@ private <T extends Comparable<T>> void validateColumn(Column<T> column) {
}

private ColumnDescriptor getColumnDescriptor(ColumnPath columnPath) {
ColumnDescriptor cd = columnsAccordingToSchema.get(columnPath);
checkArgument(cd != null, "Column " + columnPath + " was not found in schema!");
return cd;
return columnsAccordingToSchema.get(columnPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ private DictionaryFilter(List<ColumnChunkMetaData> columnsList, DictionaryPageRe
}

private ColumnChunkMetaData getColumnChunk(ColumnPath columnPath) {
ColumnChunkMetaData c = columns.get(columnPath);
checkArgument(c != null, "Column " + columnPath.toDotString() + " not found in schema!");
return c;
return columns.get(columnPath);
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -110,22 +108,26 @@ private <T extends Comparable<T>> Set<T> expandDictionary(ColumnChunkMetaData me

@Override
public <T extends Comparable<T>> Boolean visit(Eq<T> eq) {
Column<T> filterColumn = eq.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());
T value = eq.getValue();

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
if (value == null) {
// the dictionary contains only non-null values so isn't helpful. this
// could check the column stats, but the StatisticsFilter is responsible
return BLOCK_MIGHT_MATCH;
}

T value = eq.getValue();
Column<T> filterColumn = eq.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());

filterColumn.getColumnPath();
if (meta == null) {
// the column isn't in this file so all values are null, but the value
// must be non-null because of the above check.
return BLOCK_CANNOT_MATCH;
}

if (value == null) {
// the dictionary contains only non-null values so isn't helpful. this
// could check the column stats, but the StatisticsFilter is responsible
// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
return BLOCK_MIGHT_MATCH;
}

Expand All @@ -146,22 +148,32 @@ public <T extends Comparable<T>> Boolean visit(NotEq<T> notEq) {
Column<T> filterColumn = notEq.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
return BLOCK_MIGHT_MATCH;
}

T value = notEq.getValue();

filterColumn.getColumnPath();
if (value == null && meta == null) {
// the predicate value is null and all rows have a null value, so the
// predicate is always false (null != null)
return BLOCK_CANNOT_MATCH;
}

if (value == null) {
// the dictionary contains only non-null values so isn't helpful. this
// could check the column stats, but the StatisticsFilter is responsible
return BLOCK_MIGHT_MATCH;
}

if (meta == null) {
// column is missing from this file and is always null and not equal to
// the non-null test value, so the predicate is true for all rows
return BLOCK_MIGHT_MATCH;
}

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
return BLOCK_MIGHT_MATCH;
}

try {
Set<T> dictSet = expandDictionary(meta);
if (dictSet != null && dictSet.size() == 1 && dictSet.contains(value)) {
Expand All @@ -179,6 +191,12 @@ public <T extends Comparable<T>> Boolean visit(Lt<T> lt) {
Column<T> filterColumn = lt.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());

if (meta == null) {
// the column is missing and always null, which is never less than a
// value. for all x, null is never < x.
return BLOCK_CANNOT_MATCH;
}

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
Expand All @@ -187,8 +205,6 @@ public <T extends Comparable<T>> Boolean visit(Lt<T> lt) {

T value = lt.getValue();

filterColumn.getColumnPath();

try {
Set<T> dictSet = expandDictionary(meta);
if (dictSet == null) {
Expand All @@ -214,6 +230,12 @@ public <T extends Comparable<T>> Boolean visit(LtEq<T> ltEq) {
Column<T> filterColumn = ltEq.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());

if (meta == null) {
// the column is missing and always null, which is never less than or
// equal to a value. for all x, null is never <= x.
return BLOCK_CANNOT_MATCH;
}

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
Expand Down Expand Up @@ -249,6 +271,12 @@ public <T extends Comparable<T>> Boolean visit(Gt<T> gt) {
Column<T> filterColumn = gt.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());

if (meta == null) {
// the column is missing and always null, which is never greater than a
// value. for all x, null is never > x.
return BLOCK_CANNOT_MATCH;
}

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
Expand All @@ -257,8 +285,6 @@ public <T extends Comparable<T>> Boolean visit(Gt<T> gt) {

T value = gt.getValue();

filterColumn.getColumnPath();

try {
Set<T> dictSet = expandDictionary(meta);
if (dictSet == null) {
Expand All @@ -284,6 +310,12 @@ public <T extends Comparable<T>> Boolean visit(GtEq<T> gtEq) {
Column<T> filterColumn = gtEq.getColumn();
ColumnChunkMetaData meta = getColumnChunk(filterColumn.getColumnPath());

if (meta == null) {
// the column is missing and always null, which is never greater than or
// equal to a value. for all x, null is never >= x.
return BLOCK_CANNOT_MATCH;
}

// if the chunk has non-dictionary pages, don't bother decoding the
// dictionary because the row group can't be eliminated.
if (hasNonDictionaryPages(meta)) {
Expand Down
Loading