Return-Path: X-Original-To: apmail-hawq-dev-archive@minotaur.apache.org Delivered-To: apmail-hawq-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 39C6C19EC1 for ; Tue, 22 Mar 2016 00:24:20 +0000 (UTC) Received: (qmail 63316 invoked by uid 500); 22 Mar 2016 00:24:19 -0000 Delivered-To: apmail-hawq-dev-archive@hawq.apache.org Received: (qmail 63248 invoked by uid 500); 22 Mar 2016 00:24:19 -0000 Mailing-List: contact dev-help@hawq.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hawq.incubator.apache.org Delivered-To: mailing list dev@hawq.incubator.apache.org Received: (qmail 63237 invoked by uid 99); 22 Mar 2016 00:24:19 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Mar 2016 00:24:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 0B157180218 for ; Tue, 22 Mar 2016 00:24:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id HoZ6Jnb8YqAH for ; Tue, 22 Mar 2016 00:24:18 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id C04A35F2C4 for ; Tue, 22 Mar 2016 00:24:17 +0000 (UTC) Received: (qmail 63232 invoked by uid 99); 22 Mar 2016 00:24:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Mar 2016 00:24:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 256CADFB8A; Tue, 22 Mar 2016 00:24:17 +0000 (UTC) From: shivzone To: dev@hawq.incubator.apache.org Reply-To: dev@hawq.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-hawq pull request: HAWQ 459 Enhanced metadata api to sup... Content-Type: text/plain Message-Id: <20160322002417.256CADFB8A@git1-us-west.apache.org> Date: Tue, 22 Mar 2016 00:24:17 +0000 (UTC) Github user shivzone commented on a diff in the pull request: https://github.com/apache/incubator-hawq/pull/477#discussion_r56920623 --- Diff: pxf/pxf-hive/src/main/java/org/apache/hawq/pxf/plugins/hive/utilities/HiveUtilities.java --- @@ -203,19 +205,37 @@ private static boolean verifyModifers(String[] modifiers) { * It can be either table_name or db_name.table_name. * * @param qualifiedName Hive table name - * @return {@link org.apache.hawq.pxf.api.Metadata.Table} object holding the full table name + * @return {@link Metadata.Item} object holding the full table name */ - public static Metadata.Table parseTableQualifiedName(String qualifiedName) { + public static Metadata.Item extractTableFromName(String qualifiedName) { + List items = extractTablesFromPattern(null, qualifiedName); + if(items.isEmpty()) { + return null; + } + return items.get(0); + } + + /** + * Extracts the db_name and table_name from the qualifiedName. + * qualifiedName is the Hive table name or pattern that the user enters in the CREATE EXTERNAL TABLE statement + * or when querying HCatalog table. + * It can be either table_name_pattern or db_name_pattern.table_name_pattern. + * + * @param client Hivemetastore client + * @param pattern Hive table name or pattern + * @return {@link Metadata.Item} object holding the full table name + */ + public static List extractTablesFromPattern(HiveMetaStoreClient client, String pattern) { - String dbName, tableName; + String dbPattern, tablePattern; String errorMsg = " is not a valid Hive table name. " + "Should be either or "; - if (StringUtils.isBlank(qualifiedName)) { + if (StringUtils.isBlank(pattern)) { throw new IllegalArgumentException("empty string" + errorMsg); } - String[] rawToks = qualifiedName.split("[.]"); + String[] rawToks = pattern.split("[.]"); ArrayList toks = new ArrayList(); for (String tok: rawToks) { if (StringUtils.isBlank(tok)) { --- End diff -- Thats true but doesn't seem right. I'm not quite sure why we had this earlier --- 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. ---