You can format your code by indenting it 4 spaces. Also, I think you can
have a line of quotes above and below it like this:
````````````````
````````````````

Not sure if it's forward or backward quote, though.


On Wed, Jan 22, 2014 at 10:39 PM, ramkrish86 <notifications@github.com>wrote:

> In
> phoenix-core/src/main/java/com/salesforce/phoenix/compile/ExpressionCompiler.java:
>
> > @@ -1289,4 +1292,45 @@ public Expression visit(SequenceOpParseNode node)
> >          .setSchemaName(node.getTableName().getSchemaName())
> >          .setTableName(node.getTableName().getTableName())
> .build().buildException();
> >  	}
> > +
> > +	@Override
> > +	public Expression visitLeave(ArrayConstructorNode node, List<Expression> children)
> > +			throws SQLException {
> > +		ArrayConstructorExpression arrayExpression = new ArrayConstructorExpression(
>
> How do you format the code part while writing comemnts?
>
>  Note that in your code above, you need to loop first through the
> children to find out the common base type of the array. For example, in
> this example here, the array will end up being a DECIMAL_ARRAY because the
> common base type of the INTEGER 1 and the DECIMAL 2.2 is a DECIMAL. You
> can't assume that the first child type will determine the array type.
>
>  I got this point. I have fixed this too. The piece of code I attached is
> after doing this check.
>
> {code}
> PDataType arrayElemDataType = children.get(0).getDataType();
>
> for (int i = 0; i < children.size(); i++) {
> Expression child = children.get(i);
> PDataType childType = child.getDataType();
> if (childType == null) {
> isChildTypeUnknown = true;
> } else if (arrayElemDataType == null) {
> arrayElemDataType = childType;
> isChildTypeUnknown = true;
> } else if (arrayElemDataType == childType ||
> childType.isCoercibleTo(arrayElemDataType)) {
> continue;
> } else if (arrayElemDataType.isCoercibleTo(childType)) {
> arrayElemDataType = childType;
> } else {
> throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_CONVERT_TYPE)
> .setMessage(
> "Case expressions must have common type: " + arrayElemDataType + " cannot
> be coerced to "
> + childType).build().buildException();
> }
> }
> // If we found an "unknown" child type and the return type is a number
> // make the return type be the most general number type of DECIMAL.
> if (isChildTypeUnknown && arrayElemDataType != null &&
> arrayElemDataType.isCoercibleTo(PDataType.DECIMAL)) {
> arrayElemDataType = PDataType.DECIMAL;
> }
> {code}
> SELECT ARRAY[1, 2.2, v] FROM t;
> where v could be double, integer anything.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/forcedotcom/phoenix/pull/707/files#r9104297>
> .
>