@Test public void testCollectDocLevelWhereClause() throws Throwable { EqOperator op = (EqOperator) functions.get( new FunctionIdent( EqOperator.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER, DataTypes.INTEGER))); List<Symbol> toCollect = Collections.<Symbol>singletonList(testDocLevelReference); WhereClause whereClause = new WhereClause( new Function( op.info(), Arrays.<Symbol>asList(testDocLevelReference, Literal.newLiteral(2)))); CollectPhase collectNode = getCollectNode(toCollect, whereClause); Bucket result = collect(collectNode); assertThat(result, contains(isRow(2))); }
@Test public void testCollectShardExpressionsWhereShardIdIs0() throws Exception { EqOperator op = (EqOperator) functions.get( new FunctionIdent( EqOperator.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER, DataTypes.INTEGER))); List<Symbol> toCollect = ImmutableList.<Symbol>of(testShardIdReference); CollectPhase collectNode = new CollectPhase( UUID.randomUUID(), 0, "shardCollect", shardRouting(0, 1), toCollect, EMPTY_PROJECTIONS); collectNode.whereClause( new WhereClause( new Function(op.info(), Arrays.asList(testShardIdReference, Literal.newLiteral(0))))); collectNode.maxRowGranularity(RowGranularity.SHARD); Bucket result = getBucket(collectNode); assertThat(result, contains(isRow(0))); }
@Test public void testCollectWithNullWhereClause() throws Exception { EqOperator op = (EqOperator) functions.get( new FunctionIdent( EqOperator.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER, DataTypes.INTEGER))); CollectPhase collectNode = new CollectPhase( UUID.randomUUID(), 0, "whereClause", testRouting, TO_COLLECT_TEST_REF, EMPTY_PROJECTIONS); collectNode.whereClause( new WhereClause( new Function(op.info(), Arrays.<Symbol>asList(Literal.NULL, Literal.NULL)))); Bucket result = getBucket(collectNode); assertThat(result.size(), is(0)); }