use of org.apache.druid.segment.join.JoinConditionAnalysis in project druid by druid-io.
the class SegmentManagerBroadcastJoinIndexedTableTest method emptyCacheKeyForUnsupportedCondition.
@Test
public void emptyCacheKeyForUnsupportedCondition() {
final DataSource dataSource = new GlobalTableDataSource(TABLE_NAME);
JoinConditionAnalysis condition = EasyMock.mock(JoinConditionAnalysis.class);
EasyMock.expect(condition.canHashJoin()).andReturn(false);
EasyMock.replay(condition);
Assert.assertNull(joinableFactory.build(dataSource, condition).orElse(null));
}
use of org.apache.druid.segment.join.JoinConditionAnalysis in project druid by druid-io.
the class IndexedTableJoinableTest method makeJoinMatcherWithDimensionSelectorOnString.
@Test
public void makeJoinMatcherWithDimensionSelectorOnString() {
final JoinConditionAnalysis condition = JoinConditionAnalysis.forExpression("x == \"j.str\"", PREFIX, ExprMacroTable.nil());
final JoinMatcher joinMatcher = target.makeJoinMatcher(dummyColumnSelectorFactory, condition, false, false, Closer.create());
final DimensionSelector selector = joinMatcher.getColumnSelectorFactory().makeDimensionSelector(DefaultDimensionSpec.of("str"));
// getValueCardinality
Assert.assertEquals(4, selector.getValueCardinality());
// nameLookupPossibleInAdvance
Assert.assertTrue(selector.nameLookupPossibleInAdvance());
// lookupName
Assert.assertEquals("foo", selector.lookupName(0));
Assert.assertEquals("bar", selector.lookupName(1));
Assert.assertEquals("baz", selector.lookupName(2));
Assert.assertNull(selector.lookupName(3));
// lookupId
Assert.assertNull(selector.idLookup());
}
use of org.apache.druid.segment.join.JoinConditionAnalysis in project druid by druid-io.
the class LookupJoinMatcherTest method testCreateConditionAlwaysFalseShouldReturnSuccessfullyAndNotThrowException.
@Test
public void testCreateConditionAlwaysFalseShouldReturnSuccessfullyAndNotThrowException() {
JoinConditionAnalysis condition = JoinConditionAnalysis.forExpression("0", PREFIX, ExprMacroTable.nil());
target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, false);
Assert.assertNotNull(target);
target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true);
Assert.assertNotNull(target);
}
use of org.apache.druid.segment.join.JoinConditionAnalysis in project druid by druid-io.
the class LookupJoinMatcherTest method testMatchConditionSometimesTrueSometimesFalse.
@Test
public void testMatchConditionSometimesTrueSometimesFalse() {
final int index = 1;
SingleIndexedInt row = new SingleIndexedInt();
row.setValue(index);
Mockito.doReturn(dimensionSelector).when(leftSelectorFactory).makeDimensionSelector(ArgumentMatchers.any(DimensionSpec.class));
Mockito.doReturn(row).when(dimensionSelector).getRow();
Mockito.doReturn("foo").when(dimensionSelector).lookupName(index);
Mockito.doReturn("bar").when(extractor).apply("foo");
JoinConditionAnalysis condition = JoinConditionAnalysis.forExpression(StringUtils.format("\"%sk\" == foo", PREFIX), PREFIX, ExprMacroTable.nil());
target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true);
// Test match
target.matchCondition();
Assert.assertTrue(target.hasMatch());
verifyMatch("foo", "bar");
// Test no more
target.nextMatch();
Assert.assertFalse(target.hasMatch());
}
use of org.apache.druid.segment.join.JoinConditionAnalysis in project druid by druid-io.
the class LookupJoinMatcherTest method testMatchMultiValuedRowShouldThrowException.
@Test(expected = QueryUnsupportedException.class)
public void testMatchMultiValuedRowShouldThrowException() {
ArrayBasedIndexedInts row = new ArrayBasedIndexedInts(new int[] { 2, 4, 6 });
Mockito.doReturn(dimensionSelector).when(leftSelectorFactory).makeDimensionSelector(ArgumentMatchers.any(DimensionSpec.class));
Mockito.doReturn(row).when(dimensionSelector).getRow();
JoinConditionAnalysis condition = JoinConditionAnalysis.forExpression(StringUtils.format("\"%sk\" == foo", PREFIX), PREFIX, ExprMacroTable.nil());
target = LookupJoinMatcher.create(extractor, leftSelectorFactory, condition, true);
// Test match should throw exception
target.matchCondition();
}
Aggregations