### Question:
CastParseNode extends UnaryParseNode { @Override public void toSQL(ColumnResolver resolver, StringBuilder buf) { List<ParseNode> children = getChildren(); buf.append(" CAST("); children.get(0).toSQL(resolver, buf); buf.append(" AS "); boolean isArray = dt.isArrayType(); PDataType type = isArray ? PDataType.arrayBaseType(dt) : dt; buf.append(type.getSqlTypeName()); if (maxLength != null) { buf.append('('); buf.append(maxLength); if (scale != null) { buf.append(','); buf.append(scale); } buf.append(')'); } if (isArray) { buf.append(' '); buf.append(PDataType.ARRAY_TYPE_SUFFIX); } buf.append(")"); } CastParseNode(ParseNode expr, String dataType, Integer maxLength, Integer scale, boolean arr);   CastParseNode(ParseNode expr, PDataType dataType, Integer maxLength, Integer scale, boolean arr); @Override T accept(ParseNodeVisitor<T> visitor); PDataType getDataType(); Integer getMaxLength(); Integer getScale(); @Override int hashCode(); @Override boolean equals(Object obj); @Override void toSQL(ColumnResolver resolver, StringBuilder buf);  }### Answer:
@Test public void testToSQL() { ColumnParseNode columnParseNode = new ColumnParseNode(TableName.create("SCHEMA1", "TABLE1"), "V"); CastParseNode castParseNode = new CastParseNode(columnParseNode, PLong.INSTANCE, null, null, false); StringBuilder stringBuilder = new StringBuilder(); castParseNode.toSQL(null, stringBuilder); assertEquals(" CAST(TABLE1.V AS BIGINT)", stringBuilder.toString()); }
@Test public void testToSQL_WithLengthAndScale() { ColumnParseNode columnParseNode = new ColumnParseNode(TableName.create("SCHEMA1", "TABLE1"), "V"); CastParseNode castParseNode = new CastParseNode(columnParseNode, PDecimal.INSTANCE, 5, 3, false); StringBuilder stringBuilder = new StringBuilder(); castParseNode.toSQL(null, stringBuilder); assertEquals(" CAST(TABLE1.V AS DECIMAL(5,3))", stringBuilder.toString()); }
@Test public void testToSQL_ArrayType() { ColumnParseNode columnParseNode = new ColumnParseNode(TableName.create("SCHEMA1", "TABLE1"), "V"); CastParseNode castParseNode = new CastParseNode(columnParseNode, PLong.INSTANCE, null, null, true); StringBuilder stringBuilder = new StringBuilder(); castParseNode.toSQL(null, stringBuilder); assertEquals(" CAST(TABLE1.V AS BIGINT ARRAY)", stringBuilder.toString()); }