diff --git a/core/trino-main/src/main/java/io/trino/operator/output/RleAwarePositionsAppender.java b/core/trino-main/src/main/java/io/trino/operator/output/RleAwarePositionsAppender.java index 41b08f0397a6..dbffe7983146 100644 --- a/core/trino-main/src/main/java/io/trino/operator/output/RleAwarePositionsAppender.java +++ b/core/trino-main/src/main/java/io/trino/operator/output/RleAwarePositionsAppender.java @@ -54,7 +54,7 @@ public void append(IntArrayList positions, Block source) { // RleAwarePositionsAppender should be used with UnnestingPositionsAppender that makes sure // append is called only with flat block - checkArgument(!(source instanceof RunLengthEncodedBlock), "Append should be called with flat block but got %s", source); + checkArgument(!(source instanceof RunLengthEncodedBlock), "Append should be called with non-RLE block but got %s", source); switchToFlat(); delegate.append(positions, source); } diff --git a/core/trino-main/src/main/java/io/trino/operator/output/UnnestingPositionsAppender.java b/core/trino-main/src/main/java/io/trino/operator/output/UnnestingPositionsAppender.java index c56f02b4c754..cedc3ece1cfd 100644 --- a/core/trino-main/src/main/java/io/trino/operator/output/UnnestingPositionsAppender.java +++ b/core/trino-main/src/main/java/io/trino/operator/output/UnnestingPositionsAppender.java @@ -117,6 +117,11 @@ public long getSizeInBytes() private void appendDictionary(IntArrayList positions, DictionaryBlock source) { Block dictionary = source.getDictionary(); + if (dictionary instanceof RunLengthEncodedBlock rleDictionary) { + appendRle(rleDictionary.getValue(), positions.size()); + return; + } + IntArrayList dictionaryPositions = getDictionaryPositions(positions, source); if (dictionaryBlockBuilder.canAppend(dictionary)) { dictionaryBlockBuilder.append(dictionaryPositions, dictionary);