Consider the "constant" value: DefaultEncoding. Typically we would add it to the companion object:
object Strlen {
val DefaultEncoding = "ISO-8859-1"
..
}
However, we are compelled to avoid the use of a companion object because Strlen is required to be a case class to correspond to code structures/conventions in a significant existing codebase:
case class Strlen(child: Expression, encoding : Expression) extends UnaryExpression with LengthExpression {
val DefaultEncoding = "ISO-8859-1" // This will not be isible in the following constructor
def this(child: Expression) = this(child, new Literal(DefaultEncoding, StringType))
So then would there be any way to achieve compartmentalization of the DefaultEncoding 'constant' within the case class?
Update From suggestion by wingedsubmariner, I tried the following within the case class:
def DefaultEncoding = "ISO-8859-1"
However it does not compile
[info] Compiling 1 Scala source to /shared/spark-master/sql/catalyst/target/scala-2.10/classes...
[error] /shared/spark-master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala:253: not found: value DefaultEncoding
[error] def this(child: Expression) = this(child, new Literal(/* StrConstants. */DefaultEncoding, StringType))
[error]