@@ -961,6 +961,62 @@ case class TryValidateUTF8(input: Expression) extends RuntimeReplaceable with Im
961961
962962}
963963
964+ /**
965+ * A function that returns the Unicode normalization of a string.
966+ */
967+ // scalastyle:off
968+ @ ExpressionDescription (
969+ usage = """
970+ _FUNC_(str[, form]) - Returns the Unicode normalization of `str` using the normalization `form`.
971+ Valid forms are 'NFC' (default), 'NFD', 'NFKC', and 'NFKD'. The form name is case-insensitive.
972+ """ ,
973+ arguments = """
974+ Arguments:
975+ * str - a string expression to normalize.
976+ * form - a string expression giving the normalization form: 'NFC', 'NFD', 'NFKC', or 'NFKD'.
977+ If omitted, 'NFC' is used.
978+ """ ,
979+ examples = """
980+ Examples:
981+ > SELECT _FUNC_('fi', 'NFKC');
982+ fi
983+ """ ,
984+ since = " 4.3.0" ,
985+ group = " string_funcs" )
986+ // scalastyle:on
987+ case class Normalize (input : Expression , form : Expression )
988+ extends RuntimeReplaceable with ImplicitCastInputTypes with BinaryLike [Expression ] {
989+ override def nullIntolerant : Boolean = true
990+
991+ override lazy val replacement : Expression =
992+ StaticInvoke (
993+ classOf [ExpressionImplUtils ],
994+ input.dataType,
995+ " normalize" ,
996+ Seq (input, form),
997+ inputTypes)
998+
999+ def this (input : Expression ) = this (input, Literal (" NFC" ))
1000+
1001+ override def inputTypes : Seq [AbstractDataType ] =
1002+ Seq (StringTypeWithCollation (supportsTrimCollation = true ),
1003+ StringTypeWithCollation (supportsTrimCollation = true ))
1004+
1005+ override def nodeName : String = " normalize"
1006+
1007+ override def nullable : Boolean = true
1008+
1009+ override def left : Expression = input
1010+
1011+ override def right : Expression = form
1012+
1013+ override protected def withNewChildrenInternal (
1014+ newLeft : Expression , newRight : Expression ): Normalize = {
1015+ copy(input = newLeft, form = newRight)
1016+ }
1017+
1018+ }
1019+
9641020/**
9651021 * Replace all occurrences with string.
9661022 */
0 commit comments