dbatomic commented on code in PR #46166: URL: https://github.com/apache/spark/pull/46166#discussion_r1592549183
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CollationKey.scala: ########## @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalyst.expressions + +import java.util.Locale + +import org.apache.spark.sql.catalyst.expressions.codegen.{CodegenContext, ExprCode} +import org.apache.spark.sql.catalyst.util.{CollationFactory, GenericArrayData} +import org.apache.spark.sql.internal.types.{AbstractArrayType, StringTypeAnyCollation} +import org.apache.spark.sql.types.{AbstractDataType, ArrayType, DataType, StringType, StructType, TypeCollection} +import org.apache.spark.unsafe.types.UTF8String + +case class CollationKey(expr: Expression) extends UnaryExpression with ExpectsInputTypes { Review Comment: So, this is saying that `CollationKey` for Array(string) will return Array(string), but string data will be garbage for ICU collations - it will just be constructed from binary representation of collation key, which may not even be valid UTF8 codes. Also, that "garbage" data will still go through comparison rules for string of given collation (instead it should be just binary comparison). Is it cleaner to just say that CollationKey is a StringType -> Binary transformation? Then other layers can take care of array and struct transformations? Also second part can be a separate PR. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org