This is an automated email from the ASF dual-hosted git repository.
soumyava pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 972937659d5 Fixing return type for IPV4 (#15916)
972937659d5 is described below
commit 972937659d5804c9b7e975208eba2b32be5737d7
Author: Soumyava <[email protected]>
AuthorDate: Thu Apr 4 08:49:50 2024 -0700
Fixing return type for IPV4 (#15916)
* Fixing return type for IPV4
* Update ipv4match
---
.../IPv4AddressParseOperatorConversion.java | 4 +--
.../apache/druid/sql/calcite/CalciteQueryTest.java | 41 ++++++++++++++++++++++
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git
a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/IPv4AddressParseOperatorConversion.java
b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/IPv4AddressParseOperatorConversion.java
index 1981a91b4bb..297f10c63ad 100644
---
a/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/IPv4AddressParseOperatorConversion.java
+++
b/sql/src/main/java/org/apache/druid/sql/calcite/expression/builtin/IPv4AddressParseOperatorConversion.java
@@ -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();
diff --git
a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
index 887c6a5e446..bc21586ac8c 100644
--- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
+++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
@@ -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})
+ );
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]