Esempio n. 1
0
 def test_bin_auto(self):
     self.assertEqual(
         " | summarize avg(numField) by bin_auto(numField)",
         Query().summarize(f.avg(t.numField)).by(f.bin_auto(t.numField)).render()
     )
     self.assertEqual(
         " | summarize avg(numField) by bin_auto(timespanField)",
         Query().summarize(f.avg(t.numField)).by(f.bin_auto(t.timespanField)).render()
     )
Esempio n. 2
0
 def test_avg(self):
     self.assertEqual(
         " | summarize avg(numField)",
         Query().summarize(f.avg(t.numField)).render()
     )
     self.assertEqual(
         " | summarize avg(numField) - 5",
         Query().summarize(f.avg(t.numField) - 5).render()
     )
Esempio n. 3
0
 def test_bin(self):
     self.assertEqual(
         " | summarize avg(numField) by bin(numField2, 0.1)",
         Query().summarize(f.avg(t.numField)).by(f.bin(t.numField2, 0.1)).render()
     )
     self.assertEqual(
         " | summarize avg(numField2) by bin(dateField, time(0.12:0:0.0))",
         Query().summarize(f.avg(t.numField2)).by(f.bin(t.dateField, timedelta(0.5))).render()
     )
     self.assertEqual(
         " | summarize avg(numField2) by bin(timespanField, time(0.12:0:0.0))",
         Query().summarize(f.avg(t.numField2)).by(f.bin(t.timespanField, timedelta(0.5))).render()
     )
Esempio n. 4
0
 def test_bin_at(self):
     self.assertEqual(
         " | summarize avg(numField) by bin_at(numField2, 0.1, 1)",
         Query().summarize(f.avg(t.numField)).by(
             f.bin_at(t.numField2, 0.1, 1)).render())
     self.assertEqual(
         " | summarize avg(numField) by bin_at(dateField, time(0.12:0:0.0), datetime(2019-07-08 00:00:00.000000))",
         Query().summarize(f.avg(t.numField)).by(
             f.bin_at(t.dateField, timedelta(0.5), datetime(2019, 7,
                                                            8))).render())
     self.assertEqual(
         " | summarize avg(numField) by bin_at(timespanField, time(0.12:0:0.0), time(1.0:0:0.0))",
         Query().summarize(f.avg(t.numField)).by(
             f.bin_at(t.timespanField, timedelta(0.5),
                      timedelta(days=1))).render())