This is an automated email from the ASF dual-hosted git repository.
dianfu pushed a commit to branch release-2.3
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-2.3 by this push:
new 9109067bd17 [FLINK-23758][python] Fix semantics of
Expression.__invert__ (#29148)
9109067bd17 is described below
commit 9109067bd17d4e0f914cdbf2ea17afee27ea6f41
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 9e1711dc455..f1d9c606fa4 100644
--- a/flink-python/pyflink/table/expression.py
+++ b/flink-python/pyflink/table/expression.py
@@ -480,7 +480,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 e7a2078d1db..909f1ef6b8c 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))