You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ro...@apache.org on 2022/11/15 16:29:36 UTC
[pinot] branch master updated: [multistage] add test for LiteralValueOperator (#9796)
This is an automated email from the ASF dual-hosted git repository.
rongr 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 47c8f18436 [multistage] add test for LiteralValueOperator (#9796)
47c8f18436 is described below
commit 47c8f184365d6ffde870f94285747b9e009c7c15
Author: Almog Gavra <al...@gmail.com>
AuthorDate: Tue Nov 15 08:29:30 2022 -0800
[multistage] add test for LiteralValueOperator (#9796)
* add test for LiteralValueOperator
* add empty tests
---
.../runtime/operator/LiteralValueOperatorTest.java | 71 ++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LiteralValueOperatorTest.java b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LiteralValueOperatorTest.java
new file mode 100644
index 0000000000..663caf2272
--- /dev/null
+++ b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LiteralValueOperatorTest.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.runtime.operator;
+
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.query.planner.logical.RexExpression;
+import org.apache.pinot.query.runtime.blocks.TransferableBlock;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+public class LiteralValueOperatorTest {
+
+ @Test
+ public void shouldReturnLiteralBlock() {
+ // Given:
+ DataSchema schema = new DataSchema(new String[]{"sLiteral", "iLiteral"},
+ new ColumnDataType[]{ColumnDataType.STRING, ColumnDataType.INT});
+ List<List<RexExpression>> literals = ImmutableList.of(
+ ImmutableList.of(
+ new RexExpression.Literal(DataType.STRING, "foo"),
+ new RexExpression.Literal(DataType.INT, 1)),
+ ImmutableList.of(
+ new RexExpression.Literal(DataType.STRING, ""),
+ new RexExpression.Literal(DataType.INT, 2))
+ );
+ LiteralValueOperator operator = new LiteralValueOperator(schema, literals);
+
+ // When:
+ TransferableBlock transferableBlock = operator.nextBlock();
+
+ // Then:
+ Assert.assertEquals(transferableBlock.getContainer().get(0), new Object[]{"foo", 1});
+ Assert.assertEquals(transferableBlock.getContainer().get(1), new Object[]{"", 2});
+ Assert.assertTrue(operator.nextBlock().isEndOfStreamBlock(), "Expected EOS after reading two rows");
+ }
+
+ @Test
+ public void shouldHandleEmptyLiteralRows() {
+ // Given:
+ DataSchema schema = new DataSchema(new String[]{}, new ColumnDataType[]{});
+ List<List<RexExpression>> literals = ImmutableList.of(ImmutableList.of());
+ LiteralValueOperator operator = new LiteralValueOperator(schema, literals);
+
+ // When:
+ TransferableBlock transferableBlock = operator.nextBlock();
+
+ // Then:
+ Assert.assertEquals(transferableBlock.getContainer().get(0), new Object[]{});
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org