fix ipv4_parse function return type in SQL to be bigint instead of integer (#16942)

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

* fix default value mode
This commit is contained in:
Clint Wylie 2024-08-22 13:36:43 -07:00 committed by GitHub
parent bce60b0674
commit 2aef6ac685
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View File

@ -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();

View File

@ -16128,7 +16128,31 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
.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})
);
}