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-975. Added support for IN, BETWEEN, LIKE.
Date Fri, 19 Aug 2016 21:40:31 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-967 d0e541938 -> f40b2918e


HAWQ-975. Added support for IN, BETWEEN, LIKE.


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

Branch: refs/heads/HAWQ-967
Commit: f40b2918eca1fb1293781354cef8c1d216b07b30
Parents: d0e5419
Author: Oleksandr Diachenko <odiachenko@pivotal.io>
Authored: Fri Aug 19 14:40:22 2016 -0700
Committer: Oleksandr Diachenko <odiachenko@pivotal.io>
Committed: Fri Aug 19 14:40:22 2016 -0700

----------------------------------------------------------------------
 src/backend/access/external/pxffilters.c | 44 ++++++++++++++++-----------
 1 file changed, 27 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f40b2918/src/backend/access/external/pxffilters.c
----------------------------------------------------------------------
diff --git a/src/backend/access/external/pxffilters.c b/src/backend/access/external/pxffilters.c
index 4ec8dde..bd7588b 100644
--- a/src/backend/access/external/pxffilters.c
+++ b/src/backend/access/external/pxffilters.c
@@ -38,6 +38,7 @@ static char* pxf_serialize_filter_list(List *filters);
 static bool opexpr_to_pxffilter(OpExpr *expr, PxfFilterDesc *filter);
 static bool supported_filter_type(Oid type);
 static void const_to_str(Const *constval, StringInfo buf);
+static List* append_attr_from_var(Var* var, List* attrs);
 
 /*
  * All supported HAWQ operators, and their respective HFDS operator code.
@@ -196,7 +197,7 @@ pxf_make_filter_list(List *quals)
 				elog(DEBUG5, "pxf_make_filter_list: node tag %d (T_BoolExpr), bool node type %d %s",
 						tag, boolType, boolType==AND_EXPR ? "(AND_EXPR)" : "");
 
-				/* only AND_EXPR is supported for filter push-down*/
+				/* only AND_EXPR is supported */
 				if (expr->boolop == AND_EXPR)
 				{
 					List *inner_result = pxf_make_filter_list(expr->args);
@@ -451,7 +452,8 @@ opexpr_to_pxffilter(OpExpr *expr, PxfFilterDesc *filter)
 	return false;
 }
 
-List* append_attr_from_var(Var* var, List* attrs)
+static List*
+append_attr_from_var(Var* var, List* attrs)
 {
 	AttrNumber varattno = var->varattno;
 	/* system attr not supported */
@@ -462,7 +464,7 @@ List* append_attr_from_var(Var* var, List* attrs)
 }
 
 static List*
-get_attrs_from_opexpr(OpExpr *expr)
+get_attrs_from_expr(Expr *expr)
 {
 	Node	*leftop 	= NULL;
 	Node	*rightop	= NULL;
@@ -471,10 +473,17 @@ get_attrs_from_opexpr(OpExpr *expr)
 	if ((!expr))
 		return attrs;
 
-	leftop = get_leftop((Expr*)expr);
-	rightop	= get_rightop((Expr*)expr);
+	if (IsA(expr, OpExpr))
+	{
+		leftop = get_leftop(expr);
+		rightop	= get_rightop(expr);
+	} else if (IsA(expr, ScalarArrayOpExpr))
+	{
+		ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) expr;
+		leftop = (Node *) linitial(saop->args);
+		rightop = (Node *) lsecond(saop->args);
+	}
 
-	/* arguments must be VAR and CONST */
 	if (IsA(leftop, Var))
 	{
 		attrs = append_attr_from_var((Var *) leftop, attrs);
@@ -620,28 +629,29 @@ List* extractPxfAttributes(List* quals)
 		switch (tag)
 		{
 			case T_OpExpr:
+			case T_ScalarArrayOpExpr:
 			{
-				OpExpr			*expr 	= (OpExpr *) node;
-				List			*attrs = get_attrs_from_opexpr(expr);
-				attributes = lappend(attributes, attrs);
-				break;
-			}
-			case T_NullTest:
-			{
-				NullTest	*expr = (NullTest *) node;
-				attributes = append_attr_from_var((Var *) expr->arg, attributes);
+				Expr* expr = (Expr *) node;
+				List			*attrs = get_attrs_from_expr(expr);
+				attributes = list_concat(attributes, attrs);
 				break;
 			}
 			case T_BoolExpr:
 			{
-				BoolExpr	*expr = (BoolExpr *) node;
+				BoolExpr* expr = (BoolExpr *) node;
 				List *inner_result = extractPxfAttributes(expr->args);
 				attributes = list_concat(attributes, inner_result);
 				break;
 			}
+			case T_NullTest:
+			{
+				NullTest* expr = (NullTest *) node;
+				attributes = append_attr_from_var((Var *) expr->arg, attributes);
+				break;
+			}
 			default:
 				/* expression not supported */
-				elog(ERROR, "pxf_make_filter_list: unsupported node tag %d", tag);
+				elog(ERROR, "extractPxfAttributes: unsupported node tag %d, unable to extract column
from WHERE clause", tag);
 				break;
 		}
 	}


Mime
View raw message