Support for 0 length dictionary copyRegion#20065
Conversation
core/trino-spi/src/main/java/io/trino/spi/block/DictionaryBlock.java
Outdated
Show resolved
Hide resolved
|
I'm not sure that I follow the logic here, to be honest. |
|
@pettyjamesm the error I saw was I guess it might be related to |
|
I might suspect RowBlock (or some RowBlock/ArrayBlock interaction) because it recently changed from being null suppressed to not. |
|
@pettyjamesm which pr removed null suppression? |
|
|
@pettyjamesm do you think that PR could be related somehow to null/empty arrays which would trigger the issue here? |
It seems like a plausible theory for how we might suddenly start seeing off by one, out of bounds position references. |
|
@pettyjamesm but would that be a bug or just a side effect? |
As a starting assumption, I would consider referencing an out of bounds position (even with a zero length) to probably be a bug, but maybe a careful inspection of the related logic would show that zero length regions are actually a valid special special case and should be allowed. |
|
@dain wdyt? |
|
@pettyjamesm here is 0 length region doesn't exceed block boundary technically, but I'm not sure why it happens in the first place (maybe it worked like that always) |
|
Anyway this is a good change since it just makes dictionary support current contract |
And definitely not a bug in RowBlock’s implementation? Asking for an out of bounds range seems fishy, but if it’s valid behavior then maybe we should allow any zero length range at any offset? |
|
We don't need to wrap the description at 40 characters. Also, typo "postiion" |
checkValidRegion already validates that region is correct. Therefore copyRegion for position 42 and length 0 shoudn't fail for dictionary with 42 positions.
checkValidRegion already validates that
region is correct. Therefore copyRegion
for postiion 42 and length 0 shoudn't
fail for dictionary with 42 positions.