Github user GodenYao commented on a diff in the pull request:
https://github.com/apache/incubator-hawq/pull/477#discussion_r56917255
--- 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 <code>table_name</code> or
<code>db_name.table_name</code>.
*
* @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<Metadata.Item> 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 <code>table_name_pattern</code> or
<code>db_name_pattern.table_name_pattern</code>.
+ *
+ * @param client Hivemetastore client
+ * @param pattern Hive table name or pattern
+ * @return {@link Metadata.Item} object holding the full table name
+ */
+ public static List<Metadata.Item>
extractTablesFromPattern(HiveMetaStoreClient client, String pattern) {
- String dbName, tableName;
+ String dbPattern, tablePattern;
String errorMsg = " is not a valid Hive table name. "
+ "Should be either <table_name> or <db_name.table_name>";
- if (StringUtils.isBlank(qualifiedName)) {
+ if (StringUtils.isBlank(pattern)) {
throw new IllegalArgumentException("empty string" + errorMsg);
}
- String[] rawToks = qualifiedName.split("[.]");
+ String[] rawToks = pattern.split("[.]");
ArrayList<String> toks = new ArrayList<String>();
for (String tok: rawToks) {
if (StringUtils.isBlank(tok)) {
--- End diff --
so this means input like "db_name.....table_name" will be accepted?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---