Skip to content

Commit

Permalink
Fixed a bug where none query element type would sometimes be retained…
Browse files Browse the repository at this point in the history
… in the query.
  • Loading branch information
oskar11120 committed Mar 23, 2024
1 parent 1fcf251 commit 76f1c2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
23 changes: 12 additions & 11 deletions Apache.Druid.Querying.Tests.Unit/QueryShould_MapToRightJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ private sealed record FilteredAggregations(double First);
[Test]
public void FilteredAggregation()
{
//var first = new Query<IotMeasurement>
// .TimeSeries
// .WithNoVirtualColumns
// .WithAggregations<double>()
// .Aggregations(type => type.Filtered(
// filterType => filterType.Selector(data => data.Value, 1),
// type.First(data => data.Value)));
//AssertMatch(first);
var first = new Query<IotMeasurement>
.TimeSeries
.WithNoVirtualColumns
.WithAggregations<double>()
.Aggregations(type => type.Filtered(
filterType => filterType.Selector(data => data.Value, 1),
type.First(data => data.Value)));
AssertMatch(first);

var second = new Query<IotMeasurement>
.TimeSeries
Expand All @@ -41,22 +41,23 @@ public void FilteredAggregation()
AssertMatch(second);
}

private sealed record NonePostAggregations(long Value);
[Test]
public void NoneElementType()
{
static Query<IotMeasurement>.GroupBy<double>.WithVirtualColumns<int>.WithAggregations<string>.WithPostAggregations<long> Query()
static Query<IotMeasurement>.GroupBy<double>.WithVirtualColumns<int>.WithAggregations<string>.WithPostAggregations<NonePostAggregations> Query()
=> new Query<IotMeasurement>
.GroupBy<double>
.WithVirtualColumns<int>
.WithAggregations<string>
.WithPostAggregations<long>();
.WithPostAggregations<NonePostAggregations>();
var dimensions = Query().Dimensions(type => type.None<double>());
AssertMatch(dimensions);
var virtualColumns = Query().VirtualColumns(type => type.None<int>());
AssertMatch(virtualColumns);
var aggregations = Query().Aggregations(type => type.None<string>());
AssertMatch(aggregations);
var postAggregations = Query().PostAggregations(type => type.None<long>());
var postAggregations = Query().PostAggregations(type => new(type.None<long>()));
AssertMatch(postAggregations);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ JsonObject MapCall(ElementFactoryCall call, bool mapSectionColumnName, string? p
JsonNode Map(IReadOnlyCollection<ElementFactoryCall> calls, bool forceSingle, bool mapSectionColumnName, string? parentResultMemberName)
{
static bool IsNone(ElementFactoryCall call) =>
call.ResultMemberName is null &&
call.MethodName is "None" &&
call.MethodName is nameof(QueryElementFactory<TArguments>.INone.None) &&
call.Parameters.Count is 0;

if (forceSingle)
Expand Down

0 comments on commit 76f1c2b

Please sign in to comment.