cloud-fan commented on code in PR #54223: URL: https://github.com/apache/spark/pull/54223#discussion_r2852006200
########## sql/api/src/main/scala/org/apache/spark/sql/types/ops/FormatTypeOps.scala: ########## @@ -0,0 +1,112 @@ +/* + * 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.types.ops + +import org.apache.spark.sql.types.DataType +import org.apache.spark.unsafe.types.UTF8String + +/** + * Operations for formatting values as strings. + * + * PURPOSE: Handles string formatting for display and SQL output. This includes formatting values + * for CAST to STRING, EXPLAIN output, SHOW commands, and SQL literals. + * + * USAGE CONTEXT - examples of use: + * - ToStringBase.scala - CAST(x AS STRING) expressions + * - EXPLAIN output - displaying literal values + * - SHOW commands - displaying column values + * - SQL generation - creating SQL literal representations + * - HiveResult.scala - formatting results for Thrift/JDBC + * + * @see + * TimeTypeApiOps for reference implementation + * @since 4.1.0 + */ +trait FormatTypeOps extends TypeApiOps { + + /** + * Formats an internal value as a display string. + * + * This method converts the internal Catalyst representation to a human-readable string suitable + * for display or CAST to STRING operations. + * + * @param v + * The internal value (e.g., Long nanoseconds for TimeType) + * @return + * Formatted string (e.g., "10:30:45.123456") + * @example + * 37800000000000L -> "10:30:00" (for TIME) + */ + def format(v: Any): String Review Comment: ditto -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
