Skip to content

Commit

Permalink
Fix IS DISTINCT FROM for long decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
ptkool committed Dec 27, 2019
1 parent 6cc6e5b commit cea8be9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public static boolean distinctBlockPositionLongLong(Block left, int leftPosition

long leftLow = left.getLong(leftPosition, 0);
long leftHigh = left.getLong(leftPosition, SIZE_OF_LONG);
long rightLow = left.getLong(rightPosition, 0);
long rightHigh = left.getLong(rightPosition, SIZE_OF_LONG);
long rightLow = right.getLong(rightPosition, 0);
long rightHigh = right.getLong(rightPosition, SIZE_OF_LONG);
return UnscaledDecimal128Arithmetic.compare(leftLow, leftHigh, rightLow, rightHigh) != 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.facebook.presto.block;

import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.block.BlockBuilder;
import com.facebook.presto.spi.block.Int128ArrayBlock;
import com.facebook.presto.spi.block.Int128ArrayBlockBuilder;
Expand All @@ -23,7 +24,9 @@
import java.util.Optional;

import static com.facebook.presto.spi.block.Int128ArrayBlock.INT128_BYTES;
import static com.facebook.presto.type.DecimalInequalityOperators.distinctBlockPositionLongLong;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

public class TestInt128ArrayBlock
Expand Down Expand Up @@ -82,6 +85,16 @@ public void testCompactBlock()
testIncompactBlock(new Int128ArrayBlock(valueIsNull.length - 2, Optional.of(valueIsNull), longArray));
}

@Test
public void testIsDistinctFrom()
{
Block left = new Int128ArrayBlock(1, Optional.empty(), new long[]{112L, 0L});
Block right = new Int128ArrayBlock(1, Optional.empty(), new long[]{185L, 0L});

assertFalse(distinctBlockPositionLongLong(left, 0, left, 0));
assertTrue(distinctBlockPositionLongLong(left, 0, right, 0));
}

private void assertFixedWithValues(Slice[] expectedValues)
{
BlockBuilder blockBuilder = createBlockBuilderWithValues(expectedValues);
Expand Down

0 comments on commit cea8be9

Please sign in to comment.