[ 
https://issues.apache.org/jira/browse/DRILL-4728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15410222#comment-15410222
 ] 

ASF GitHub Bot commented on DRILL-4728:
---------------------------------------

Github user vkorukanti commented on a diff in the pull request:

    https://github.com/apache/drill/pull/527#discussion_r73769668
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/MetadataProvider.java
 ---
    @@ -0,0 +1,451 @@
    +/**
    + * 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
    + * <p/>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p/>
    + * 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.work.metadata;
    +
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaConstants.CATS_COL_CATALOG_NAME;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaConstants.SCHS_COL_SCHEMA_NAME;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaConstants.SHRD_COL_TABLE_NAME;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaConstants.SHRD_COL_TABLE_SCHEMA;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaTableType.CATALOGS;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaTableType.COLUMNS;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaTableType.SCHEMATA;
    +import static 
org.apache.drill.exec.store.ischema.InfoSchemaTableType.TABLES;
    +
    +import java.util.UUID;
    +
    +import org.apache.calcite.schema.SchemaPlus;
    +import org.apache.drill.common.exceptions.ErrorHelper;
    +import org.apache.drill.exec.ops.ViewExpansionContext;
    +import org.apache.drill.exec.proto.UserBitShared.DrillPBError;
    +import org.apache.drill.exec.proto.UserBitShared.DrillPBError.ErrorType;
    +import org.apache.drill.exec.proto.UserProtos.CatalogMetadata;
    +import org.apache.drill.exec.proto.UserProtos.ColumnMetadata;
    +import org.apache.drill.exec.proto.UserProtos.GetCatalogsResp;
    +import org.apache.drill.exec.proto.UserProtos.GetCatalogsReq;
    +import org.apache.drill.exec.proto.UserProtos.GetColumnsReq;
    +import org.apache.drill.exec.proto.UserProtos.GetColumnsResp;
    +import org.apache.drill.exec.proto.UserProtos.GetSchemasReq;
    +import org.apache.drill.exec.proto.UserProtos.GetSchemasResp;
    +import org.apache.drill.exec.proto.UserProtos.GetTablesReq;
    +import org.apache.drill.exec.proto.UserProtos.GetTablesResp;
    +import org.apache.drill.exec.proto.UserProtos.LikeFilter;
    +import org.apache.drill.exec.proto.UserProtos.RequestStatus;
    +import org.apache.drill.exec.proto.UserProtos.RpcType;
    +import org.apache.drill.exec.proto.UserProtos.SchemaMetadata;
    +import org.apache.drill.exec.proto.UserProtos.TableMetadata;
    +import org.apache.drill.exec.rpc.Response;
    +import org.apache.drill.exec.rpc.ResponseSender;
    +import org.apache.drill.exec.rpc.user.UserServer.UserClientConnection;
    +import org.apache.drill.exec.rpc.user.UserSession;
    +import org.apache.drill.exec.server.DrillbitContext;
    +import org.apache.drill.exec.server.options.OptionValue;
    +import org.apache.drill.exec.store.SchemaConfig.SchemaConfigInfoProvider;
    +import org.apache.drill.exec.store.SchemaTreeProvider;
    +import org.apache.drill.exec.store.ischema.InfoSchemaConstants;
    +import org.apache.drill.exec.store.ischema.InfoSchemaFilter;
    +import 
org.apache.drill.exec.store.ischema.InfoSchemaFilter.ConstantExprNode;
    +import org.apache.drill.exec.store.ischema.InfoSchemaFilter.ExprNode;
    +import org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode;
    +import 
org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode;
    +import org.apache.drill.exec.store.ischema.InfoSchemaTableType;
    +import org.apache.drill.exec.store.ischema.Records.Catalog;
    +import org.apache.drill.exec.store.ischema.Records.Column;
    +import org.apache.drill.exec.store.ischema.Records.Schema;
    +import org.apache.drill.exec.store.ischema.Records.Table;
    +import org.apache.drill.exec.store.pojo.PojoRecordReader;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.ImmutableList;
    +
    +/**
    + * Contains worker {@link Runnable} classes for providing the metadata and 
related helper methods.
    + */
    +public class MetadataProvider {
    +  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(MetadataProvider.class);
    +
    +  private static final String LIKE_FUNCTION = "like";
    +  private static final String AND_FUNCTION = "booleanand";
    +  private static final String OR_FUNCTION = "booleanor";
    +
    +  /**
    +   * Super class for all metadata provider runnable classes.
    +   */
    +  public abstract static class MetadataRunnable implements Runnable {
    +    protected final UserClientConnection connection;
    +    protected final DrillbitContext dContext;
    +    protected final ResponseSender responseSender;
    +
    +    protected MetadataRunnable(final UserClientConnection connection, 
final DrillbitContext dContext,
    +        final ResponseSender responseSender) {
    +      this.connection = Preconditions.checkNotNull(connection);
    +      this.dContext = Preconditions.checkNotNull(dContext);
    +      this.responseSender = Preconditions.checkNotNull(responseSender);
    +    }
    +  }
    +
    +  /**
    +   * Runnable that fetches the catalog metadata for given {@link 
GetCatalogsReq} and sends response at the end.
    +   */
    +  public static class CatalogsProvider extends MetadataRunnable {
    +    private final GetCatalogsReq req;
    +
    +    public CatalogsProvider(final UserClientConnection connection, final 
DrillbitContext dContext,
    +        final GetCatalogsReq req, final ResponseSender responseSender) {
    +      super(connection, dContext, responseSender);
    +      this.req = Preconditions.checkNotNull(req);
    +    }
    +
    +    @Override
    +    public void run() {
    +      final GetCatalogsResp.Builder respBuilder = 
GetCatalogsResp.newBuilder();
    +
    +      final InfoSchemaFilter filter = createInfoSchemaFilter(
    +          req.hasCatalogNameFilter() ? req.getCatalogNameFilter() : null, 
null, null, null);
    +
    +      try (SchemaTreeProvider schemaTreeProvider = new 
SchemaTreeProvider(dContext)) {
    --- End diff --
    
    we can't reuse SchemaTreeProviders.


> Add support for new metadata fetch APIs
> ---------------------------------------
>
>                 Key: DRILL-4728
>                 URL: https://issues.apache.org/jira/browse/DRILL-4728
>             Project: Apache Drill
>          Issue Type: Sub-task
>          Components: Metadata
>            Reporter: Venki Korukanti
>            Assignee: Venki Korukanti
>             Fix For: 1.8.0
>
>
> Please see the doc attached to the parent JIRA DRILL-4714 for details on APIs.
> Add support for following APIs (including {{protobuf}} messages, server 
> handling code and Java client APIs)
> {code}
>    List<Catalog> getCatalogs(Filter catalogNameFilter)
>    List<Schema> getSchemas(
>       Filter catalogNameFilter,
>       Filter schemaNameFilter
>    )
>    List<Table> getTables(
>       Filter catalogNameFilter,
>       Filter schemaNameFilter,
>      Filter tableNameFilter
>    )
>    List<Column> getColumns(
>       Filter catalogNameFilter,
>       Filter schemaNameFilter,
>       Filter tableNameFilter,
>       Filter columnNameFilter
>    )
> {code}
> Note: native client changes are not going to be included in this patch. Will 
> file a separate JIRA.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to