You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by od...@apache.org on 2016/10/14 18:45:19 UTC

[1/3] incubator-hawq git commit: HAWQ-1103. Draft implementation without taking care of different charsets.

Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-1103 [created] 2497b6f32


HAWQ-1103. Draft implementation without taking care of different charsets.


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

Branch: refs/heads/HAWQ-1103
Commit: b318fa0e7d038084ded2bc99c6e631aa26700b21
Parents: 7f3658d
Author: Oleksandr Diachenko <od...@pivotal.io>
Authored: Thu Oct 13 16:00:03 2016 -0700
Committer: Oleksandr Diachenko <od...@pivotal.io>
Committed: Thu Oct 13 16:00:03 2016 -0700

----------------------------------------------------------------------
 src/backend/access/external/pxffilters.c | 25 +++++++++++++++----------
 src/include/access/pxffilters.h          |  9 ++++++---
 2 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b318fa0e/src/backend/access/external/pxffilters.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/pxffilters.c b/src/backend/access/external/pxffilters.c
index 56aea55..ded9f9a 100644
--- a/src/backend/access/external/pxffilters.c
+++ b/src/backend/access/external/pxffilters.c
@@ -369,14 +369,18 @@ pxf_serialize_filter_list(List *expressionItems)
 					PxfOperatorCode o = filter->op;
 					if (pxfoperand_is_attr(l) && pxfoperand_is_const(r))
 					{
-						appendStringInfo(resbuf, "%c%d%c%s",
+						appendStringInfo(resbuf, "%c%d%c%d%c%d%c%s",
 												 PXF_ATTR_CODE, l.attnum - 1, /* Java attrs are 0-based */
-												 PXF_CONST_CODE, (r.conststr)->data);
+												 PXF_CONST_CODE, r.consttype,
+												 PXF_LENGTH_TO_READ, strlen(r.conststr->data),
+												 PXF_CONST_DATA, (r.conststr)->data);
 					}
 					else if (pxfoperand_is_const(l) && pxfoperand_is_attr(r))
 					{
-						appendStringInfo(resbuf, "%c%s%c%d",
-												 PXF_CONST_CODE, (l.conststr)->data,
+						appendStringInfo(resbuf, "%c%d%c%d%c%s%c%d",
+												 PXF_CONST_CODE, l.consttype,
+												 PXF_LENGTH_TO_READ, strlen(l.conststr->data),
+												 PXF_CONST_DATA, (l.conststr)->data,
 												 PXF_ATTR_CODE, r.attnum - 1); /* Java attrs are 0-based */
 					}
 					else
@@ -468,6 +472,7 @@ opexpr_to_pxffilter(OpExpr *expr, PxfFilterDesc *filter)
 	{
 		filter->l.opcode = PXF_ATTR_CODE;
 		filter->l.attnum = ((Var *) leftop)->varattno;
+		filter->l.consttype = InvalidOid;
 		if (filter->l.attnum <= InvalidAttrNumber)
 			return false; /* system attr not supported */
 
@@ -476,6 +481,7 @@ opexpr_to_pxffilter(OpExpr *expr, PxfFilterDesc *filter)
 		filter->r.conststr = makeStringInfo();
 		initStringInfo(filter->r.conststr);
 		const_to_str((Const *)rightop, filter->r.conststr);
+		filter->r.consttype = ((Const *)rightop)->consttype;
 	}
 	else if (IsA(leftop, Const) && IsA(rightop, Var))
 	{
@@ -484,9 +490,11 @@ opexpr_to_pxffilter(OpExpr *expr, PxfFilterDesc *filter)
 		filter->l.conststr = makeStringInfo();
 		initStringInfo(filter->l.conststr);
 		const_to_str((Const *)leftop, filter->l.conststr);
+		filter->l.consttype = ((Const *)leftop)->consttype;
 
 		filter->r.opcode = PXF_ATTR_CODE;
 		filter->r.attnum = ((Var *) rightop)->varattno;
+		filter->r.consttype = InvalidOid;
 		if (filter->r.attnum <= InvalidAttrNumber)
 			return false; /* system attr not supported */
 	}
@@ -632,9 +640,6 @@ const_to_str(Const *constval, StringInfo buf)
 		case FLOAT4OID:
 		case FLOAT8OID:
 		case NUMERICOID:
-			appendStringInfo(buf, "%s", extval);
-			break;
-
 		case TEXTOID:
 		case VARCHAROID:
 		case BPCHAROID:
@@ -642,14 +647,14 @@ const_to_str(Const *constval, StringInfo buf)
 		case BYTEAOID:
 		case DATEOID:
 		case TIMESTAMPOID:
-			appendStringInfo(buf, "\\\"%s\\\"", extval);
+			appendStringInfo(buf, "%s", extval);
 			break;
 
 		case BOOLOID:
 			if (strcmp(extval, "t") == 0)
-				appendStringInfo(buf, "\"true\"");
+				appendStringInfo(buf, "true");
 			else
-				appendStringInfo(buf, "\"false\"");
+				appendStringInfo(buf, "false");
 			break;
 
 		default:

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/b318fa0e/src/include/access/pxffilters.h
----------------------------------------------------------------------
diff --git a/src/include/access/pxffilters.h b/src/include/access/pxffilters.h
index 894337b..5f5ae4e 100644
--- a/src/include/access/pxffilters.h
+++ b/src/include/access/pxffilters.h
@@ -53,9 +53,11 @@ typedef enum PxfOperatorCode
  * by a code that will describe the operator type in the final serialized
  * string that gets pushed down.
  */
-#define PXF_ATTR_CODE		'a'
-#define PXF_CONST_CODE		'c'
-#define PXF_OPERATOR_CODE	'o'
+#define PXF_ATTR_CODE				'a'
+#define PXF_CONST_CODE				'c'
+#define PXF_LENGTH_TO_READ			's'
+#define PXF_CONST_DATA				'd'
+#define PXF_OPERATOR_CODE			'o'
 #define PXF_LOGICAL_OPERATOR_CODE	'l'
 
 /*
@@ -68,6 +70,7 @@ typedef struct PxfOperand
 	char		opcode;		/* PXF_ATTR_CODE or PXF_CONST_CODE*/
 	AttrNumber 	attnum;		/* used when opcode is PXF_ATTR_CODE */
 	StringInfo 	conststr;	/* used when opcode is PXF_CONST_CODE */
+	Oid 		consttype; 	/* used when opcode is PXF_CONST_CODE */
 
 } PxfOperand;
 


[3/3] incubator-hawq git commit: HAWQ-1103. Added test cases with string containing a quote.

Posted by od...@apache.org.
HAWQ-1103. Added test cases with string containing a quote.


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

Branch: refs/heads/HAWQ-1103
Commit: 2497b6f327944e1fbdc5434dddacab0fcacfa7f9
Parents: d9f77da
Author: Oleksandr Diachenko <od...@pivotal.io>
Authored: Fri Oct 14 11:45:02 2016 -0700
Committer: Oleksandr Diachenko <od...@pivotal.io>
Committed: Fri Oct 14 11:45:02 2016 -0700

----------------------------------------------------------------------
 src/backend/access/external/pxffilters.c           | 4 ++--
 src/backend/access/external/test/pxffilters_test.c | 7 +++++--
 src/include/access/pxffilters.h                    | 2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2497b6f3/src/backend/access/external/pxffilters.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/pxffilters.c b/src/backend/access/external/pxffilters.c
index ded9f9a..ef7b16f 100644
--- a/src/backend/access/external/pxffilters.c
+++ b/src/backend/access/external/pxffilters.c
@@ -372,14 +372,14 @@ pxf_serialize_filter_list(List *expressionItems)
 						appendStringInfo(resbuf, "%c%d%c%d%c%d%c%s",
 												 PXF_ATTR_CODE, l.attnum - 1, /* Java attrs are 0-based */
 												 PXF_CONST_CODE, r.consttype,
-												 PXF_LENGTH_TO_READ, strlen(r.conststr->data),
+												 PXF_SIZE_BYTES, strlen(r.conststr->data),
 												 PXF_CONST_DATA, (r.conststr)->data);
 					}
 					else if (pxfoperand_is_const(l) && pxfoperand_is_attr(r))
 					{
 						appendStringInfo(resbuf, "%c%d%c%d%c%s%c%d",
 												 PXF_CONST_CODE, l.consttype,
-												 PXF_LENGTH_TO_READ, strlen(l.conststr->data),
+												 PXF_SIZE_BYTES, strlen(l.conststr->data),
 												 PXF_CONST_DATA, (l.conststr)->data,
 												 PXF_ATTR_CODE, r.attnum - 1); /* Java attrs are 0-based */
 					}

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2497b6f3/src/backend/access/external/test/pxffilters_test.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/test/pxffilters_test.c b/src/backend/access/external/test/pxffilters_test.c
index 6db7ae7..3679587 100644
--- a/src/backend/access/external/test/pxffilters_test.c
+++ b/src/backend/access/external/test/pxffilters_test.c
@@ -517,20 +517,23 @@ test__pxf_serialize_filter_list__manyFilters(void **state)
 	ExpressionItem* expressionItem2 = build_expression_item(2, TEXTOID, "George Orwell", TEXTOID, TextEqualOperator);
 	ExpressionItem* expressionItem3 = build_expression_item(3, TEXTOID, "Winston", TEXTOID, TextEqualOperator);
 	ExpressionItem* expressionItem4 = build_expression_item(4, TEXTOID, "Eric-%", TEXTOID, 1209);
+	ExpressionItem* expressionItem5 = build_expression_item(5, TEXTOID, "\"Ugly\" string with quotes", TEXTOID, TextEqualOperator);
 
 
 	expressionItems = lappend(expressionItems, expressionItem1);
 	expressionItems = lappend(expressionItems, expressionItem2);
 	expressionItems = lappend(expressionItems, expressionItem3);
 	expressionItems = lappend(expressionItems, expressionItem4);
+	expressionItems = lappend(expressionItems, expressionItem5);
 
 	result = pxf_serialize_filter_list(expressionItems);
-	assert_string_equal(result, "a0c25s4d1984o5a1c25s13dGeorge Orwello5a2c25s7dWinstono5a3c25s6dEric-%o7");
+	assert_string_equal(result, "a0c25s4d1984o5a1c25s13dGeorge Orwello5a2c25s7dWinstono5a3c25s6dEric-%o7a4c25s25d\"Ugly\" string with quoteso5");
 	pfree(result);
 
+	int trivialExpressionItems = expressionItems->length;
 	enrich_trivial_expression(expressionItems);
 
-	assert_int_equal(expressionItems->length, 7);
+	assert_int_equal(expressionItems->length, 2*trivialExpressionItems - 1);
 
 	pxf_free_expression_items_list(expressionItems, true);
 	expressionItems = NIL;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/2497b6f3/src/include/access/pxffilters.h
----------------------------------------------------------------------
diff --git a/src/include/access/pxffilters.h b/src/include/access/pxffilters.h
index 5f5ae4e..00c77d3 100644
--- a/src/include/access/pxffilters.h
+++ b/src/include/access/pxffilters.h
@@ -55,7 +55,7 @@ typedef enum PxfOperatorCode
  */
 #define PXF_ATTR_CODE				'a'
 #define PXF_CONST_CODE				'c'
-#define PXF_LENGTH_TO_READ			's'
+#define PXF_SIZE_BYTES				's'
 #define PXF_CONST_DATA				'd'
 #define PXF_OPERATOR_CODE			'o'
 #define PXF_LOGICAL_OPERATOR_CODE	'l'


[2/3] incubator-hawq git commit: HAWQ-1103. Updated unit-tests.

Posted by od...@apache.org.
HAWQ-1103. Updated unit-tests.


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

Branch: refs/heads/HAWQ-1103
Commit: d9f77da1db31e260092fbce603686f92540848f3
Parents: b318fa0
Author: Oleksandr Diachenko <od...@pivotal.io>
Authored: Thu Oct 13 16:45:33 2016 -0700
Committer: Oleksandr Diachenko <od...@pivotal.io>
Committed: Thu Oct 13 16:45:33 2016 -0700

----------------------------------------------------------------------
 .../access/external/test/pxffilters_test.c      | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/d9f77da1/src/backend/access/external/test/pxffilters_test.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/test/pxffilters_test.c b/src/backend/access/external/test/pxffilters_test.c
index 76be330..6db7ae7 100644
--- a/src/backend/access/external/test/pxffilters_test.c
+++ b/src/backend/access/external/test/pxffilters_test.c
@@ -183,19 +183,19 @@ test__const_to_str__int(void **state)
 void
 test__const_to_str__text(void **state)
 {
-	verify__const_to_str(false, "that", TEXTOID, "\\\"that\\\"");
-	verify__const_to_str(false, "joke", VARCHAROID, "\\\"joke\\\"");
-	verify__const_to_str(false, "isn't", BPCHAROID, "\\\"isn't\\\"");
-	verify__const_to_str(false, "funny", CHAROID, "\\\"funny\\\"");
-	verify__const_to_str(false, "anymore", BYTEAOID, "\\\"anymore\\\"");
-	verify__const_to_str(false, "iamdate", DATEOID, "\\\"iamdate\\\"");
+	verify__const_to_str(false, "that", TEXTOID, "that");
+	verify__const_to_str(false, "joke", VARCHAROID, "joke");
+	verify__const_to_str(false, "isn't", BPCHAROID, "isn't");
+	verify__const_to_str(false, "funny", CHAROID, "funny");
+	verify__const_to_str(false, "anymore", BYTEAOID, "anymore");
+	verify__const_to_str(false, "iamdate", DATEOID, "iamdate");
 }
 
 void
 test__const_to_str__boolean(void **state)
 {
-	verify__const_to_str(false, "t", BOOLOID, "\"true\"");
-	verify__const_to_str(false, "f", BOOLOID, "\"false\"");
+	verify__const_to_str(false, "t", BOOLOID, "true");
+	verify__const_to_str(false, "f", BOOLOID, "false");
 }
 
 void
@@ -499,7 +499,7 @@ void test__pxf_serialize_filter_list__oneFilter(void **state) {
 	expressionItems = lappend(expressionItems, filterExpressionItem);
 
 	char* result = pxf_serialize_filter_list(expressionItems);
-	assert_string_equal(result, "a0c\\\"1984\\\"o5");
+	assert_string_equal(result, "a0c25s4d1984o5");
 
 	pxf_free_expression_items_list(expressionItems, true);
 	expressionItems = NIL;
@@ -514,9 +514,9 @@ test__pxf_serialize_filter_list__manyFilters(void **state)
 	List* expressionItems = NIL;
 
 	ExpressionItem* expressionItem1 = build_expression_item(1, TEXTOID, "1984", TEXTOID, TextEqualOperator);
-	ExpressionItem* expressionItem2 = build_expression_item(2, TEXTOID, "\"George Orwell\"", TEXTOID, TextEqualOperator);
-	ExpressionItem* expressionItem3 = build_expression_item(3, TEXTOID, "\"Winston\"", TEXTOID, TextEqualOperator);
-	ExpressionItem* expressionItem4 = build_expression_item(4, TEXTOID, "\"Eric-%\"", TEXTOID, 1209);
+	ExpressionItem* expressionItem2 = build_expression_item(2, TEXTOID, "George Orwell", TEXTOID, TextEqualOperator);
+	ExpressionItem* expressionItem3 = build_expression_item(3, TEXTOID, "Winston", TEXTOID, TextEqualOperator);
+	ExpressionItem* expressionItem4 = build_expression_item(4, TEXTOID, "Eric-%", TEXTOID, 1209);
 
 
 	expressionItems = lappend(expressionItems, expressionItem1);
@@ -525,7 +525,7 @@ test__pxf_serialize_filter_list__manyFilters(void **state)
 	expressionItems = lappend(expressionItems, expressionItem4);
 
 	result = pxf_serialize_filter_list(expressionItems);
-	assert_string_equal(result, "a0c\\\"1984\\\"o5a1c\\\"\"George Orwell\"\\\"o5a2c\\\"\"Winston\"\\\"o5a3c\\\"\"Eric-%\"\\\"o7");
+	assert_string_equal(result, "a0c25s4d1984o5a1c25s13dGeorge Orwello5a2c25s7dWinstono5a3c25s6dEric-%o7");
 	pfree(result);
 
 	enrich_trivial_expression(expressionItems);