paul-rogers commented on a change in pull request #1914: DRILL-7458: Base framework for storage plugins URL: https://github.com/apache/drill/pull/1914#discussion_r369355344
########## File path: exec/java-exec/src/test/java/org/apache/drill/exec/store/base/DummyStoragePlugin.java ########## @@ -0,0 +1,151 @@ +/* + * 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.base; + +import java.util.List; +import java.util.Set; + +import org.apache.drill.common.exceptions.ChildErrorContext; +import org.apache.drill.common.exceptions.UserException; +import org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.common.types.TypeProtos.MinorType; +import org.apache.drill.common.types.Types; +import org.apache.drill.exec.metastore.MetadataProviderManager; +import org.apache.drill.exec.ops.OptimizerRulesContext; +import org.apache.drill.exec.physical.impl.scan.framework.ManagedReader; +import org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework; +import org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ReaderFactory; +import org.apache.drill.exec.physical.impl.scan.framework.ManagedScanFramework.ScanFrameworkBuilder; +import org.apache.drill.exec.physical.impl.scan.framework.SchemaNegotiator; +import org.apache.drill.exec.planner.PlannerPhase; +import org.apache.drill.exec.server.DrillbitContext; +import org.apache.drill.exec.server.options.OptionManager; +import org.apache.drill.exec.server.options.SessionOptionManager; +import org.apache.drill.exec.store.StoragePluginOptimizerRule; +import org.apache.drill.exec.store.base.filter.RelOp; +import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableSet; + +import com.fasterxml.jackson.core.type.TypeReference; + +/** + * "Test mule" for the base storage plugin and the filter push down + * framework. + */ + +public class DummyStoragePlugin + extends BaseStoragePlugin<DummyStoragePluginConfig> { + + private static class DummyScanFactory extends + BaseScanFactory<DummyStoragePlugin, DummyScanSpec, DummyGroupScan, DummySubScan> { + + @Override + public DummyGroupScan newGroupScan(DummyStoragePlugin storagePlugin, + String userName, DummyScanSpec scanSpec, + SessionOptionManager sessionOptions, + MetadataProviderManager metadataProviderManager) { + + // Force user name to "dummy" so golden and actual test files are stable + return new DummyGroupScan(storagePlugin, "dummy", scanSpec); + } + + @Override + public DummyGroupScan groupWithColumns(DummyGroupScan group, + List<SchemaPath> columns) { + return new DummyGroupScan(group, columns); + } + + @Override + public ScanFrameworkBuilder scanBuilder(DummyStoragePlugin storagePlugin, + OptionManager options, DummySubScan subScan) { + ScanFrameworkBuilder builder = new ScanFrameworkBuilder(); Review comment: We can probably make this easier. Somehow the plugin has to obtain a schema; we don't seem to provide a general-purpose registry. Maybe we need one that works like the storage and format plugin registries? Presumably, the schema factory would look up the schema at the point that it looks up the table name. It would be passed (via the scan spec) to the group scan, and from there to the sub scan. Then, in this method, given a schema in the sub scan, we add one line: ``` builder.typeConverterBuilder().providedSchema(subScan.getSchema()); ``` ---------------------------------------------------------------- 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
