mirror of https://github.com/apache/druid.git
Fixing return type for IPV4 (#15916)
* Fixing return type for IPV4 * Update ipv4match
This commit is contained in:
parent
75fb57ed6e
commit
972937659d
|
@ -23,8 +23,8 @@ import org.apache.calcite.sql.SqlFunction;
|
|||
import org.apache.calcite.sql.SqlFunctionCategory;
|
||||
import org.apache.calcite.sql.SqlOperator;
|
||||
import org.apache.calcite.sql.type.OperandTypes;
|
||||
import org.apache.calcite.sql.type.ReturnTypes;
|
||||
import org.apache.calcite.sql.type.SqlTypeFamily;
|
||||
import org.apache.calcite.sql.type.SqlTypeName;
|
||||
import org.apache.druid.java.util.common.StringUtils;
|
||||
import org.apache.druid.query.expression.IPv4AddressParseExprMacro;
|
||||
import org.apache.druid.sql.calcite.expression.DirectOperatorConversion;
|
||||
|
@ -39,7 +39,7 @@ public class IPv4AddressParseOperatorConversion extends DirectOperatorConversion
|
|||
OperandTypes.family(SqlTypeFamily.STRING),
|
||||
OperandTypes.family(SqlTypeFamily.INTEGER)
|
||||
))
|
||||
.returnTypeInference(ReturnTypes.INTEGER_NULLABLE)
|
||||
.returnTypeNullable(SqlTypeName.INTEGER)
|
||||
.functionCategory(SqlFunctionCategory.USER_DEFINED_FUNCTION)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -15509,4 +15509,45 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIpv4ParseWithNullableType()
|
||||
{
|
||||
testQuery(
|
||||
"select ipv4_parse('1.2.3') from (values(1)) as t(col)",
|
||||
NullHandling.sqlCompatible() ?
|
||||
ImmutableList.of(
|
||||
Druids.newScanQueryBuilder()
|
||||
.dataSource(InlineDataSource.fromIterable(
|
||||
ImmutableList.of(new Object[]{null}),
|
||||
RowSignature.builder()
|
||||
.add("EXPR$0", ColumnType.LONG)
|
||||
.build()
|
||||
))
|
||||
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||
.columns("EXPR$0")
|
||||
.context(QUERY_CONTEXT_DEFAULT)
|
||||
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||
.legacy(false)
|
||||
.build()
|
||||
) :
|
||||
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", "0", ColumnType.LONG))
|
||||
.context(QUERY_CONTEXT_DEFAULT)
|
||||
.resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||
.legacy(false)
|
||||
.build()
|
||||
),
|
||||
ImmutableList.of(NullHandling.sqlCompatible() ? new Object[]{null} : new Object[]{0})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue