hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odiache...@apache.org
Subject incubator-hawq git commit: HAWQ-967. Project additional columns from basic WHERE clause.
Date Mon, 08 Aug 2016 20:16:37 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-967 [created] 64c3af080


HAWQ-967. Project additional columns from basic WHERE clause.


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

Branch: refs/heads/HAWQ-967
Commit: 64c3af08025add685701aca785f1ce6d2c86a81a
Parents: 8906240
Author: Oleksandr Diachenko <odiachenko@pivotal.io>
Authored: Mon Aug 8 13:16:24 2016 -0700
Committer: Oleksandr Diachenko <odiachenko@pivotal.io>
Committed: Mon Aug 8 13:16:24 2016 -0700

----------------------------------------------------------------------
 src/backend/access/external/pxffilters.c | 36 +++++++++++++++++++++++++++
 src/backend/access/external/pxfheaders.c | 25 ++++++++++++++++---
 src/bin/gpfusion/gpbridgeapi.c           |  1 +
 src/include/access/pxffilters.h          |  1 +
 src/include/access/pxfheaders.h          |  1 +
 5 files changed, 60 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64c3af08/src/backend/access/external/pxffilters.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/pxffilters.c b/src/backend/access/external/pxffilters.c
index f219738..056eb44 100644
--- a/src/backend/access/external/pxffilters.c
+++ b/src/backend/access/external/pxffilters.c
@@ -536,6 +536,33 @@ const_to_str(Const *constval, StringInfo buf)
 	pfree(extval);
 }
 
+
+static List*
+pxf_extract_attributes(List *filters) {
+	ListCell *lc = NULL;
+	List *result = NIL;
+
+	if (list_length(filters) == 0)
+		return NIL;
+
+	foreach (lc, filters)
+	{
+		PxfFilterDesc *filter = (PxfFilterDesc *) lfirst(lc);
+		PxfOperand l = filter->l;
+		PxfOperand r = filter->r;
+
+		if (pxfoperand_is_attr(l)) {
+			result = lappend_int(result, l.attnum - 1);
+		}
+
+		if (pxfoperand_is_attr(r)) {
+			result = lappend_int(result, r.attnum - 1);
+		}
+	}
+
+	return result;
+}
+
 /*
  * serializePxfFilterQuals
  *
@@ -563,3 +590,12 @@ char *serializePxfFilterQuals(List *quals)
 	return result;
 }
 
+List* extractPxfAttributes(List* quals)
+{
+
+	List *filters = pxf_make_filter_list(quals);
+
+	List *attributes = pxf_extract_attributes(filters);
+
+	return attributes;
+}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64c3af08/src/backend/access/external/pxfheaders.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/pxfheaders.c b/src/backend/access/external/pxfheaders.c
index 45fcc35..c7b2ab4 100644
--- a/src/backend/access/external/pxfheaders.c
+++ b/src/backend/access/external/pxfheaders.c
@@ -26,6 +26,7 @@
 #include "catalog/namespace.h"
 #include "catalog/pg_exttable.h"
 #include "access/pxfheaders.h"
+#include "access/pxffilters.h"
 #include "utils/guc.h"
 
 static void add_alignment_size_httpheader(CHURL_HEADERS headers);
@@ -34,7 +35,7 @@ static void add_location_options_httpheader(CHURL_HEADERS headers, GPHDUri
*gphd
 static char* prepend_x_gp(const char* key);
 static void add_delegation_token_headers(CHURL_HEADERS headers, PxfInputData *inputData);
 static void add_remote_credentials(CHURL_HEADERS headers);
-static void add_projection_desc_httpheader(CHURL_HEADERS headers, ProjectionInfo *projInfo);
+static void add_projection_desc_httpheader(CHURL_HEADERS headers, ProjectionInfo *projInfo,
List *whereAttributes);
 
 /* 
  * Add key/value pairs to connection header. 
@@ -64,7 +65,9 @@ void build_http_header(PxfInputData *input)
 	
 	if (proj_info != NULL && proj_info->pi_isVarList)
 	{
-		add_projection_desc_httpheader(headers, proj_info);
+		List* whereAttributes = extractPxfAttributes(input->quals);
+
+		add_projection_desc_httpheader(headers, proj_info, whereAttributes);
 	}
 
 	/* GP cluster configuration */
@@ -166,7 +169,7 @@ static void add_tuple_desc_httpheader(CHURL_HEADERS headers, Relation
rel)
 	pfree(formatter.data);
 }
 
-static void add_projection_desc_httpheader(CHURL_HEADERS headers, ProjectionInfo *projInfo)
{
+static void add_projection_desc_httpheader(CHURL_HEADERS headers, ProjectionInfo *projInfo,
List *whereAttributes) {
     int i;
     char long_number[sizeof(int32) * 8];
     int *varNumbers = projInfo->pi_varNumbers;
@@ -174,7 +177,7 @@ static void add_projection_desc_httpheader(CHURL_HEADERS headers, ProjectionInfo
     initStringInfo(&formatter);
 
     /* Convert the number of projection columns to a string */
-    pg_ltoa(list_length(projInfo->pi_targetlist), long_number);
+    pg_ltoa(list_length(projInfo->pi_targetlist) + list_length(whereAttributes), long_number);
     churl_headers_append(headers, "X-GP-ATTRS-PROJ", long_number);
 
     for(i = 0; i < list_length(projInfo->pi_targetlist); i++) {
@@ -186,6 +189,20 @@ static void add_projection_desc_httpheader(CHURL_HEADERS headers, ProjectionInfo
         churl_headers_append(headers, formatter.data,long_number);
     }
 
+	ListCell *attribute = NULL;
+
+	foreach(attribute, whereAttributes)
+	{
+		AttrNumber attrNumber = lfirst_int(attribute);
+
+		pg_ltoa(attrNumber, long_number);
+		resetStringInfo(&formatter);
+		appendStringInfo(&formatter, "X-GP-ATTRS-PROJ-IDX");
+
+		churl_headers_append(headers, formatter.data,long_number);
+	}
+
+
     pfree(formatter.data);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64c3af08/src/bin/gpfusion/gpbridgeapi.c
----------------------------------------------------------------------
diff --git a/src/bin/gpfusion/gpbridgeapi.c b/src/bin/gpfusion/gpbridgeapi.c
index 94c6b7d..2751b1b 100644
--- a/src/bin/gpfusion/gpbridgeapi.c
+++ b/src/bin/gpfusion/gpbridgeapi.c
@@ -181,6 +181,7 @@ void add_querydata_to_http_header(gphadoop_context* context, PG_FUNCTION_ARGS)
 	inputData.headers = context->churl_headers;
 	inputData.gphduri = context->gphd_uri;
 	inputData.rel = EXTPROTOCOL_GET_RELATION(fcinfo);
+	inputData.quals = EXTPROTOCOL_GET_SCANQUALS(fcinfo);
 	inputData.filterstr = serializePxfFilterQuals(EXTPROTOCOL_GET_SCANQUALS(fcinfo));
 	if (EXTPROTOCOL_GET_SELECTDESC(fcinfo))
 		inputData.proj_info = EXTPROTOCOL_GET_PROJINFO(fcinfo);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64c3af08/src/include/access/pxffilters.h
----------------------------------------------------------------------
diff --git a/src/include/access/pxffilters.h b/src/include/access/pxffilters.h
index 358cd8b..1409e39 100644
--- a/src/include/access/pxffilters.h
+++ b/src/include/access/pxffilters.h
@@ -102,5 +102,6 @@ static inline bool pxfoperand_is_const(PxfOperand x)
 }
 
 char *serializePxfFilterQuals(List *quals);
+List* extractPxfAttributes(List* quals);
 
 #endif // _PXF_FILTERS_H_

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/64c3af08/src/include/access/pxfheaders.h
----------------------------------------------------------------------
diff --git a/src/include/access/pxfheaders.h b/src/include/access/pxfheaders.h
index da3da7f..410a077 100644
--- a/src/include/access/pxfheaders.h
+++ b/src/include/access/pxfheaders.h
@@ -45,6 +45,7 @@ typedef struct sPxfInputData
 	char			*filterstr;
 	PxfHdfsToken	token;
 	ProjectionInfo  *proj_info;
+	List			*quals;
 } PxfInputData;
 
 void build_http_header(PxfInputData *input);


Mime
View raw message