Skip to content

Commit

Permalink
fix ipv4_parse function return type in SQL to be bigint instead of in…
Browse files Browse the repository at this point in the history
…teger (#16942)

* fix ipv4_parse function return type in SQL to be bigint instead of integer

* fix default value mode
  • Loading branch information
clintropolis authored Aug 22, 2024
1 parent bce60b0 commit 2aef6ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class IPv4AddressParseOperatorConversion extends DirectOperatorConversion
OperandTypes.family(SqlTypeFamily.STRING),
OperandTypes.family(SqlTypeFamily.INTEGER)
))
.returnTypeNullable(SqlTypeName.INTEGER)
.returnTypeNullable(SqlTypeName.BIGINT)
.functionCategory(SqlFunctionCategory.USER_DEFINED_FUNCTION)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16128,7 +16128,31 @@ public void testIpv4ParseWithNullableType()
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
.build()
),
ImmutableList.of(NullHandling.sqlCompatible() ? new Object[]{null} : new Object[]{0})
ImmutableList.of(NullHandling.sqlCompatible() ? new Object[]{null} : new Object[]{0L})
);
}

@Test
public void testIpv4ParseWithBigintOutput()
{
testQuery(
"select ipv4_parse('192.168.0.1') from (values(1)) as t(col)",
ImmutableList.of(
Druids.newScanQueryBuilder()
.dataSource(InlineDataSource.fromIterable(
ImmutableList.of(new Object[]{1L}),
RowSignature.builder()
.add("col", ColumnType.LONG)
.build()
))
.intervals(querySegmentSpec(Filtration.eternity()))
.columns("v0")
.virtualColumns(expressionVirtualColumn("v0", "3232235521", ColumnType.LONG))
.context(QUERY_CONTEXT_DEFAULT)
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
.build()
),
ImmutableList.of(new Object[]{3232235521L})
);
}

Expand Down

0 comments on commit 2aef6ac

Please sign in to comment.