[
https://issues.apache.org/jira/browse/DRILL-7177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16959669#comment-16959669
]
ASF GitHub Bot commented on DRILL-7177:
---------------------------------------
arina-ielchiieva commented on pull request #1749: DRILL-7177: Format Plugin for
Excel Files
URL: https://github.com/apache/drill/pull/1749#discussion_r339008989
##########
File path:
contrib/format-excel/src/main/java/org/apache/drill/exec/store/excel/ExcelFormatPlugin.java
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.drill.exec.store.excel;
+
+import org.apache.drill.common.exceptions.ExecutionSetupException;
+import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.common.types.Types;
+import
org.apache.drill.exec.physical.impl.scan.file.FileScanFramework.FileReaderFactory;
+import
org.apache.drill.exec.physical.impl.scan.file.FileScanFramework.FileScanBuilder;
+import
org.apache.drill.exec.physical.impl.scan.file.FileScanFramework.FileSchemaNegotiator;
+
+import org.apache.drill.exec.physical.impl.scan.framework.ManagedReader;
+import org.apache.drill.exec.proto.UserBitShared;
+import org.apache.drill.exec.server.DrillbitContext;
+import org.apache.drill.exec.server.options.OptionManager;
+import org.apache.drill.exec.store.dfs.easy.EasyFormatPlugin;
+import org.apache.drill.exec.store.dfs.easy.EasySubScan;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.drill.exec.store.excel.ExcelBatchReader.ExcelReaderConfig;
+import org.slf4j.Logger;
+
+
+public class ExcelFormatPlugin extends EasyFormatPlugin<ExcelFormatConfig> {
+
+ protected static final String DEFAULT_NAME = "excel";
+ private static final Logger logger =
org.slf4j.LoggerFactory.getLogger(ExcelFormatPlugin.class);
+
+ private static class ExcelReaderFactory extends FileReaderFactory {
+ private final ExcelBatchReader.ExcelReaderConfig readerConfig;
+
+ public ExcelReaderFactory(ExcelReaderConfig config) {
+ readerConfig = config;
+ }
+
+ @Override
+ public ManagedReader<? extends FileSchemaNegotiator> newReader() {
+ return new ExcelBatchReader(readerConfig);
+ }
+ }
+
+ public ExcelFormatPlugin(String name, DrillbitContext context,
+ Configuration fsConf, StoragePluginConfig
storageConfig,
+ ExcelFormatConfig formatConfig) {
+ super(name, easyConfig(fsConf, formatConfig), context, storageConfig,
formatConfig);
+ }
+
+ private static EasyFormatConfig easyConfig(Configuration fsConf,
ExcelFormatConfig pluginConfig) {
+ EasyFormatConfig config = new EasyFormatConfig();
+ config.readable = true;
+ config.writable = false;
+ config.blockSplittable = false;
+ config.compressible = true;
+ config.supportsProjectPushdown = true;
+ config.extensions = pluginConfig.getExtensions();
+ config.fsConf = fsConf;
+ config.defaultName = DEFAULT_NAME;
+ config.readerOperatorType =
UserBitShared.CoreOperatorType.EXCEL_SUB_SCAN_VALUE;
+ config.useEnhancedScan = true;
+ return config;
+ }
+
+ @Override
+ public ManagedReader<? extends FileSchemaNegotiator> newBatchReader(
+ EasySubScan scan, OptionManager options) throws ExecutionSetupException {
+ return new ExcelBatchReader(formatConfig.getReaderConfig(this));
+ }
+
+ @Override
+ protected FileScanBuilder frameworkBuilder(OptionManager options,
EasySubScan scan) throws ExecutionSetupException {
+ FileScanBuilder builder = new FileScanBuilder();
+ ExcelReaderConfig readerConfig = new ExcelReaderConfig(this);
+
+ verifyConfigOptions(readerConfig);
+ builder.setReaderFactory(new ExcelReaderFactory(readerConfig));
+
+ initScanBuilder(builder, scan);
+ builder.setNullType(Types.optional(TypeProtos.MinorType.VARCHAR));
+ return builder;
+ }
+
+ /**
+ * This function verifies that the user entered valid user configuration
options. Specifically it verifies that:
+ * <ul>
+ * <li>the lastColumn is greater than the first column</li>
+ * <li>The lastColumn is not zero</li>
+ * <li>firstColumn is greater than zero</li>
+ * <li>lastColumn is greater than zero</li>
+ * <li>The headerRow index is less than the lastRow index</li>
+ * </ul>
+ *
+ * @param readerConfig
Review comment:
please add description to avoid warning in the IDE.
----------------------------------------------------------------
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]
> Format Plugin for Excel Files
> -----------------------------
>
> Key: DRILL-7177
> URL: https://issues.apache.org/jira/browse/DRILL-7177
> Project: Apache Drill
> Issue Type: Improvement
> Affects Versions: 1.17.0
> Reporter: Charles Givre
> Assignee: Charles Givre
> Priority: Major
> Labels: doc-impacting
> Fix For: 1.17.0
>
>
> This pull request adds the functionality which enables Drill to query
> Microsoft Excel files.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)