Skip to content

Commit

Permalink
[fix](Nereids) support implicit cast ip types to string (apache#39318)
Browse files Browse the repository at this point in the history
  • Loading branch information
morrySnow authored Aug 14, 2024
1 parent b2ef072 commit c51e786
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,14 @@ public static ImmutableSetMultimap<PrimitiveType, PrimitiveType> getImplicitCast
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);

Expand Down
15 changes: 15 additions & 0 deletions regression-test/suites/nereids_syntax_p0/cast.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,19 @@ suite("cast") {
sql "select cast(1 as signed int)"
sql "select cast(1 as unsigned)"
sql "select cast(1 as unsigned integer)"

// 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"""
}

0 comments on commit c51e786

Please sign in to comment.