mcvsubbu commented on a change in pull request #5238: Evaluate schema transform 
expressions during ingestion
URL: https://github.com/apache/incubator-pinot/pull/5238#discussion_r407813808
 
 

 ##########
 File path: 
pinot-plugins/pinot-input-format/pinot-orc/src/main/java/org/apache/pinot/plugin/inputformat/orc/ORCRecordExtractor.java
 ##########
 @@ -0,0 +1,144 @@
+/**
+ * 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.plugin.inputformat.orc;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hadoop.hive.ql.exec.vector.ColumnVector;
+import org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch;
+import org.apache.hadoop.io.BooleanWritable;
+import org.apache.hadoop.io.ByteWritable;
+import org.apache.hadoop.io.BytesWritable;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.FloatWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.LongWritable;
+import org.apache.hadoop.io.NullWritable;
+import org.apache.hadoop.io.ShortWritable;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.orc.TypeDescription;
+import org.apache.orc.mapred.OrcList;
+import org.apache.orc.mapred.OrcMapredRecordReader;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.data.readers.RecordExtractor;
+import org.apache.pinot.spi.data.readers.RecordExtractorConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Extractor for ORC records
+ */
+public class ORCRecordExtractor implements RecordExtractor<VectorizedRowBatch> 
{
+
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ORCRecordExtractor.class);
+
+  private TypeDescription _orcSchema;
+
+  @Override
+  public void init(RecordExtractorConfig recordExtractorConfig) {
+    _orcSchema = ((ORCRecordExtractorConfig) 
recordExtractorConfig).getOrcSchema();
+  }
+
+  @Override
+  public GenericRow extract(List<String> sourceFieldNames, VectorizedRowBatch 
from, GenericRow to) {
+    // TODO: use Pinot schema to fill the values to handle missing column and 
default values properly
+
+    // ORC's TypeDescription is the equivalent of a schema. The way we will 
support ORC in Pinot
+    // will be to get the top level struct that contains all our fields and 
look through its
+    // children to determine the fields in our schemas.
+    if (_orcSchema.getCategory().equals(TypeDescription.Category.STRUCT)) {
+      List<TypeDescription> orcSchemaChildren = _orcSchema.getChildren();
+      for (int i = 0; i < orcSchemaChildren.size(); i++) {
+        // Get current column in schema
+        String currColumnName = _orcSchema.getFieldNames().get(i);
+        if (!sourceFieldNames.contains(currColumnName)) {
+          LOGGER.warn("Skipping column {} because it is not in source 
columns", currColumnName);
 
 Review comment:
   Please remove this log message, it will show up in every input message.  We 
don't seem to be logging this in other extractors either

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to