hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sansanichfb <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ 459 Enhanced metadata api to sup...
Date Mon, 21 Mar 2016 23:27:09 GMT
Github user sansanichfb commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/477#discussion_r56915071
  
    --- Diff: pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java
---
    @@ -225,15 +245,53 @@ private static boolean verifyModifers(String[] modifiers) {
             }
     
             if (toks.size() == 1) {
    -            dbName = HIVE_DEFAULT_DBNAME;
    -            tableName = toks.get(0);
    +            dbPattern = HIVE_DEFAULT_DBNAME;
    +            tablePattern = toks.get(0);
             } else if (toks.size() == 2) {
    -            dbName = toks.get(0);
    -            tableName = toks.get(1);
    +            dbPattern = toks.get(0);
    +            tablePattern = toks.get(1);
             } else {
    -            throw new IllegalArgumentException("\"" + qualifiedName + "\"" + errorMsg);
    +            throw new IllegalArgumentException("\"" + pattern + "\"" + errorMsg);
             }
     
    -        return new Metadata.Table(dbName, tableName);
    +        return getTablesFromPattern(client, dbPattern, tablePattern);
    +
    +    }
    +
    +    private static List<Metadata.Item> getTablesFromPattern(HiveMetaStoreClient
client, String dbPattern, String tablePattern) {
    +
    +        List<String> databases = null;
    +        List<Metadata.Item> itemList = new ArrayList<Metadata.Item>();
    +        List<String> tables = new ArrayList<String>();
    +
    +        if(client == null || (!dbPattern.contains(WILDCARD) && !tablePattern.contains(WILDCARD))
) {
    +            /* This case occurs when the call is invoked as part of the fragmenter api
or when metadata is requested for a specific table name */
    +            itemList.add(new Metadata.Item(dbPattern, tablePattern));
    +            return itemList;
    +        }
    +
    +        try {
    +            /*if(dbPattern.contains(WILDCARD)) {
    +                databases.addAll(client.getAllDatabases());
    +            }*/
    +            databases = client.getDatabases(dbPattern);
    +            if(databases.isEmpty()) {
    +                throw new IllegalArgumentException("no database found for the given pattern");
    +            }
    +            for(String dbName: databases) {
    +                for(String tableName: client.getTables(dbName, tablePattern)) {
    +                    if (!tableName.isEmpty()) {
    +                        itemList.add(new Metadata.Item(dbName, tableName));
    +                    }
    +                }
    +            }
    +            if(itemList.isEmpty()) {
    +                throw new IllegalArgumentException("no tables found");
    +            }
    +            return itemList;
    +
    +        } catch (MetaException cause) {
    +            throw new RuntimeException("Failed connecting to Hive MetaStore service:
" + cause.getMessage(), cause);
    --- End diff --
    
    Should we have consistent messages in expection, either starting from upper or lower letter?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message