kz930 commented on code in PR #8907:
URL: https://github.com/apache/texera/pull/8907#discussion_r4382381771


##########
common/workflow-core/src/main/scala/org/apache/texera/amber/core/tuple/AttributeTypeUtils.scala:
##########
@@ -228,6 +245,69 @@ object AttributeTypeUtils extends Serializable {
 
   }
 
+  /**
+    * Epoch millis of a zone-less ISO local date-time, `yyyy-MM-dd` optionally
+    * followed by `[ T]HH:mm[:ss[.f]]` with 1-9 fraction digits, or 
Long.MinValue
+    * when `s` is not exactly that shape or names no real date-time.
+    *
+    * This is the form a CSV timestamp column usually holds, and the general 
date
+    * parser spends most of a scan's time on it. For a zone-less string that 
parser
+    * sets these same fields on a fresh default Calendar, so doing that here 
gives
+    * the identical instant; anything else falls through to the parser 
unchanged.
+    */
+  private def parseIsoLocalMillis(s: String): Long = {
+    val len = s.length
+    if (len != 10 && len != 16 && len < 19) return Long.MinValue
+    def digit(i: Int): Int = {
+      val c = s.charAt(i)
+      if (c >= '0' && c <= '9') c - '0' else -1000
+    }
+    def twoDigits(i: Int): Int = digit(i) * 10 + digit(i + 1)
+
+    if (s.charAt(4) != '-' || s.charAt(7) != '-') return Long.MinValue
+    val year = digit(0) * 1000 + digit(1) * 100 + twoDigits(2)

Review Comment:
   A non-digit in the 4th year position slips through, because `digit()` 
returns -1000 and the year stays positive. For example, `202a-01-05` now parses 
as 1020-01-05, while `DateParser` rejects it, so could the fast path return 
`Long.MinValue` on any non-digit and add such inputs to the comparison test?



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

Reply via email to