Github user kavinderd commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/981#discussion_r88100166
  
    --- Diff: src/backend/access/external/pxffilters.c ---
    @@ -496,23 +629,116 @@ opexpr_to_pxffilter(OpExpr *expr, PxfFilterDesc 
*filter)
                return false;
        }
     
    -   /* is operator supported? if so, set the corresponding PXFOP */
    -   for (i = 0; i < nargs; i++)
    +   return true;
    +}
    +
    +static bool
    +scalar_array_op_expr_to_pxffilter(ScalarArrayOpExpr *expr, PxfFilterDesc 
*filter)
    +{
    +
    +   Node    *leftop         = NULL;
    +   Node    *rightop        = NULL;
    +
    +   leftop = (Node *) linitial(expr->args);
    +   rightop = (Node *) lsecond(expr->args);
    +   Oid              leftop_type = exprType(leftop);
    +   Oid              rightop_type = exprType(rightop);
    +
    +   /*
    +    * check if supported type -
    +    */
    +   if (!supported_filter_type(rightop_type) || 
!supported_filter_type(leftop_type))
    +           return false;
    +
    +   /*
    +    * check if supported operator -
    +    */
    +   if(!supported_operator_type(expr->opno, filter))
    +           return false;
    +
    +   if (IsA(leftop, Var) && IsA(rightop, Const))
        {
    -           /* NOTE: switch to hash table lookup if   */
    -           /* array grows. for now it's cheap enough */
    -           if(expr->opno == pxf_supported_opr[i].dbop)
    -           {
    -                   filter->op = pxf_supported_opr[i].pxfop;
    -                   return true; /* filter qualifies! */
    -           }
    +           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 */
    +
    +           filter->r.opcode = PXF_LIST_CONST_CODE;
    +           filter->r.attnum = InvalidAttrNumber;
    +           filter->r.conststr = makeStringInfo();
    +           list_const_to_str((Const *)rightop, filter->r.conststr);
    +           filter->r.consttype = ((Const *)rightop)->consttype;
    +   }
    +   else if (IsA(leftop, Const) && IsA(rightop, Var))
    +   {
    +           filter->l.opcode = PXF_LIST_CONST_CODE;
    +           filter->l.attnum = InvalidAttrNumber;
    +           filter->l.conststr = makeStringInfo();
    +           list_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 */
    +   }
    +   else
    +   {
    +           elog(DEBUG1, "pxf_serialize_filter_list: expression is not a 
Var+Const");
    +           return false;
        }
     
    -   elog(DEBUG1, "opexpr_to_pxffilter: operator is not supported, operator 
code: %d", expr->opno);
     
    -   /* NOTE: if more validation needed, add it before the operators test
    -    * or alternatively change it to use a false flag and return true below 
*/
    -   return false;
    +
    +   return true;
    +}
    +
    +static bool
    +var_to_pxffilter(Var *var, PxfFilterDesc *filter)
    +{
    +   Oid var_type = InvalidOid;
    +
    +   if ((!var) || (!filter))
    +           return false;
    +
    +   var_type = exprType(var);
    +
    +   /*
    +    * check if supported type -
    +    */
    +   if (!supported_filter_type(var_type))
    +           return false;
    +
    +   /*
    +    * check if supported operator -
    +    */
    +   if (!supported_operator_type(BooleanEqualOperator, filter))
    +           return false;
    +
    +   /* arguments must be VAR and CONST */
    +   if (IsA(var,  Var))
    +   {
    +           filter->l.opcode = PXF_ATTR_CODE;
    +           filter->l.attnum = var->varattno;
    +           filter->l.consttype = InvalidOid;
    --- End diff --
    
    Why is this `InvalidOid` is that just a default value?


---
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.
---

Reply via email to