def test_iff_ambiguous_type(self): with self.assertLogs(test_logger, logging.WARN) as cm: self.assertEqual( " | project foo = iff(boolField, time(3.0:0:0.0), foo - bar)", Query().project(foo=f.iff(t.boolField, timedelta(3), col.foo - col.bar)).render() ) self.assertEqual([], cm.output)
def test_iff_different_types(self): with self.assertLogs(_logger, logging.WARN) as cm: self.assertEqual( ' | project foo = iff(dateField > (ago(time(2.0:0:0.0))), time(3.0:0:0.0), "hello")', Query().project(foo=f.iff(t.dateField > f.ago(timedelta(2)), timedelta(3), "hello")).render()) self.assertEqual([ 'WARNING:pykusto:The second and third arguments must be of the same type, but they are: timespan and string. ' 'If this is a mistake, please report it at https://github.com/Azure/pykusto/issues' ], cm.output)
def test_iff_related_types(self): self.assertEqual( " | project foo = iff(dateField > (ago(time(2.0:0:0.0))), 2, array_length(arrayField))", Query().project(foo=f.iff(t.dateField > f.ago(timedelta(2)), 2, f.array_length(t.arrayField))).render() )
def test_iff_expression_return_type(self): self.assertEqual( " | project foo = iff(dateField > (ago(time(2.0:0:0.0))), array_length(arrayField), array_length(arrayField2))", Query().project(foo=f.iff(t.dateField > f.ago(timedelta(2)), f.array_length(t.arrayField), f.array_length(t.arrayField2))).render() )
def test_iff(self): self.assertEqual( " | project foo = iff(dateField > (ago(time(2.0:0:0.0))), time(3.0:0:0.0), time(4.0:0:0.0))", Query().project(foo=f.iff(t.dateField > f.ago(timedelta(2)), timedelta(3), timedelta(4))).render() )