xiaokang commented on code in PR #41001: URL: https://github.com/apache/doris/pull/41001#discussion_r1821682355
########## regression-test/suites/nereids_function_p0/scalar_function/IP.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("nereids_scalar_fn_IP") { + sql 'use regression_test_nereids_function_p0' + sql 'set enable_nereids_planner=true' + sql 'set enable_fallback_to_original_planner=false' + + def cidr_v6 = 64 + def cidr_v4 = 32 + // for table fn_test_ip_nullable + // test_ip_cidr_to_range_function + qt_sql_cidr_ipv6 "select id, struct_element(ipv6_cidr_to_range(ip6,$cidr_v6), 'min') as min_range, struct_element(ipv6_cidr_to_range(ip6, $cidr_v6), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv4 "select id, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'min') as min_range, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """ + qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """ + + + // test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id' + exception "Null Input" Review Comment: not null data is not tested. ########## regression-test/suites/nereids_function_p0/load.groovy: ########## @@ -27,6 +27,109 @@ suite("load") { DROP TABLE IF EXISTS `fn_test_bitmap` """ + // test ipv4/ipv6 + sql """ drop table if exists fn_test_ip_nullable """ + sql """ CREATE TABLE IF NOT EXISTS fn_test_ip_nullable (id int, ip4 ipv4, ip6 ipv6) engine=olap + DISTRIBUTED BY HASH(`id`) BUCKETS 4 + properties("replication_num" = "1") """ + // make some special ip address + /*** + 回环地址 + 1;127.0.0.1;::1 + // 私有地址 + - 网络地址 (最小地址) + 2;10.0.0.0;fc00:: + - 广播地址 (最大地址) + 3;10.255.255.255;fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff + - 网络地址 (最小地址) + 4;172.16.0.0;fc00:: + - 广播地址 (最大地址) + 5;172.31.255.255;febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff + - 网络地址 (最小地址) + 6;192.168.0.0;fe80:: + - 广播地址 (最大地址) + 7;192.168.255.255;ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff + // 链路本地地址 + 8;169.254.0.0;fe80:: + // 公有地址 + 9;8.8.8.8;2001:4860:4860::8888 // Google Public DNS + 10;1.1.1.1;2606:4700:4700::1111 // Cloudflare DNS + // 组播地址 + 11;224.0.0.0;ff01:: // 所有主机 + 12;239.255.255.255;ff02::1 // 所有路由器 + // 仅用于文档示例的地址 + 13;192.0.2.0;2001:0db8:85a3::8a2e:0370:7334 + 14;203.0.113.0;2001:db8::1 + 15;198.51.100.0;2001:db8::2 + // 本地回环地址 + 16;localhost;::1 + // IPv4 特殊地址 + 17;240.0.0.0;null // 保留地址 + 18;255.255.255.255;null // 广播地址 + // 唯一本地地址 + 19;null;fd00:: // 唯一本地地址 (ULA) + // A 类地址 + - 网络地址 (最小地址) + 20;0.0.0.0;null + - 最大地址 + 21;127.255.255.255;null + // B 类地址 + - 网络地址 (最小地址) + 22;128.0.0.0;null + - 最大地址 + 23;191.255.255.255;null + // C 类地址 + - 网络地址 (最小地址) + 24;192.0.0.0;null + - 最大地址 + 25;223.255.255.255;null + // D 类地址 + - 组播地址 (最小地址) + 26;224.0.0.0;ff01:: + - 最大地址 + 27;239.255.255.255;ff02::1 + // 无效的多播地址 + 28;null;ff00:: // 保留地址 + ***/ + + streamLoad { + table "fn_test_ip_nullable" + db "regression_test_nereids_function_p0" + file "fn_test_ip_special.csv" + set 'column_separator', ';' Review Comment: Why use seperator ';' ? ########## regression-test/suites/nereids_function_p0/load.groovy: ########## @@ -27,6 +27,109 @@ suite("load") { DROP TABLE IF EXISTS `fn_test_bitmap` """ + // test ipv4/ipv6 + sql """ drop table if exists fn_test_ip_nullable """ + sql """ CREATE TABLE IF NOT EXISTS fn_test_ip_nullable (id int, ip4 ipv4, ip6 ipv6) engine=olap + DISTRIBUTED BY HASH(`id`) BUCKETS 4 + properties("replication_num" = "1") """ + // make some special ip address Review Comment: It's very good to add comment for your test data. You can add comment for all data files. ########## regression-test/data/nereids_function_p0/fn_test_ip.csv: ########## @@ -0,0 +1,100 @@ +1;127.0.0.1;::1 Review Comment: You can change file name from fn_test_ip.csv to test_ip.csv, since the test data can be used not only by function tests but also by all ip tests. ########## regression-test/data/nereids_function_p0/fn_test_ip_normal.csv: ########## @@ -0,0 +1,72 @@ +29;0.0.0.1;2001:0db8:0:0:0:0:0:1 Review Comment: What's the difference between fn_test_ip_normal.csv and fn_test_ip.csv? ########## regression-test/suites/nereids_function_p0/scalar_function/IP.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("nereids_scalar_fn_IP") { + sql 'use regression_test_nereids_function_p0' + sql 'set enable_nereids_planner=true' + sql 'set enable_fallback_to_original_planner=false' + + def cidr_v6 = 64 + def cidr_v4 = 32 + // for table fn_test_ip_nullable + // test_ip_cidr_to_range_function + qt_sql_cidr_ipv6 "select id, struct_element(ipv6_cidr_to_range(ip6,$cidr_v6), 'min') as min_range, struct_element(ipv6_cidr_to_range(ip6, $cidr_v6), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv4 "select id, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'min') as min_range, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """ + qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """ + + + // test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + test { + sql 'select id, ipv4_string_to_num(ip4) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + // test ipv_num_to_string + qt_sql_num2string_ipv6 "select id, ipv6_num_to_string(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_num2string_ipv4 "select id, ipv4_num_to_string(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test INET_NTOA/INET6_NTOA + qt_sql_inet6_ntoa "select id, inet6_ntoa(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_inet_ntoa "select id, inet_ntoa(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_DEFAULT/IPV6_STRING_TO_NUM_OR_DEFAULT + qt_sql_string2num_or_default_ipv6 "select id, ipv6_string_to_num_or_default(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_default_ipv4 "select id, ipv4_string_to_num_or_default(ip4) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_NULL/IPV6_STRING_TO_NUM_OR_NULL + qt_sql_string2num_or_null_ipv6 "select id, ipv6_string_to_num_or_null(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_null_ipv4 "select id, ipv4_string_to_num_or_null(ip4) from fn_test_ip_nullable order by id" + + // test IS_IPV4_COMPAT/IS_IPV4_MAPPED + qt_sql_is_ipv4_compat "select id, is_ipv4_compat(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_mapped "select id, is_ipv4_mapped(ip6) from fn_test_ip_nullable order by id" + + // test IS_IP_ADDRESS_IN_RANGE + def cidr_prefix_v6 = '2001:db8::/32' + def cidr_prefix_v4 = '::ffff:192.168.0.4/128' + qt_sql_is_ip_address_in_range_ipv6 "select id, is_ip_address_in_range(ip6, '$cidr_prefix_v6') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_ipv4 "select id, is_ip_address_in_range(ip4, '$cidr_prefix_v4') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip6, null) from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip4, null) from fn_test_ip_nullable order by id" + + // test IS_IPV4_STRING/IS_IPV6_STRING + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip6) from fn_test_ip_nullable order by id" + + // test TO_IPV4/TO_IPV6 (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql "select id, to_ipv4(ip4) from fn_test_ip_nullable order by id" Review Comment: ditto ########## regression-test/suites/nereids_function_p0/scalar_function/IP.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("nereids_scalar_fn_IP") { + sql 'use regression_test_nereids_function_p0' + sql 'set enable_nereids_planner=true' + sql 'set enable_fallback_to_original_planner=false' + + def cidr_v6 = 64 + def cidr_v4 = 32 + // for table fn_test_ip_nullable + // test_ip_cidr_to_range_function + qt_sql_cidr_ipv6 "select id, struct_element(ipv6_cidr_to_range(ip6,$cidr_v6), 'min') as min_range, struct_element(ipv6_cidr_to_range(ip6, $cidr_v6), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv4 "select id, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'min') as min_range, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """ + qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """ + + + // test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + test { + sql 'select id, ipv4_string_to_num(ip4) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + // test ipv_num_to_string + qt_sql_num2string_ipv6 "select id, ipv6_num_to_string(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_num2string_ipv4 "select id, ipv4_num_to_string(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test INET_NTOA/INET6_NTOA + qt_sql_inet6_ntoa "select id, inet6_ntoa(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_inet_ntoa "select id, inet_ntoa(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_DEFAULT/IPV6_STRING_TO_NUM_OR_DEFAULT + qt_sql_string2num_or_default_ipv6 "select id, ipv6_string_to_num_or_default(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_default_ipv4 "select id, ipv4_string_to_num_or_default(ip4) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_NULL/IPV6_STRING_TO_NUM_OR_NULL + qt_sql_string2num_or_null_ipv6 "select id, ipv6_string_to_num_or_null(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_null_ipv4 "select id, ipv4_string_to_num_or_null(ip4) from fn_test_ip_nullable order by id" + + // test IS_IPV4_COMPAT/IS_IPV4_MAPPED + qt_sql_is_ipv4_compat "select id, is_ipv4_compat(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_mapped "select id, is_ipv4_mapped(ip6) from fn_test_ip_nullable order by id" + + // test IS_IP_ADDRESS_IN_RANGE + def cidr_prefix_v6 = '2001:db8::/32' + def cidr_prefix_v4 = '::ffff:192.168.0.4/128' + qt_sql_is_ip_address_in_range_ipv6 "select id, is_ip_address_in_range(ip6, '$cidr_prefix_v6') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_ipv4 "select id, is_ip_address_in_range(ip4, '$cidr_prefix_v4') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip6, null) from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip4, null) from fn_test_ip_nullable order by id" + + // test IS_IPV4_STRING/IS_IPV6_STRING + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip6) from fn_test_ip_nullable order by id" + + // test TO_IPV4/TO_IPV6 (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql "select id, to_ipv4(ip4) from fn_test_ip_nullable order by id" + exception "not NULL" + } + + test { + sql "select id, to_ipv6(ip6) from fn_test_ip_nullable order by id" Review Comment: ditto ########## regression-test/suites/nereids_function_p0/scalar_function/IP.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("nereids_scalar_fn_IP") { + sql 'use regression_test_nereids_function_p0' + sql 'set enable_nereids_planner=true' + sql 'set enable_fallback_to_original_planner=false' + + def cidr_v6 = 64 + def cidr_v4 = 32 + // for table fn_test_ip_nullable + // test_ip_cidr_to_range_function + qt_sql_cidr_ipv6 "select id, struct_element(ipv6_cidr_to_range(ip6,$cidr_v6), 'min') as min_range, struct_element(ipv6_cidr_to_range(ip6, $cidr_v6), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv4 "select id, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'min') as min_range, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """ + qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """ + + + // test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + test { + sql 'select id, ipv4_string_to_num(ip4) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + // test ipv_num_to_string + qt_sql_num2string_ipv6 "select id, ipv6_num_to_string(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_num2string_ipv4 "select id, ipv4_num_to_string(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test INET_NTOA/INET6_NTOA + qt_sql_inet6_ntoa "select id, inet6_ntoa(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_inet_ntoa "select id, inet_ntoa(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_DEFAULT/IPV6_STRING_TO_NUM_OR_DEFAULT + qt_sql_string2num_or_default_ipv6 "select id, ipv6_string_to_num_or_default(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_default_ipv4 "select id, ipv4_string_to_num_or_default(ip4) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_NULL/IPV6_STRING_TO_NUM_OR_NULL + qt_sql_string2num_or_null_ipv6 "select id, ipv6_string_to_num_or_null(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_null_ipv4 "select id, ipv4_string_to_num_or_null(ip4) from fn_test_ip_nullable order by id" + + // test IS_IPV4_COMPAT/IS_IPV4_MAPPED + qt_sql_is_ipv4_compat "select id, is_ipv4_compat(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_mapped "select id, is_ipv4_mapped(ip6) from fn_test_ip_nullable order by id" + + // test IS_IP_ADDRESS_IN_RANGE + def cidr_prefix_v6 = '2001:db8::/32' + def cidr_prefix_v4 = '::ffff:192.168.0.4/128' + qt_sql_is_ip_address_in_range_ipv6 "select id, is_ip_address_in_range(ip6, '$cidr_prefix_v6') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_ipv4 "select id, is_ip_address_in_range(ip4, '$cidr_prefix_v4') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip6, null) from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip4, null) from fn_test_ip_nullable order by id" + + // test IS_IPV4_STRING/IS_IPV6_STRING + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip4) from fn_test_ip_nullable order by id" Review Comment: This SQL implies `CAST(ip4 AS STRING)` since `is_ipv4_string/is_ipv6_string` need a string argument. You should add two columns ip4_str and ip6_str and use them for functions need string argument. ########## regression-test/suites/nereids_function_p0/scalar_function/IP.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("nereids_scalar_fn_IP") { + sql 'use regression_test_nereids_function_p0' + sql 'set enable_nereids_planner=true' + sql 'set enable_fallback_to_original_planner=false' + + def cidr_v6 = 64 + def cidr_v4 = 32 + // for table fn_test_ip_nullable + // test_ip_cidr_to_range_function + qt_sql_cidr_ipv6 "select id, struct_element(ipv6_cidr_to_range(ip6,$cidr_v6), 'min') as min_range, struct_element(ipv6_cidr_to_range(ip6, $cidr_v6), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv4 "select id, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'min') as min_range, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """ + qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """ + + + // test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + test { + sql 'select id, ipv4_string_to_num(ip4) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + // test ipv_num_to_string + qt_sql_num2string_ipv6 "select id, ipv6_num_to_string(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_num2string_ipv4 "select id, ipv4_num_to_string(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test INET_NTOA/INET6_NTOA + qt_sql_inet6_ntoa "select id, inet6_ntoa(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_inet_ntoa "select id, inet_ntoa(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_DEFAULT/IPV6_STRING_TO_NUM_OR_DEFAULT + qt_sql_string2num_or_default_ipv6 "select id, ipv6_string_to_num_or_default(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_default_ipv4 "select id, ipv4_string_to_num_or_default(ip4) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_NULL/IPV6_STRING_TO_NUM_OR_NULL + qt_sql_string2num_or_null_ipv6 "select id, ipv6_string_to_num_or_null(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_null_ipv4 "select id, ipv4_string_to_num_or_null(ip4) from fn_test_ip_nullable order by id" + + // test IS_IPV4_COMPAT/IS_IPV4_MAPPED + qt_sql_is_ipv4_compat "select id, is_ipv4_compat(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_mapped "select id, is_ipv4_mapped(ip6) from fn_test_ip_nullable order by id" + + // test IS_IP_ADDRESS_IN_RANGE + def cidr_prefix_v6 = '2001:db8::/32' + def cidr_prefix_v4 = '::ffff:192.168.0.4/128' + qt_sql_is_ip_address_in_range_ipv6 "select id, is_ip_address_in_range(ip6, '$cidr_prefix_v6') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_ipv4 "select id, is_ip_address_in_range(ip4, '$cidr_prefix_v4') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip6, null) from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip4, null) from fn_test_ip_nullable order by id" + + // test IS_IPV4_STRING/IS_IPV6_STRING + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip6) from fn_test_ip_nullable order by id" + + // test TO_IPV4/TO_IPV6 (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql "select id, to_ipv4(ip4) from fn_test_ip_nullable order by id" + exception "not NULL" + } + + test { + sql "select id, to_ipv6(ip6) from fn_test_ip_nullable order by id" + exception "not NULL" + } + + // test TO_IPV4_OR_DEFAULT/TO_IPV6_OR_DEFAULT + qt_sql_to_ipv6_or_default "select id, to_ipv6_or_default(ip6) from fn_test_ip_nullable order by id" Review Comment: ditto ########## regression-test/suites/nereids_function_p0/scalar_function/IP.groovy: ########## @@ -0,0 +1,101 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("nereids_scalar_fn_IP") { + sql 'use regression_test_nereids_function_p0' + sql 'set enable_nereids_planner=true' + sql 'set enable_fallback_to_original_planner=false' + + def cidr_v6 = 64 + def cidr_v4 = 32 + // for table fn_test_ip_nullable + // test_ip_cidr_to_range_function + qt_sql_cidr_ipv6 "select id, struct_element(ipv6_cidr_to_range(ip6,$cidr_v6), 'min') as min_range, struct_element(ipv6_cidr_to_range(ip6, $cidr_v6), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv4 "select id, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'min') as min_range, struct_element(ipv4_cidr_to_range(ip4, $cidr_v4), 'max') as max_range from fn_test_ip_nullable order by id" + qt_sql_cidr_ipv6_all """ select id, ipv6_cidr_to_range(ip6, 16) from fn_test_ip_nullable order by id; """ + qt_sql_cidr_ipv4_all """ select id, ipv4_cidr_to_range(ip4, 16) from fn_test_ip_nullable order by id; """ + + + // test IPV4_STRING_TO_NUM/IPV6_STRING_TO_NUM (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql 'select id, ipv6_string_to_num(ip6) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + test { + sql 'select id, ipv4_string_to_num(ip4) from fn_test_ip_nullable order by id' + exception "Null Input" + } + + // test ipv_num_to_string + qt_sql_num2string_ipv6 "select id, ipv6_num_to_string(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_num2string_ipv4 "select id, ipv4_num_to_string(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test INET_NTOA/INET6_NTOA + qt_sql_inet6_ntoa "select id, inet6_ntoa(ipv6_string_to_num_or_default(ip6)) from fn_test_ip_nullable order by id" + qt_sql_inet_ntoa "select id, inet_ntoa(ipv4_string_to_num_or_default(ip4)) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_DEFAULT/IPV6_STRING_TO_NUM_OR_DEFAULT + qt_sql_string2num_or_default_ipv6 "select id, ipv6_string_to_num_or_default(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_default_ipv4 "select id, ipv4_string_to_num_or_default(ip4) from fn_test_ip_nullable order by id" + + // test IPV4_STRING_TO_NUM_OR_NULL/IPV6_STRING_TO_NUM_OR_NULL + qt_sql_string2num_or_null_ipv6 "select id, ipv6_string_to_num_or_null(ip6) from fn_test_ip_nullable order by id" + qt_sql_string2num_or_null_ipv4 "select id, ipv4_string_to_num_or_null(ip4) from fn_test_ip_nullable order by id" + + // test IS_IPV4_COMPAT/IS_IPV4_MAPPED + qt_sql_is_ipv4_compat "select id, is_ipv4_compat(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_mapped "select id, is_ipv4_mapped(ip6) from fn_test_ip_nullable order by id" + + // test IS_IP_ADDRESS_IN_RANGE + def cidr_prefix_v6 = '2001:db8::/32' + def cidr_prefix_v4 = '::ffff:192.168.0.4/128' + qt_sql_is_ip_address_in_range_ipv6 "select id, is_ip_address_in_range(ip6, '$cidr_prefix_v6') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_ipv4 "select id, is_ip_address_in_range(ip4, '$cidr_prefix_v4') from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip6, null) from fn_test_ip_nullable order by id" + qt_sql_is_ip_address_in_range_null "select id, is_ip_address_in_range(ip4, null) from fn_test_ip_nullable order by id" + + // test IS_IPV4_STRING/IS_IPV6_STRING + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip6) from fn_test_ip_nullable order by id" + qt_sql_is_ipv6_string "select id, is_ipv6_string(ip4) from fn_test_ip_nullable order by id" + qt_sql_is_ipv4_string "select id, is_ipv4_string(ip6) from fn_test_ip_nullable order by id" + + // test TO_IPV4/TO_IPV6 (we have null value in ip4 and ip6 column in fn_test_ip_nullable table) + test { + sql "select id, to_ipv4(ip4) from fn_test_ip_nullable order by id" + exception "not NULL" + } + + test { + sql "select id, to_ipv6(ip6) from fn_test_ip_nullable order by id" + exception "not NULL" + } + + // test TO_IPV4_OR_DEFAULT/TO_IPV6_OR_DEFAULT + qt_sql_to_ipv6_or_default "select id, to_ipv6_or_default(ip6) from fn_test_ip_nullable order by id" + qt_sql_to_ipv4_or_default "select id, to_ipv4_or_default(ip4) from fn_test_ip_nullable order by id" + qt_sql_to_ipv6_or_default "select id, to_ipv6_or_default(ip4) from fn_test_ip_nullable order by id" + qt_sql_to_ipv4_or_default "select id, to_ipv4_or_default(ip6) from fn_test_ip_nullable order by id" + + // test TO_IPV4_OR_NULL/TO_IPV6_OR_NULL + qt_sql_to_ipv6_or_null "select id, to_ipv6_or_null(ip6) from fn_test_ip_nullable order by id" Review Comment: ditto -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org