MaxGekk commented on code in PR #55952:
URL: https://github.com/apache/spark/pull/55952#discussion_r3273487562


##########
sql/api/src/main/scala/org/apache/spark/sql/types/TimestampLTZNanosType.scala:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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
+
+import org.apache.spark.annotation.Unstable
+import org.apache.spark.sql.errors.DataTypeErrors
+
+/**
+ * Timestamp with local time zone with fractional-second precision in the 
nanosecond-capable range
+ * (7 to 9 decimal digits). Represents a time instant analogous to 
`TimestampType`, but with
+ * sub-microsecond precision: valid range is [0001-01-01T00:00:00.000000000Z,
+ * 9999-12-31T23:59:59.999999999Z] in the proleptic Gregorian calendar at 
UTC+00:00. No time zone
+ * is stored; the session time zone is used when converting values to and from 
text.
+ *
+ * @param precision
+ *   Number of digits of fractional seconds for this SQL type. The valid 
values are 7, 8, and 9
+ *   where 9 means nanosecond precision.
+ *
+ * @since 4.2.0
+ */
+@Unstable
+case class TimestampLTZNanosType(precision: Int) extends DatetimeType {

Review Comment:
   First of all, because the SPIP 
https://docs.google.com/document/d/1DeW15QueI4PdRyPm6C6jsTZFmIjbXX2j4h-Ja5W_fsg/edit?usp=sharing
 defines this class with such name. Probably you might ask why I named it in 
this way in the SPIP. So, there are a few reasons:
   
   1. **Pairs with TimestampNTZNanosType.** Spark already has two SQL timestamp 
families: with local time zone (TimestampType / TIMESTAMP_LTZ) and without 
(TimestampNTZType / TIMESTAMP_NTZ). The nanosecond-capable types are the same 
split. Alone TimestampNanosType reads as “the” nano timestamp type and does not 
signal which semantics apply.
   
   2. **Matches SQL and typeName.** The class backs timestamp_ltz(p). 
TimestampLTZNanosType lines up with TimestampNTZNanosType and with the SPIP/SQL 
names; TimestampNanosType would mirror neither timestamp_ntz nor the explicit 
TIMESTAMP_LTZ(n) surface.
   
   3. **Consistency with how Spark names the NTZ side.** TimestampType omits 
“LTZ” for history (timestamp defaulted to session-local semantics), but 
TimestampNTZType is explicit because the second variant exists. For new APIs 
where both variants are first-class, being explicit on both sides avoids the 
ambiguity that already bites people (TimestampType vs “timestamp with TZ” in 
docs).
   
   4. **Safer for pattern matches and downstream code.** Much of the codebase 
branches TimestampType vs TimestampNTZType. TimestampLTZNanosType + 
TimestampNTZNanosType extend that model predictably; TimestampNanosType would 
be assumed LTZ-by-analogy-to-TimestampType, which is easy to get wrong in 
reviews and refactors.



-- 
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]

Reply via email to