gortiz commented on code in PR #16257:
URL: https://github.com/apache/pinot/pull/16257#discussion_r2200843236


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/ErrorOperator.java:
##########
@@ -0,0 +1,80 @@
+/**
+ * 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 java.util.List;
+import org.apache.pinot.common.datatable.StatMap;
+import org.apache.pinot.query.runtime.blocks.ErrorMseBlock;
+import org.apache.pinot.query.runtime.blocks.MseBlock;
+import org.apache.pinot.query.runtime.plan.OpChainExecutionContext;
+import org.apache.pinot.spi.exception.QueryErrorCode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ErrorOperator extends MultiStageOperator {
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ErrorOperator.class);
+  private static final String EXPLAIN_NAME = "ERROR";
+  private final QueryErrorCode _errorCode;
+  private final String _errorMessage;
+  private final StatMap<LiteralValueOperator.StatKey> _statMap = new 
StatMap<>(LiteralValueOperator.StatKey.class);
+
+  public ErrorOperator(OpChainExecutionContext context, QueryErrorCode 
errorCode,
+      String errorMessage) {
+    super(context);
+    _errorCode = errorCode;
+    _errorMessage = errorMessage;
+  }
+
+  @Override
+  protected MseBlock getNextBlock() {
+    return ErrorMseBlock.fromError(_errorCode, _errorMessage);
+  }
+
+  @Override
+  public String toExplainString() {
+    return EXPLAIN_NAME;
+  }
+
+  @Override
+  protected Logger logger() {
+    return LOGGER;
+  }
+
+  @Override
+  public void registerExecution(long time, int numRows) {
+    _statMap.merge(LiteralValueOperator.StatKey.EXECUTION_TIME_MS, time);
+    _statMap.merge(LiteralValueOperator.StatKey.EMITTED_ROWS, numRows);
+  }
+
+  @Override
+  public Type getOperatorType() {
+    return Type.LITERAL;
+  }
+
+  @Override
+  public List<MultiStageOperator> getChildOperators() {
+    return List.of();
+  }

Review Comment:
   That is a good idea. I'm applying it on the next commit



-- 
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-unsubscr...@pinot.apache.org

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


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

Reply via email to