@@ -21,7 +21,7 @@ package org.apache.comet.serde
2121
2222import java .util .Locale
2323
24- import org .apache .spark .sql .catalyst .expressions .{Attribute , Cast , Concat , ConcatWs , Elt , Expression , FindInSet , FormatNumber , FormatString , GetJsonObject , If , InitCap , IsNull , Left , Length , Levenshtein , Like , Literal , Lower , Overlay , RegExpExtract , RegExpExtractAll , RegExpInStr , RegExpReplace , Right , RLike , SoundEx , StringLocate , StringLPad , StringRepeat , StringReplace , StringRPad , StringSplit , Substring , SubstringIndex , ToCharacter , ToNumber , UnBase64 , Upper }
24+ import org .apache .spark .sql .catalyst .expressions .{Attribute , BitLength , Cast , Concat , ConcatWs , Elt , Expression , FindInSet , FormatNumber , FormatString , GetJsonObject , If , InitCap , IsNull , Left , Length , Levenshtein , Like , Literal , Lower , OctetLength , Overlay , RegExpExtract , RegExpExtractAll , RegExpInStr , RegExpReplace , Right , RLike , SoundEx , StringLocate , StringLPad , StringRepeat , StringReplace , StringRPad , StringSplit , StringTranslate , Substring , SubstringIndex , ToCharacter , ToNumber , UnBase64 , Upper }
2525import org .apache .spark .sql .types .{BinaryType , DataTypes , LongType , StringType }
2626import org .apache .spark .unsafe .types .UTF8String
2727
@@ -84,6 +84,35 @@ object CometLength extends CometScalarFunction[Length]("length") {
8484 }
8585}
8686
87+ object CometBitLength extends CometScalarFunction [BitLength ](" bit_length" ) {
88+ override def getUnsupportedReasons (): Seq [String ] = Seq (" `BinaryType` input is not supported" )
89+
90+ override def getSupportLevel (expr : BitLength ): SupportLevel = expr.child.dataType match {
91+ case _ : BinaryType => Unsupported (Some (" bit_length on BinaryType is not supported" ))
92+ case _ => Compatible ()
93+ }
94+ }
95+
96+ object CometOctetLength extends CometScalarFunction [OctetLength ](" octet_length" ) {
97+ override def getUnsupportedReasons (): Seq [String ] = Seq (" `BinaryType` input is not supported" )
98+
99+ override def getSupportLevel (expr : OctetLength ): SupportLevel = expr.child.dataType match {
100+ case _ : BinaryType => Unsupported (Some (" octet_length on BinaryType is not supported" ))
101+ case _ => Compatible ()
102+ }
103+ }
104+
105+ object CometStringTranslate extends CometScalarFunction [StringTranslate ](" translate" ) {
106+ private val incompatReason =
107+ " DataFusion's translate iterates over Unicode graphemes (Spark uses code points) and" +
108+ " substitutes U+0000 instead of treating it as a deletion sentinel"
109+
110+ override def getIncompatibleReasons (): Seq [String ] = Seq (incompatReason)
111+
112+ override def getSupportLevel (expr : StringTranslate ): SupportLevel = Incompatible (
113+ Some (incompatReason))
114+ }
115+
87116object CometInitCap extends CometScalarFunction [InitCap ](" initcap" ) {
88117
89118 override def getSupportLevel (expr : InitCap ): SupportLevel = Compatible ()
0 commit comments