Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions be/src/vec/functions/function_ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,12 @@ class FunctionCutIPv6 : public IFunction {
auto ipv6_idx = index_check_const(i, ipv6_const);
auto bytes_to_cut_for_ipv6_idx = index_check_const(i, bytes_to_cut_for_ipv6_const);
auto bytes_to_cut_for_ipv4_idx = index_check_const(i, bytes_to_cut_for_ipv4_const);
// the current function logic is processed in big endian manner
// But ipv6 in doris is stored in little-endian byte order
// need transfer to big-endian byte order first, so we can't deal this process in column
auto val_128 = ipv6_addr_column_data[ipv6_idx];
auto* address = reinterpret_cast<unsigned char*>(&val_128);

auto* address = const_cast<unsigned char*>(
reinterpret_cast<const unsigned char*>(&ipv6_addr_column_data[ipv6_idx]));
Int8 bytes_to_cut_for_ipv6_count =
to_cut_for_ipv6_bytes_column_data[bytes_to_cut_for_ipv6_idx];
Int8 bytes_to_cut_for_ipv4_count =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
:: ::ffff:0.0.0.0
:: ::ffff:192.168.0.0
Expand All @@ -17,3 +18,7 @@ ffff:ffff:ffff:ffff:: ::

-- !sql --
\N

-- !sql --
0 182a:556f:6665:4fb1:a0f0:40ff:3af2:7ad3

Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,20 @@ suite("test_cut_ipv6_function") {
qt_sql "select cut_ipv6(to_ipv6('2001:0DB8:AC10:FE01:FEED:BABE:CAFE:F00D'), 0, NULL)"

sql "DROP TABLE test_cut_ipv6_function"

sql """ DROP TABLE IF EXISTS test_cutipv6 """
sql """
CREATE TABLE `test_cutipv6` (
`pk` int NOT NULL,
`col_ipv6_undef_signed` ipv6 NULL
) ENGINE=OLAP
UNIQUE KEY(`pk`)
DISTRIBUTED BY HASH(`pk`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """ insert into test_cutipv6 values(0,"182a:556f:6665:4fb1:a0f0:40ff:3af2:7ad3"); """
qt_sql "select pk,col_ipv6_undef_signed from test_cutipv6 where cut_ipv6(col_ipv6_undef_signed, 4, 7) != '182a:556f:6665:4fb1:a0f0:40ff:3af2:7ad3';"

}