Skip to content

DateTime backend exception following User Defined Function #4106

Closed

Description

@BenComer98

What happened?

Release: 1.1.0
Platform: Windows, using Powershell
UI: Google Chrome

Background: I'm trying to use a User Defined Function to define a Priority Score for a dataset I'm using. To do so, I'm using a standard CSV File scan to pull in data from a csv. I've attached the CSV as a dataset, I'm pulling it through a UDF that adds a field "priority_score," and I'm sorting in descending order by that score. The execution unit crashes and produces the error shown in the log section.

I have attached the files I used to produce this error. I tried using a smaller, made-up-for-this-issue csv, but it didn't error out.

appointments.csv <- CSV

Issue Repro.json <- Exported Issue repro

How to reproduce?

  1. Add a dataset containing appointments.csv to Texera.
  2. Add a Workflow. In that Workflow, add a CSV File Scan, a Python UDF (normal, no variation), and a Sort, and connect them in that order.
  3. In the CSV File Scan, select the appointments.csv file with headers on.
  4. In the Python UDF, add a new field called "priority_score" with type double and paste the following:
    `from pytexera import *
    from datetime import date
    import math

class ProcessTupleOperator(UDFOperatorV2):

@overrides
def process_tuple(self, tuple_: Tuple, port: int) -> Iterator[Optional[TupleLike]]:
    appointment_date = tuple_["appointment_datetime"].date()

    today = date.today()
    days_until = (appointment_date - today).days
    if days_until >= 0:
        tuple_["priority_score"] = 1 / math.log(days_until + 2) + 1
    else:
        tuple_["priority_score"] = 0.0

    # Output the tuple
    yield tuple_

`
5. In the Sort function, sort by priority_score DESC.
6. Add a Computing Unit and Run. Your backend will throw errors.

Version

1.1.0-incubating (Pre-release/Master)

Commit Hash (Optional)

No response

What browsers are you seeing the problem on?

No response

Relevant log output

texera-computing-unit-master            | [2025-12-05 00:08:11,439] [WARN] [edu.uci.ics.amber.util.ArrowUtils$] [flight-server-default-executor-0] - Caught error during parsing Arrow value back to Texera value
texera-computing-unit-master            | edu.uci.ics.amber.core.tuple.AttributeTypeUtils$AttributeTypeException: Failed to parse type java.time.LocalDateTime to Timestamp: 2026-09-05T01:01:12
texera-computing-unit-master            |       at edu.uci.ics.amber.core.tuple.AttributeTypeUtils$$anonfun$parseTimestamp$2.applyOrElse(AttributeTypeUtils.scala:219)
texera-computing-unit-master            |       at edu.uci.ics.amber.core.tuple.AttributeTypeUtils$$anonfun$parseTimestamp$2.applyOrElse(AttributeTypeUtils.scala:215)
texera-computing-unit-master            |       at scala.util.Failure.recover(Try.scala:233)
texera-computing-unit-master            |       at edu.uci.ics.amber.core.tuple.AttributeTypeUtils$.parseTimestamp(AttributeTypeUtils.scala:215)
texera-computing-unit-master            |       at edu.uci.ics.amber.core.tuple.AttributeTypeUtils$.parseField(AttributeTypeUtils.scala:128)
texera-computing-unit-master            |       at edu.uci.ics.amber.util.ArrowUtils$.$anonfun$getTexeraTuple$1(ArrowUtils.scala:82)
texera-computing-unit-master            |       at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100)
texera-computing-unit-master            |       at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87)
texera-computing-unit-master            |       at scala.collection.convert.JavaCollectionWrappers$JCollectionWrapper.map(JavaCollectionWrappers.scala:98)
texera-computing-unit-master            |       at edu.uci.ics.amber.util.ArrowUtils$.getTexeraTuple(ArrowUtils.scala:77)
texera-computing-unit-master            |       at edu.uci.ics.amber.engine.architecture.pythonworker.AmberProducer.$anonfun$acceptPut$2(PythonProxyServer.scala:143)
texera-computing-unit-master            |       at edu.uci.ics.amber.engine.architecture.pythonworker.AmberProducer.$anonfun$acceptPut$2$adapted(PythonProxyServer.scala:142)
texera-computing-unit-master            |       at scala.collection.immutable.Range.foreach(Range.scala:190)
texera-computing-unit-master            |       at edu.uci.ics.amber.engine.architecture.pythonworker.AmberProducer.$anonfun$acceptPut$1(PythonProxyServer.scala:142)
texera-computing-unit-master            |       at org.apache.arrow.flight.FlightService.lambda$doPutCustom$0(FlightService.java:233)
texera-computing-unit-master            |       at io.grpc.Context$1.run(Context.java:566)
texera-computing-unit-master            |       at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
texera-computing-unit-master            |       at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
texera-computing-unit-master            |       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
texera-computing-unit-master            |       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
texera-computing-unit-master            |       at java.base/java.lang.Thread.run(Thread.java:829)
texera-computing-unit-master            | Caused by: edu.uci.ics.amber.core.tuple.AttributeTypeUtils$AttributeTypeException: Unsupported type for parsing to Timestamp: java.time.LocalDateTime
texera-computing-unit-master            |       at edu.uci.ics.amber.core.tuple.AttributeTypeUtils$.$anonfun$parseTimestamp$1(AttributeTypeUtils.scala:209)
texera-computing-unit-master            |       at scala.util.Try$.apply(Try.scala:210)
texera-computing-unit-master            |       at edu.uci.ics.amber.core.tuple.AttributeTypeUtils$.parseTimestamp(AttributeTypeUtils.scala:202)

