Exemplo n.º 1
0
 def test_count(self):
     self.assertEqual(
         " | summarize count()",
         Query().summarize(f.count()).render()
     )
     self.assertEqual(
         " | summarize count(stringField)",
         Query().summarize(f.count(t.stringField)).render()
     )
Exemplo n.º 2
0
 def test_summarize_by(self):
     self.assertEqual(
         "mock_table | summarize count(stringField), my_count = count(stringField2) by boolField, bin(numField, 1), time_range = bin(dateField, 10)",
         Query(t).summarize(f.count(t.stringField),
                            my_count=f.count(t.stringField2)).by(
                                t.boolField,
                                f.bin(t.numField, 1),
                                time_range=f.bin(t.dateField, 10)).render(),
     )
Exemplo n.º 3
0
 def test_summarize_by_with_shuffle_hint_specific_key(self):
     self.assertEqual(
         "mock_table | summarize hint.shufflekey = boolField count(stringField) by boolField, time_range = bin(dateField, time(0.0:0:10.0))",
         (Query(t).summarize(f.count(t.stringField)).by(
             t.boolField,
             time_range=f.bin(t.dateField, timedelta(
                 seconds=10))).shuffle_key(t.boolField).render()))
Exemplo n.º 4
0
 def test_summarize_by_with_shuffle_hint_multiple_specific_keys(self):
     self.assertEqual(
         "mock_table | summarize hint.shufflekey = boolField hint.shufflekey = stringField count(stringField) by boolField, stringField, numField",
         (Query(t).summarize(f.count(t.stringField)).by(
             t.boolField, t.stringField, t.numField).shuffle_key(
                 t.boolField, t.stringField).render()))
Exemplo n.º 5
0
 def test_summarize_by_with_shuffle_hint(self):
     self.assertEqual(
         "mock_table | summarize hint.strategy = shuffle count(stringField) by tostring(mapField)",
         Query(t).summarize(f.count(t.stringField)).by(
             f.to_string(t.mapField)).shuffle_key().render())
Exemplo n.º 6
0
 def test_summarize_by_expression(self):
     self.assertEqual(
         "mock_table | summarize count(stringField) by tostring(mapField)",
         Query(t).summarize(f.count(t.stringField)).by(
             f.to_string(t.mapField)).render(),
     )
Exemplo n.º 7
0
 def test_summarize(self):
     self.assertEqual(
         "mock_table | summarize count(stringField), my_count = count(stringField2)",
         Query(t).summarize(f.count(t.stringField),
                            my_count=f.count(t.stringField2)).render(),
     )