Description
When `Expr.clone()` is called, various errors(NPE/TypeCastingError/recursive/functional error) are occurs. This issue should be solved for others issues reusing `Expr`. Please refer the following code.
- NPE case (Aggregation.java, UnaryOperator.java, CreateTable, AlterTable)
- aggregation.namedExprs = new NamedExpr[namedExprs.length]; - for (int i = 0; i < namedExprs.length; i++) { - aggregation.namedExprs[i] = (NamedExpr) namedExprs[i].clone(); + if (namedExprs != null) { + aggregation.namedExprs = new NamedExpr[namedExprs.length]; + for (int i = 0; i < namedExprs.length; i++) { + aggregation.namedExprs[i] = (NamedExpr) namedExprs[i].clone(); + } } - aggregation.groups = new GroupElement[groups.length]; - for (int i = 0; i < groups.length; i++) { - aggregation.groups[i] = (GroupElement) groups[i].clone(); + if (groups != null) { + aggregation.groups = new GroupElement[groups.length]; + for (int i = 0; i < groups.length; i++) { + aggregation.groups[i] = (GroupElement) groups[i].clone(); + } }
- alter.addNewColumn = (ColumnDefinition) addNewColumn.clone(); + if (addNewColumn != null) { + alter.addNewColumn = (ColumnDefinition) addNewColumn.clone(); + }
- Recursive (BetweenPredicate.java)
- between.begin = (Expr) between.clone(); + between.begin = (Expr) begin.clone();
- Type Casting Error (ValueListExpr.java)
- valueListExpr.values = (Expr[]) values[i].clone(); + valueListExpr.values[i] = (Expr) values[i].clone();
- Functional Error (CreateTable.java)
- if (range.specifiers != null) { + if (specifiers != null) {