You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Shubham Chopra (JIRA)" <ji...@apache.org> on 2008/05/21 11:29:55 UTC
[jira] Issue Comment Edited: (PIG-161) Rework physical plan
[ https://issues.apache.org/jira/browse/PIG-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12598598#action_12598598 ]
shubhamc edited comment on PIG-161 at 5/21/08 2:28 AM:
-------------------------------------------------------------
I had to modify Pi's TypeCheckingVisitor. Instead of the visit(BinaryExpressionOperator) function, I had to put in individual functions that override corresponding methods in LOVisitor. So, instead of;
{code}
protected void visit(BinaryExpressionOperator binOp)
throws VisitorException {
ExpressionOperator lhs = binOp.getLhsOperand() ;
ExpressionOperator rhs = binOp.getRhsOperand() ;
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
/**
* For AND/OR, all operands must be boolean
* Output is always boolean
*/
if ( (binOp instanceof LOAnd) ||
(binOp instanceof LOOr) ) {
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new VisitorException(msg) ;
}
binOp.setType(DataType.BOOLEAN) ;
}
{code}
I had to convert it to the following :
{code}
@Override
public void visit(LOAnd binOp) throws VisitorException {
ExpressionOperator lhs = binOp.getLhsOperand() ;
ExpressionOperator rhs = binOp.getRhsOperand() ;
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new VisitorException(msg) ;
}
binOp.setType(DataType.BOOLEAN) ;
}
@Override
public void visit(LOOr binOp) throws VisitorException {
ExpressionOperator lhs = binOp.getLhsOperand() ;
ExpressionOperator rhs = binOp.getRhsOperand() ;
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new VisitorException(msg) ;
}
binOp.setType(DataType.BOOLEAN) ;
}
{code}
was (Author: shubhamc):
I had to modify Pi's TypeCheckingVisitor. Instead of the visit(BinaryExpressionOperator) function, I had to put in individual functions that override corresponding methods in LOVisitor. So, instead of;
{{{
protected void visit(BinaryExpressionOperator binOp)
throws VisitorException {
ExpressionOperator lhs = binOp.getLhsOperand() ;
ExpressionOperator rhs = binOp.getRhsOperand() ;
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
/**
* For AND/OR, all operands must be boolean
* Output is always boolean
*/
if ( (binOp instanceof LOAnd) ||
(binOp instanceof LOOr) ) {
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new VisitorException(msg) ;
}
binOp.setType(DataType.BOOLEAN) ;
}
}}}
I had to convert it to the following :
{{{
@Override
public void visit(LOAnd binOp) throws VisitorException {
ExpressionOperator lhs = binOp.getLhsOperand() ;
ExpressionOperator rhs = binOp.getRhsOperand() ;
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new VisitorException(msg) ;
}
binOp.setType(DataType.BOOLEAN) ;
}
@Override
public void visit(LOOr binOp) throws VisitorException {
ExpressionOperator lhs = binOp.getLhsOperand() ;
ExpressionOperator rhs = binOp.getRhsOperand() ;
byte lhsType = lhs.getType() ;
byte rhsType = rhs.getType() ;
if ( (lhsType != DataType.BOOLEAN) ||
(rhsType != DataType.BOOLEAN) ) {
String msg = "Operands of AND/OR can be boolean only" ;
msgCollector.collect(msg, MessageType.Error);
throw new VisitorException(msg) ;
}
binOp.setType(DataType.BOOLEAN) ;
}
}}}
> Rework physical plan
> --------------------
>
> Key: PIG-161
> URL: https://issues.apache.org/jira/browse/PIG-161
> Project: Pig
> Issue Type: Sub-task
> Reporter: Alan Gates
> Assignee: Alan Gates
> Attachments: arithmeticOperators.patch, BinCondAndNegative.patch, CastAndMapLookUp.patch, incr2.patch, incr3.patch, incr4.patch, incr5.patch, logToPhyTranslator.patch, MRCompilerTests_PlansAndOutputs.txt, Phy_AbsClass.patch, physicalOps.patch, physicalOps.patch, physicalOps.patch, physicalOps.patch, physicalOps_latest.patch, POCast.patch, POCast.patch, podistinct.patch, pogenerate.patch, pogenerate.patch, pogenerate.patch, posort.patch, TEST-org.apache.pig.test.TestLocalJobSubmission.txt, TEST-org.apache.pig.test.TestLogToPhyCompiler.txt, TEST-org.apache.pig.test.TestTypeCheckingValidator.txt, TEST-org.apache.pig.test.TestUnion.txt, translator.patch, translator.patch, translator.patch
>
>
> This bug tracks work to rework all of the physical operators as described in http://wiki.apache.org/pig/PigTypesFunctionalSpec
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.