This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch release-1.20
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.20 by this push:
     new 3b15f1cf22a [FLINK-23758][python] Fix semantics of 
Expression.__invert__ (#29148)
3b15f1cf22a is described below

commit 3b15f1cf22a22f9974871f455bae65558a501573
Author: Beetle brank <[email protected]>
AuthorDate: Thu Sep 10 11:02:48 2026 +0800

    [FLINK-23758][python] Fix semantics of Expression.__invert__ (#29148)
    
    Generated-by: OpenAI Codex (GPT-5)
---
 flink-python/pyflink/table/expression.py            |  2 +-
 flink-python/pyflink/table/tests/test_calc.py       | 10 ++++++++++
 flink-python/pyflink/table/tests/test_expression.py |  2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/flink-python/pyflink/table/expression.py 
b/flink-python/pyflink/table/expression.py
index d83398e60b7..e8ae9bcafdc 100644
--- a/flink-python/pyflink/table/expression.py
+++ b/flink-python/pyflink/table/expression.py
@@ -476,7 +476,7 @@ class Expression(Generic[T]):
     # logic functions
     __and__ = _binary_op("and")
     __or__ = _binary_op("or")
-    __invert__ = _unary_op('isNotTrue')
+    __invert__ = _unary_op("not")
 
     __rand__ = _binary_op("and")
     __ror__ = _binary_op("or")
diff --git a/flink-python/pyflink/table/tests/test_calc.py 
b/flink-python/pyflink/table/tests/test_calc.py
index 89d6c956270..677f628fcd3 100644
--- a/flink-python/pyflink/table/tests/test_calc.py
+++ b/flink-python/pyflink/table/tests/test_calc.py
@@ -37,6 +37,16 @@ class StreamTableCalcTests(PyFlinkStreamTableTestCase):
         self.assertEqual('[plus(a, 1), b, c]',
                          query_operation.getProjectList().toString())
 
+    def test_invert_nullable_boolean_expression(self):
+        schema = DataTypes.ROW([
+            DataTypes.FIELD("a", DataTypes.BOOLEAN())
+        ])
+        table = self.t_env.from_elements([(True,), (False,), (None,)], schema)
+
+        actual = [tuple(row) for row in table.select(table.a, 
~table.a).execute().collect()]
+
+        self.assertCountEqual(actual, [(True, False), (False, True), (None, 
None)])
+
     def test_alias(self):
         t = self.t_env.from_elements([(1, 'Hi', 'Hello')], ['a', 'b', 'c'])
         t = t.alias("d", "e", "f")
diff --git a/flink-python/pyflink/table/tests/test_expression.py 
b/flink-python/pyflink/table/tests/test_expression.py
index f70b2622d9e..f5c912234bc 100644
--- a/flink-python/pyflink/table/tests/test_expression.py
+++ b/flink-python/pyflink/table/tests/test_expression.py
@@ -53,7 +53,7 @@ class PyFlinkBatchExpressionTests(PyFlinkTestCase):
         self.assertEqual('and(a, b)', str(expr1 & expr2))
         self.assertEqual('or(a, b)', str(expr1 | expr2))
         self.assertEqual('isNotTrue(a)', str(expr1.is_not_true))
-        self.assertEqual('isNotTrue(a)', str(~expr1))
+        self.assertEqual('not(a)', str(~expr1))
 
         # arithmetic functions
         self.assertEqual('plus(a, b)', str(expr1 + expr2))

Reply via email to