hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odiache...@apache.org
Subject [1/3] incubator-hawq git commit: HAWQ-546. Implemented call of pxf_get_object_fields for Hive on psql.
Date Wed, 30 Mar 2016 01:18:55 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-546 [created] 4bcbef98c


HAWQ-546. Implemented call of pxf_get_object_fields for Hive on psql.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/d89173e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/d89173e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/d89173e7

Branch: refs/heads/HAWQ-546
Commit: d89173e7860ac1b6bf1f50d9a660fc7ccf903b73
Parents: 76dc631
Author: Oleksandr Diachenko <odiachenko@pivotal.io>
Authored: Mon Mar 21 17:04:32 2016 -0700
Committer: Oleksandr Diachenko <odiachenko@pivotal.io>
Committed: Mon Mar 21 17:04:32 2016 -0700

----------------------------------------------------------------------
 src/bin/psql/describe.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d89173e7/src/bin/psql/describe.c
----------------------------------------------------------------------
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 99718d2..1672e64 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -42,6 +42,7 @@ static bool describeOneTSConfig(const char *oid, const char *nspname,
 static void printACLColumn(PQExpBuffer buf, const char *colname);
 static bool isGPDB(void);
 static bool isGPDB4200OrLater(void);
+static bool describeHcatalogTable(const char *pattern, bool verbose);
 
 /* GPDB 3.2 used PG version 8.2.10, and we've moved the minor number up since then for each
release,  4.1 = 8.2.15 */
 /* Allow for a couple of future releases.  If the version isn't in this range, we are talking
to PostgreSQL, not GPDB */
@@ -1151,6 +1152,12 @@ describeTableDetails(const char *pattern, bool verbose, bool showSystem)
 	PQExpBufferData buf;
 	PGresult   *res;
 	int			i;
+	char const *hcatalog = "hcatalog";
+
+
+	//Hcatalog hook in this method
+	if(strncmp(pattern, hcatalog, strlen(hcatalog)) == 0)
+		return describeHcatalogTable(pattern, verbose);
 
 	initPQExpBuffer(&buf);
 
@@ -4213,3 +4220,44 @@ printACLColumn(PQExpBuffer buf, const char *colname)
 						  "pg_catalog.array_to_string(%s, '\\n') AS \"%s\"",
 						  colname, gettext_noop("Access privileges"));
 }
+
+
+static void
+parseExternalPattern(const char *user_pattern, char **profile, char **pattern)
+{
+
+	*profile = strtok(user_pattern, ".");
+	*pattern = strtok(NULL, "/0");
+
+}
+
+static bool
+describeHcatalogTable(const char *pattern, bool verbose)
+{
+	PQExpBufferData buf;
+	PGresult *res;
+	printQueryOpt myopt = pset.popt;
+	char *pxf_profile = "*";
+	char *pxf_pattern = "*";
+
+	parseExternalPattern(pattern, &pxf_profile, &pattern);
+
+	initPQExpBuffer(&buf);
+
+	printfPQExpBuffer(&buf, "SELECT * FROM\n"
+			"pxf_get_object_fields('%s', '%s') \n", pxf_profile, pxf_pattern);
+
+	res = PSQLexec(buf.data, false);
+	termPQExpBuffer(&buf);
+	if (!res)
+		return false;
+
+	myopt.nullPrint = NULL;
+	myopt.title = _("List of Hcatalog tables");
+	myopt.translate_header = true;
+
+	printQuery(res, &myopt, pset.queryFout, pset.logfile);
+
+	PQclear(res);
+	return true;
+}


Mime
View raw message