public async Task Should_be_able_to_aggregate_and_return_results_in_projection() { var hosts = new List <IPEndPoint> { new IPEndPoint(_fixture.ImpalaIp, 21000) }; var api = new BongoClient(hosts, 1); var items = new List <AggregationAndProjectionTests_Item> { new AggregationAndProjectionTests_Item { Time = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), Passes = 10, Fails = 2 }, new AggregationAndProjectionTests_Item { Time = new DateTimeOffset(2000, 1, 2, 0, 0, 0, TimeSpan.Zero), Passes = 5, Fails = 20 }, new AggregationAndProjectionTests_Item { Time = new DateTimeOffset(2000, 1, 10, 0, 0, 0, TimeSpan.Zero), Passes = 10, Fails = 2 }, new AggregationAndProjectionTests_Item { Time = new DateTimeOffset(2000, 1, 11, 0, 0, 0, TimeSpan.Zero), Passes = 1, Fails = 3 } }; await api.Insert(items); var results = await api.Query <Projection>($@" select sum(passes) as totalpasses, sum(fails) as totalfails, floor(time/{TimeSpan.FromDays(30).TotalMilliseconds}) as bucket from aggregation_test_1 group by floor(time/{TimeSpan.FromDays(30).TotalMilliseconds}) "); results.Should().HaveCount(1); results.First().ShouldBeEquivalentTo(new Projection { Bucket = 365, TotalPasses = 26, TotalFails = 27 }); }
static async Task Main(string[] args) { var ip = Dns.GetHostAddresses("impala"); using (var bongoClient = new BongoClient(new List <IPEndPoint> { new IPEndPoint(ip[0], 21000) }, 50)) { var items = new List <TestEntity> { new TestEntity { Time = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), Passes = 10, Fails = 2 }, new TestEntity { Time = new DateTimeOffset(2000, 1, 2, 0, 0, 0, TimeSpan.Zero), Passes = 5, Fails = 20 }, new TestEntity { Time = new DateTimeOffset(2000, 1, 10, 0, 0, 0, TimeSpan.Zero), Passes = 10, Fails = 2 }, new TestEntity { Time = new DateTimeOffset(2000, 1, 20, 0, 0, 0, TimeSpan.Zero), Passes = 1, Fails = 3 } }; await bongoClient.Insert(items, true); var results = await bongoClient.Query <Projection>($@" select sum(passes) as totalpasses, sum(fails) as totalfails, floor(time/{TimeSpan.FromDays(30).TotalMilliseconds}) as bucket from aggregation_test_1 group by floor(time/{TimeSpan.FromDays(30).TotalMilliseconds}); "); } }
public async Task Should_be_able_to_parse_all_types_when_checking_for_table_creation() { var hosts = new List <IPEndPoint> { new IPEndPoint(_fixture.ImpalaIp, 21000) }; var api = new BongoClient(hosts, 1); var items = new List <TableCreationAndStartupCheckTests_TypeCheck> { new TableCreationAndStartupCheckTests_TypeCheck { Id = 1, TestEnum = TestEnum.Off, SomeTime = TimeSpan.FromMinutes(2), NullableLong = 3, At = DateTimeOffset.Now }, new TableCreationAndStartupCheckTests_TypeCheck { Id = 2, TestEnum = TestEnum.On, SomeTime = TimeSpan.FromMilliseconds(456), At = DateTimeOffset.Now.AddDays(5) } }; await api.Insert(items); var returnedItems = (await api.Query <TableCreationAndStartupCheckTests_TypeCheck>( "select * from table_creation_and_startup_check_tests_type_check_1;")) .OrderBy(item => item.Id) .ToList(); returnedItems .ShouldAllBeEquivalentTo(items, options => options.Excluding(item => item.At)); returnedItems[0].At.Should().BeCloseTo(items[0].At, 200); returnedItems[1].At.Should().BeCloseTo(items[1].At, 200); }