You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/11/14 22:18:43 UTC

[GitHub] [pinot] agavra commented on a diff in pull request #9796: [multistage] add test for LiteralValueOperator

agavra commented on code in PR #9796:
URL: https://github.com/apache/pinot/pull/9796#discussion_r1022120753


##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/LiteralValueOperatorTest.java:
##########
@@ -0,0 +1,57 @@
+/**
+ * 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, "bar"),
+            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[]{"bar", 2});
+    Assert.assertTrue(operator.nextBlock().isEndOfStreamBlock(), "Expected EOS after reading two rows");

Review Comment:
   added, but how can you create an empty literal in first place (in SQL)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org