Skip to content

Commit ca0c99a

Browse files
authored
Fix coverage (#86)
1 parent 9b8f278 commit ca0c99a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/test/java/com/yahoo/bullet/querying/ProjectionTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.yahoo.bullet.query.expressions.BinaryExpression;
1010
import com.yahoo.bullet.query.expressions.FieldExpression;
1111
import com.yahoo.bullet.query.expressions.Operation;
12+
import com.yahoo.bullet.query.expressions.UnaryExpression;
1213
import com.yahoo.bullet.record.BulletRecord;
1314
import com.yahoo.bullet.record.avro.TypedAvroBulletRecordProvider;
1415
import com.yahoo.bullet.result.RecordBox;
@@ -34,7 +35,8 @@ public void testProjectNewRecord() {
3435
new Field("f", new BinaryExpression(new FieldExpression("d"),
3536
new FieldExpression("e"),
3637
Operation.ADD)),
37-
new Field("g", new FieldExpression("g")));
38+
new Field("g", new FieldExpression("g")),
39+
new Field("h", new UnaryExpression(new FieldExpression("a"), Operation.SIZE_OF)));
3840

3941
Projection projection = new Projection(fields);
4042
BulletRecord newRecord = projection.project(record, new TypedAvroBulletRecordProvider());
@@ -62,7 +64,8 @@ public void testProjectOldRecord() {
6264
new Field("e", new BinaryExpression(new FieldExpression("e"),
6365
new FieldExpression("f"),
6466
Operation.SUB)),
65-
new Field("f", new FieldExpression("f")));
67+
new Field("f", new FieldExpression("f")),
68+
new Field("h", new UnaryExpression(new FieldExpression("a"), Operation.SIZE_OF)));
6669

6770
Projection projection = new Projection(fields);
6871
BulletRecord oldRecord = projection.project(record);

src/test/java/com/yahoo/bullet/querying/postaggregations/OrderByStrategyTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,21 @@ public void testOrderByComputationWithMissingField() {
206206
Assert.assertEquals(result.getRecords().get(3).typedGet("a").getValue(), "world");
207207
Assert.assertEquals(result.getRecords().get(4).typedGet("a").getValue(), "foobar");
208208
}
209+
210+
@Test
211+
public void testOrderByComputationWithBadComputation() {
212+
OrderByStrategy orderByStrategy = makeOrderBy(Collections.singletonList(new OrderBy.SortItem(new UnaryExpression(new FieldExpression("a"), Operation.SIZE_OF), OrderBy.Direction.ASC)));
213+
List<BulletRecord> records = new ArrayList<>();
214+
records.add(RecordBox.get().add("a", 1).getRecord());
215+
records.add(RecordBox.get().add("a", 3).getRecord());
216+
records.add(RecordBox.get().add("a", 2).getRecord());
217+
Clip clip = new Clip();
218+
clip.add(records);
219+
Clip result = orderByStrategy.execute(clip);
220+
221+
// Order should not change
222+
Assert.assertEquals(result.getRecords().get(0).typedGet("a").getValue(), 1);
223+
Assert.assertEquals(result.getRecords().get(1).typedGet("a").getValue(), 3);
224+
Assert.assertEquals(result.getRecords().get(2).typedGet("a").getValue(), 2);
225+
}
209226
}

0 commit comments

Comments
 (0)