mirror of https://github.com/apache/druid.git
Handling null operand in JSON_QUERY_ARRAY (#16118)
* fix return type inference for JSON_QUERY_ARRAY to be nullable
This commit is contained in:
parent
256160aba6
commit
e9d2caccb6
|
@ -253,7 +253,7 @@ public class NestedDataOperatorConversions
|
|||
SqlTypeFamily.CHARACTER
|
||||
)
|
||||
)
|
||||
.returnTypeInference(NESTED_ARRAY_RETURN_TYPE_INFERENCE)
|
||||
.returnTypeInference(NESTED_ARRAY_RETURN_TYPE_INFERENCE.andThen(SqlTypeTransforms.FORCE_NULLABLE))
|
||||
.functionCategory(SqlFunctionCategory.SYSTEM)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -6626,6 +6626,46 @@ public class CalciteNestedDataQueryTest extends BaseCalciteQueryTest
|
|||
.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonQueryArrayNullArray()
|
||||
{
|
||||
cannotVectorize();
|
||||
testBuilder()
|
||||
.sql("SELECT JSON_QUERY_ARRAY(arrayObject, '$.') FROM druid.arrays where arrayObject is null limit 1")
|
||||
.queryContext(QUERY_CONTEXT_DEFAULT)
|
||||
.expectedQueries(
|
||||
ImmutableList.of(
|
||||
Druids.newScanQueryBuilder()
|
||||
.dataSource(DATA_SOURCE_ARRAYS)
|
||||
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||
.virtualColumns(
|
||||
expressionVirtualColumn(
|
||||
"v0",
|
||||
"null",
|
||||
ColumnType.ofArray(ColumnType.NESTED_DATA)
|
||||
)
|
||||
)
|
||||
.filters(isNull("arrayObject"))
|
||||
.columns("v0")
|
||||
.limit(1)
|
||||
.context(QUERY_CONTEXT_DEFAULT)
|
||||
.legacy(false)
|
||||
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||
.build()
|
||||
)
|
||||
)
|
||||
.expectedResults(
|
||||
NullHandling.replaceWithDefault() ?
|
||||
ImmutableList.of(new Object[]{null}) : ImmutableList.of()
|
||||
)
|
||||
.expectedSignature(
|
||||
RowSignature.builder()
|
||||
.add("EXPR$0", ColumnType.ofArray(ColumnType.NESTED_DATA))
|
||||
.build()
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnnestJsonQueryArrays()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue