defaultvalue = defaultvalue.replace('\n', ' ');
defaultvalue = defaultvalue.replace('\r', ' ');
}
// fyi: Historically, VoltType class initialization errors get reported on this line (?).
VoltType type = VoltType.typeFromString(typename);
columnTypes.put(index, type);
if (defaultFuncID == -1) {
if (defaultvalue != null && (type == VoltType.DECIMAL || type == VoltType.NUMERIC)) {
// Until we support deserializing scientific notation in the EE, we'll
// coerce default values to plain notation here. See ENG-952 for more info.
BigDecimal temp = new BigDecimal(defaultvalue);
defaultvalue = temp.toPlainString();
}
} else {
// Concat function name and function id, format: NAME:ID
// Used by PlanAssembler:getNextInsertPlan().
defaultvalue = defaultvalue + ":" + String.valueOf(defaultFuncID);
}
Column column = table.getColumns().add(name);
// need to set other column data here (default, nullable, etc)
column.setName(name);
column.setIndex(index);
column.setType(type.getValue());
column.setNullable(Boolean.valueOf(nullable));
int size = type.getMaxLengthInBytes();
boolean inBytes = false;
if (node.attributes.containsKey("bytes")) {
inBytes = Boolean.valueOf(node.attributes.get("bytes"));
}
// Require a valid length if variable length is supported for a type
if (type == VoltType.STRING || type == VoltType.VARBINARY) {
if (sizeString == null) {
// An unspecified size for a VARCHAR/VARBINARY column should be
// for a materialized view column whose type is derived from a
// function or expression of variable-length type.
// Defaulting these to MAX_VALUE_LENGTH tends to cause them to overflow the
// allowed MAX_ROW_SIZE when there are more than one in a view.
// It's not clear what benefit, if any, we derive from limiting MAX_ROW_SIZE
// based on worst-case length for variable fields, but we comply for now by
// arbitrarily limiting these matview column sizes such that
// the max number of columns of this size would still fit.
size = MAX_ROW_SIZE / MAX_COLUMNS;
} else {
int userSpecifiedSize = Integer.parseInt(sizeString);
if (userSpecifiedSize < 0 || (inBytes && userSpecifiedSize > VoltType.MAX_VALUE_LENGTH)) {
String msg = type.toSQLString() + " column " + name +
" in table " + table.getTypeName() + " has unsupported length " + sizeString;
throw m_compiler.new VoltCompilerException(msg);
}
if (!inBytes && type == VoltType.STRING) {
if (userSpecifiedSize > VoltType.MAX_VALUE_LENGTH_IN_CHARACTERS) {