This is an automated email from the ASF dual-hosted git repository.
dianfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/master by this push:
new f2beda6d934 [FLINK-23758][python] Fix semantics of
Expression.__invert__ (#29148)
f2beda6d934 is described below
commit f2beda6d9340f5faf97b450475ba85423546de45
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 5212de11f86..d695dbd4231 100644
--- a/flink-python/pyflink/table/expression.py
+++ b/flink-python/pyflink/table/expression.py
@@ -487,7 +487,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 f50fb6309ce..f894cc2afd5 100644
--- a/flink-python/pyflink/table/tests/test_expression.py
+++ b/flink-python/pyflink/table/tests/test_expression.py
@@ -56,7 +56,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))