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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 4e889bbc6dc [fix](Nereids) support implicit cast ip types to string 
(#39318) (#39440)
4e889bbc6dc is described below

commit 4e889bbc6dc5c589d953559613313cf873ee5f66
Author: morrySnow <[email protected]>
AuthorDate: Fri Aug 16 09:57:02 2024 +0800

    [fix](Nereids) support implicit cast ip types to string (#39318) (#39440)
    
    pick from master #39318
---
 .../java/org/apache/doris/catalog/PrimitiveType.java     |  8 ++++++++
 regression-test/suites/nereids_syntax_p0/cast.groovy     | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git 
a/fe/fe-common/src/main/java/org/apache/doris/catalog/PrimitiveType.java 
b/fe/fe-common/src/main/java/org/apache/doris/catalog/PrimitiveType.java
index 33168654e10..b2666a7e722 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/PrimitiveType.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/PrimitiveType.java
@@ -591,6 +591,14 @@ public enum PrimitiveType {
         builder.put(VARIANT, STRING);
         builder.put(VARIANT, JSONB);
 
+        // ipv4
+        builder.put(IPV4, VARCHAR);
+        builder.put(IPV4, STRING);
+
+        // ipv6
+        builder.put(IPV6, VARCHAR);
+        builder.put(IPV6, STRING);
+
         // HLL
         builder.put(HLL, HLL);
 
diff --git a/regression-test/suites/nereids_syntax_p0/cast.groovy 
b/regression-test/suites/nereids_syntax_p0/cast.groovy
index 4a4192175b1..e4b4745557d 100644
--- a/regression-test/suites/nereids_syntax_p0/cast.groovy
+++ b/regression-test/suites/nereids_syntax_p0/cast.groovy
@@ -248,4 +248,20 @@ suite("cast") {
         sql """select cast(k11 as time) ct from test order by ct;"""
         exception "cannot cast"
     }
+
+    // ip
+
+    sql """drop table if exists ip_test"""
+    sql """
+        create table if not exists ip_test (a ipv6, b ipv4)  properties 
("replication_num" = "1");
+    """
+    sql """
+        insert into ip_test values('d916:b163:3ce8:e0f3:b953:fa0c:ab21:1ff9', 
"172.20.48.119");
+    """
+
+    sql """sync"""
+
+    sql """select ipv6_string_to_num(a), ipv4_string_to_num(b) from ip_test"""
+    sql """drop table if exists ip_test"""
 }
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to