You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2023/06/23 06:44:45 UTC
[pinot] branch master updated: Support NULL literal selection. (#10962)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new f903314645 Support NULL literal selection. (#10962)
f903314645 is described below
commit f90331464549e85da8c9c76e5ad8cb92f9cbd2aa
Author: Shen Yu <sh...@startree.ai>
AuthorDate: Thu Jun 22 23:44:38 2023 -0700
Support NULL literal selection. (#10962)
---
.../apache/pinot/core/common/RowBasedBlockValueFetcher.java | 11 +++++++++++
.../pinot/core/query/selection/SelectionOperatorUtils.java | 6 ++++++
.../pinot/integration/tests/NullHandlingIntegrationTest.java | 12 ++++++++++++
3 files changed, 29 insertions(+)
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/common/RowBasedBlockValueFetcher.java b/pinot-core/src/main/java/org/apache/pinot/core/common/RowBasedBlockValueFetcher.java
index 64a3f6a788..21c6d34f04 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/common/RowBasedBlockValueFetcher.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/common/RowBasedBlockValueFetcher.java
@@ -67,6 +67,8 @@ public class RowBasedBlockValueFetcher {
return new StringSingleValueFetcher(blockValSet.getStringValuesSV());
case BYTES:
return new BytesValueFetcher(blockValSet.getBytesValuesSV());
+ case UNKNOWN:
+ return new UnknownValueFetcher();
default:
throw new IllegalStateException("Unsupported value type: " + storedType + " for single-value column");
}
@@ -235,4 +237,13 @@ public class RowBasedBlockValueFetcher {
return _values[docId];
}
}
+
+ private static class UnknownValueFetcher implements ValueFetcher {
+ UnknownValueFetcher() {
+ }
+
+ public Object getValue(int docId) {
+ return null;
+ }
+ }
}
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java
index 5dc0bb5fbc..66bbefb3d1 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java
@@ -315,6 +315,9 @@ public class SelectionOperatorUtils {
case BYTES:
dataTableBuilder.setColumn(i, (ByteArray) columnValue);
break;
+ case UNKNOWN:
+ dataTableBuilder.setColumn(i, (Object) null);
+ break;
// Multi-value column
case INT_ARRAY:
@@ -387,6 +390,9 @@ public class SelectionOperatorUtils {
case BYTES:
row[i] = dataTable.getBytes(rowId, i);
break;
+ case UNKNOWN:
+ row[i] = null;
+ break;
// Multi-value column
case INT_ARRAY:
diff --git a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
index 5d8be32726..f1a66d7135 100644
--- a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
+++ b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
@@ -326,4 +326,16 @@ public class NullHandlingIntegrationTest extends BaseClusterIntegrationTestSet {
testQuery(pinotQuery, h2Query);
}
+
+ @Test
+ public void testSelectNullLiteral() throws Exception {
+ // Need to also select an identifier column to skip the all literal query optimization which returns without
+ // querying the segment.
+ String sqlQuery = "SELECT NULL, salary FROM mytable OPTION(enableNullHandling=true)";
+
+ JsonNode response = postQuery(sqlQuery, _brokerBaseApiUrl);
+
+ JsonNode rows = response.get("resultTable").get("rows");
+ assertEquals(rows.get(0).get(0).asText(), "null");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org