1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.error.StandardException; 25 26 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 27 28 import org.apache.derby.iapi.types.TypeId; 29 30 import org.apache.derby.iapi.reference.SQLState; 31 32 import org.apache.derby.iapi.services.sanity.SanityManager; 33 34 import java.util.Vector ; 35 36 41 public class GroupByColumn extends OrderedColumn 42 { 43 private ValueNode columnExpression; 44 45 50 public void init(Object colRef) 51 { 52 this.columnExpression = (ValueNode)colRef; 53 } 54 55 61 public String toString() 62 { 63 if (SanityManager.DEBUG) 64 { 65 return "Column Expression: "+columnExpression+super.toString(); 66 } 67 else 68 { 69 return ""; 70 } 71 } 72 73 79 80 public void printSubNodes(int depth) 81 { 82 if (SanityManager.DEBUG) 83 { 84 super.printSubNodes(depth); 85 86 if (columnExpression != null) 87 { 88 printLabel(depth, "colRef: "); 89 columnExpression.treePrint(depth + 1); 90 } 91 } 92 } 93 94 99 public String getColumnName() 100 { 101 return columnExpression.getColumnName(); 102 } 103 104 115 116 public void bindExpression( 117 FromList fromList, 118 SubqueryList subqueryList, 119 Vector aggregateVector) 120 throws StandardException 121 { 122 123 columnExpression = (ValueNode) columnExpression.bindExpression(fromList, 124 subqueryList, 125 aggregateVector); 126 127 if (columnExpression.isParameterNode()) 129 { 130 throw StandardException.newException(SQLState.LANG_INVALID_COL_REF_GROUPED_SELECT_LIST, 131 columnExpression); 132 } 133 140 TypeId ctid = columnExpression.getTypeId(); 141 if (! ctid.orderable(getClassFactory())) 142 { 143 throw StandardException.newException(SQLState.LANG_COLUMN_NOT_ORDERABLE_DURING_EXECUTION, 144 ctid.getSQLTypeName()); 145 } 146 } 147 148 public ValueNode getColumnExpression() 149 { 150 return columnExpression; 151 } 152 153 public void setColumnExpression(ValueNode cexpr) 154 { 155 this.columnExpression = cexpr; 156 157 } 158 } 159 | Popular Tags |