Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed May 22, 2024
1 parent b699cf3 commit 8cfddb9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 192 deletions.
2 changes: 2 additions & 0 deletions be/src/vec/functions/function_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "vec/functions/function_ip.h"

#include "vec/functions/simple_function_factory.h"

namespace doris::vectorized {

void register_function_ip(SimpleFunctionFactory& factory) {
Expand Down
184 changes: 20 additions & 164 deletions be/src/vec/functions/function_ip.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public class Ipv6NumToString extends ScalarFunction
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
FunctionSignature.ret(StringType.INSTANCE).args(StringType.INSTANCE),
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IPv6Type.INSTANCE),
FunctionSignature.ret(StringType.INSTANCE).args(IPv6Type.INSTANCE));
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(IPv6Type.INSTANCE));

public Ipv6NumToString(Expression arg0) {
super("ipv6_num_to_string", arg0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import org.apache.doris.catalog.FunctionSignature;
import org.apache.doris.nereids.trees.expressions.Expression;
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNotNullable;
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BooleanType;
Expand All @@ -36,7 +36,7 @@
* scalar function `is_ip_address_in_range`
*/
public class IsIpAddressInRange extends ScalarFunction
implements BinaryExpression, ExplicitlyCastableSignature, AlwaysNotNullable {
implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable {

public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BooleanType.INSTANCE).args(VarcharType.SYSTEM_DEFAULT, VarcharType.SYSTEM_DEFAULT),
Expand Down
13 changes: 6 additions & 7 deletions gensrc/script/doris_builtins_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,6 @@
[['ipv6_num_to_string','inet6_ntoa'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
[['ipv6_num_to_string','inet6_ntoa'], 'STRING', ['STRING'], 'ALWAYS_NULLABLE'],
[['ipv6_num_to_string','inet6_ntoa'], 'VARCHAR', ['IPV6'], 'ALWAYS_NULLABLE'],
[['ipv6_num_to_string','inet6_ntoa'], 'STRING', ['IPV6'], 'ALWAYS_NULLABLE'],
[['ipv6_string_to_num'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'],
[['ipv6_string_to_num'], 'STRING', ['STRING'], 'ALWAYS_NOT_NULLABLE'],
[['ipv6_string_to_num_or_default'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'],
Expand All @@ -2057,12 +2056,12 @@
[['is_ipv4_string'], 'BOOLEAN', ['STRING'], ''],
[['is_ipv6_string'], 'BOOLEAN', ['VARCHAR'], ''],
[['is_ipv6_string'], 'BOOLEAN', ['STRING'], ''],
[['is_ip_address_in_range'], 'BOOLEAN', ['VARCHAR', 'VARCHAR'], 'ALWAYS_NOT_NULLABLE'],
[['is_ip_address_in_range'], 'BOOLEAN', ['STRING', 'STRING'], 'ALWAYS_NOT_NULLABLE'],
[['ipv4_cidr_to_range'], 'STRUCT<IPV4, IPV4>', ['IPV4', 'SMALLINT'], ''],
[['ipv6_cidr_to_range'], 'STRUCT<IPV6, IPV6>', ['IPV6', 'SMALLINT'], ''],
[['ipv6_cidr_to_range'], 'STRUCT<IPV6, IPV6>', ['VARCHAR', 'SMALLINT'], ''],
[['ipv6_cidr_to_range'], 'STRUCT<IPV6, IPV6>', ['STRING', 'SMALLINT'], ''],
[['is_ip_address_in_range'], 'BOOLEAN', ['VARCHAR', 'VARCHAR'], 'DEPEND_ON_ARGUMENT'],
[['is_ip_address_in_range'], 'BOOLEAN', ['STRING', 'STRING'], 'DEPEND_ON_ARGUMENT'],
[['ipv4_cidr_to_range'], 'STRUCT<IPV4, IPV4>', ['IPV4', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'],
[['ipv6_cidr_to_range'], 'STRUCT<IPV6, IPV6>', ['IPV6', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'],
[['ipv6_cidr_to_range'], 'STRUCT<IPV6, IPV6>', ['VARCHAR', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'],
[['ipv6_cidr_to_range'], 'STRUCT<IPV6, IPV6>', ['STRING', 'SMALLINT'], 'DEPEND_ON_ARGUMENT'],
[['to_ipv4'], 'IPV4', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'],
[['to_ipv4'], 'IPV4', ['STRING'], 'ALWAYS_NOT_NULLABLE'],
[['to_ipv4_or_default'], 'IPV4', ['VARCHAR'], 'ALWAYS_NOT_NULLABLE'],
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 --
1 true
2 false
Expand Down Expand Up @@ -80,4 +81,14 @@
23 false
24 false
25 false
26 false
26 false

-- !sql --
\N

-- !sql --
\N

-- !sql --
\N

Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,9 @@ suite("test_is_ip_address_in_range_function") {
// scalar vs vector
qt_sql "select id, is_ip_address_in_range('192.168.100.0', cidr) from test_is_ip_address_in_range_function order by id"

test {
sql "SELECT is_ip_address_in_range('::ffff:192.168.0.1', NULL)"
// check exception message contains
exception "The arguments of function is_ip_address_in_range must be String, not NULL"
}
qt_sql "SELECT is_ip_address_in_range('::ffff:192.168.0.1', NULL)"

test {
sql "SELECT is_ip_address_in_range(NULL, '::ffff:192.168.0.4/128')"
// check exception message contains
exception "The arguments of function is_ip_address_in_range must be String, not NULL"
}
qt_sql "SELECT is_ip_address_in_range(NULL, '::ffff:192.168.0.4/128')"

test {
sql "SELECT is_ip_address_in_range(NULL, NULL)"
// check exception message contains
exception "The arguments of function is_ip_address_in_range must be String, not NULL"
}
sql """ DROP TABLE IF EXISTS test_is_ip_address_in_range_function """
qt_sql "SELECT is_ip_address_in_range(NULL, NULL)"
}

0 comments on commit 8cfddb9

Please sign in to comment.