Activity

  1. added theissue type on Dec 5, 2025
  2. chenlica commented on Dec 5, 2025

    @chenlica
    Contributor

    @BenComer98 Thanks for the reporting the issue. @aglinxinyuan Can you take a look?

  3. aglinxinyuan commented on Dec 5, 2025

    @aglinxinyuan
    Contributor

    ok

  4. aglinxinyuan commented on Dec 5, 2025

    @aglinxinyuan
    Contributor

    I followed the steps and cannot reproduce the error.

    The workflow runs ok.
    Image
    workflow.json

    Maybe @yunyad can give it a try?

  5. chenlica commented on Dec 5, 2025

    @chenlica
    Contributor

    @yunyad Please try it as well.

  6. BenComer98 commented on Dec 5, 2025

    @BenComer98
    Author

    I followed the steps and cannot reproduce the error.

    The workflow runs ok. Image workflow.json

    Maybe @yunyad can give it a try?

    I copied over this workflow to my local setup. It still errors for me in the same way. I'm suspecting this may be a local issue. I'm going to try a fresh install to see if that resolves it.

  7. yunyad commented on Dec 5, 2025

    @yunyad
    Contributor

    I remember encountering this error locally before; it was caused by a timezone issue with Python datetimes.
    This time I’m unable to reproduce it.

  8. Yicong-Huang commented on Dec 6, 2025

    @Yicong-Huang
    Contributor

    I notice the platform is windows. maybe we need windows for repro?

  9. aglinxinyuan commented on Dec 6, 2025

    @aglinxinyuan
    Contributor

    I notice the platform is windows. maybe we need windows for repro?

    I used Windows and cannot reproduce it.

  10. carloea2 commented on Dec 26, 2025

    @carloea2
    Contributor

    I used windows and I can reproduce it

    Image
  11. carloea2 commented on Dec 26, 2025

    @carloea2
    Contributor

    Reason: fieldValue is a java.time.LocalDateTime, not a java.sql.Timestamp, so none of the String / Long / Timestamp / Date cases match and it falls into case _ => and throws.

    @throws[AttributeTypeException]
    def parseTimestamp(fieldValue: Any): Timestamp = {
    val attempt: Try[Timestamp] = Try {
    fieldValue match {
    case str: String => new Timestamp(DateParserUtils.parseDate(str.trim).getTime)
    case long: java.lang.Long => new Timestamp(long)
    case timestamp: Timestamp => timestamp
    case date: java.util.Date => new Timestamp(date.getTime)
    // Integer, Double, Boolean, Binary are considered to be illegal here.
    case _ =>
    throw new AttributeTypeException(
    s"Unsupported type for parsing to Timestamp: ${fieldValue.getClass.getName}"
    )

    Image
  12. chenlica commented on Dec 28, 2025

    @chenlica
    Contributor

    @carloea2 Per our discussion, please raise a PR to fix this issue.

  13. carloea2 commented on Dec 28, 2025

    @carloea2
    Contributor

    @carloea2 Per our discussion, please raise a PR to fix this issue.

    #4139

  14. chenlica commented on Dec 29, 2025

    @chenlica
    Contributor

    It's fixed in #4139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions