Myracle commented on code in PR #27483:
URL: https://github.com/apache/flink/pull/27483#discussion_r2929765409
##########
flink-python/pyflink/table/expression.py:
##########
@@ -1447,6 +1447,43 @@ def url_encode(self) -> 'Expression[str]':
"""
return _unary_op("urlEncode")(self)
+ def inet_aton(self) -> 'Expression':
+ """
+ Converts an IPv4 address string to its numeric representation (BIGINT).
+ This function follows MySQL INET_ATON behavior.
+
+ The conversion formula is: A * 256^3 + B * 256^2 + C * 256 + D for an
IP address A.B.C.D
+
+ Supports MySQL-compatible short-form addresses:
+ - a.b is interpreted as a.0.0.b
+ - a.b.c is interpreted as a.b.0.c
+
+ Examples:
+ - lit('127.0.0.1').inet_aton() returns 2130706433
+ - lit('127.1').inet_aton() returns 2130706433 (short-form)
+ - lit('0.0.0.0').inet_aton() returns 0
+
+ :return: the numeric representation of the IP address, or null if the
input is
+ null or invalid
+ """
+ return _unary_op("inetAton")(self)
+
+ def inet_ntoa(self) -> 'Expression[str]':
+ """
+ Converts a numeric IPv4 address representation (BIGINT or INT) back to
its string format.
+ This function follows MySQL INET_NTOA behavior.
Review Comment:
Thanks for the feedback!
Good point. The INET_NTOA function performs a straightforward
numeric-to-IP-string conversion with no MySQL-specific compatibility behavior
involved, so there's no need to reference MySQL here.
I've removed the "follows MySQL INET_NTOA behavior" line from:
flink-python/pyflink/table/expression.py (Python docstring)
docs/data/sql_functions.yml (English SQL function docs)
docs/data/sql_functions_zh.yml (Chinese SQL function docs)
InetNtoaFunction.java (Java implementation Javadoc)
Note: I kept the MySQL reference in INET_ATON since it does have
MySQL-compatible short-form address parsing behavior (e.g., a.b → a.0.0.b),
which is worth documenting.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]