class HiveMetadataFetcher extends BasePlugin implements MetadataFetcher {

    @Override
    public List<Metadata> getMetadata(String pattern) throws Exception {

        boolean ignoreErrors = false;
        List<Metadata.Item> tblsDesc = hiveClientWrapper.extractTablesFromPattern(client, pattern);

        if (tblsDesc == null || tblsDesc.isEmpty()) {
            LOG.warn("No tables found for the given pattern: " + pattern);
            return null;
        }

        List<Metadata> metadataList = new ArrayList<>();

        if (tblsDesc.size() > 1) {
            ignoreErrors = true;
        }

        for (Metadata.Item tblDesc : tblsDesc) {
            try {
                Metadata metadata = new Metadata(tblDesc);
                Table tbl = hiveClientWrapper.getHiveTable(client, tblDesc);
                hiveClientWrapper.getSchema(tbl, metadata);
                boolean hasComplexTypes = hiveClientWrapper.hasComplexTypes(metadata);
                metadataList.add(metadata);
                List<Partition> tablePartitions = client.listPartitionsByFilter(tblDesc.getPath(), tblDesc.getName(), "", (short) -1);
                Set<OutputFormat> formats = new HashSet<>();
                //If table has partitions - find out all formats
                for (Partition tablePartition : tablePartitions) {
                    String inputFormat = tablePartition.getSd().getInputFormat();
                    OutputFormat outputFormat = getOutputFormat(inputFormat, hasComplexTypes);
                    formats.add(outputFormat);
                }
                //If table has no partitions - get single format of table
                if (tablePartitions.size() == 0) {
                    String inputFormat = tbl.getSd().getInputFormat();
                    OutputFormat outputFormat = getOutputFormat(inputFormat, hasComplexTypes);
                    formats.add(outputFormat);
                }
                metadata.setOutputFormats(formats);
                Map<String, String> outputParameters = new HashMap<>();
                Integer delimiterCode = hiveClientWrapper.getDelimiterCode(tbl.getSd());
                outputParameters.put(DELIM_FIELD, delimiterCode.toString());
                metadata.setOutputParameters(outputParameters);
            } catch (UnsupportedTypeException | UnsupportedOperationException e) {
                if (ignoreErrors) {
                    LOG.warn("Metadata fetch for " + tblDesc.toString() + " failed. " + e.getMessage());
                } else {
                    throw e;
                }
            }
        }

        return metadataList;
    }

    public  HiveMetadataFetcher(RequestContext context);
      HiveMetadataFetcher(RequestContext context, ConfigurationFactory configurationFactory, HiveClientWrapper hiveClientWrapper);

}