Fix self-referential shape inspection in BaseExpressionColumnValueSelector. (#12669)

* Fix self-referential shape inspection in BaseExpressionColumnValueSelector.

The new test would throw StackOverflowError on the old code.

* Restore prior test.
This commit is contained in:
Gian Merlino 2022-06-17 16:15:50 -07:00 committed by GitHub
parent 18937ffee2
commit e76a5077ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -86,7 +86,7 @@ public abstract class BaseExpressionColumnValueSelector implements ColumnValueSe
@Override @Override
public void inspectRuntimeShape(final RuntimeShapeInspector inspector) public void inspectRuntimeShape(final RuntimeShapeInspector inspector)
{ {
inspector.visit("rowIdSupplier", this); inspector.visit("rowIdSupplier", rowIdSupplier);
} }
/** /**

View File

@ -4614,6 +4614,48 @@ public class TopNQueryRunnerTest extends InitializedNullHandlingTest
assertExpectedResults(expectedResults, query); assertExpectedResults(expectedResults, query);
} }
@Test
public void testFullOnTopNAggregateLongVirtualColumn()
{
TopNQuery query = new TopNQueryBuilder()
.dataSource(QueryRunnerTestHelper.DATA_SOURCE)
.granularity(QueryRunnerTestHelper.ALL_GRAN)
.virtualColumns(new ExpressionVirtualColumn("v0", "index", ColumnType.LONG, ExprMacroTable.nil()))
.dimension(new DefaultDimensionSpec("quality", "quality"))
.metric("sumIndex")
.threshold(4)
.intervals(QueryRunnerTestHelper.FULL_ON_INTERVAL_SPEC)
.aggregators(Collections.singletonList(new LongSumAggregatorFactory("sumIndex", "v0")))
.build();
List<Result<TopNResultValue>> expectedResults = Collections.singletonList(
new Result<>(
DateTimes.of("2011-01-12T00:00:00.000Z"),
new TopNResultValue(
Arrays.<Map<String, Object>>asList(
ImmutableMap.<String, Object>builder()
.put("quality", "mezzanine")
.put("sumIndex", 217586L)
.build(),
ImmutableMap.<String, Object>builder()
.put("quality", "premium")
.put("sumIndex", 210722L)
.build(),
ImmutableMap.<String, Object>builder()
.put("quality", "automotive")
.put("sumIndex", 12226L)
.build(),
ImmutableMap.<String, Object>builder()
.put("quality", "entertainment")
.put("sumIndex", 12038L)
.build()
)
)
)
);
assertExpectedResults(expectedResults, query);
}
@Test @Test
public void testTopNStringVirtualColumn() public void testTopNStringVirtualColumn()
{ {