Linhong Liu created SPARK-61560:
-----------------------------------

             Summary: Data Source V2 push-down evaluates time-zone-dependent 
datetime fields of a TIMESTAMP in the source's zone instead of the session time 
zone
                 Key: SPARK-61560
                 URL: https://issues.apache.org/jira/browse/SPARK-61560
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 5.0.0
            Reporter: Linhong Liu


Under a non-UTC session time zone, V2 push-down translates time-zone-dependent 
casts and datetime field extractions of a TIMESTAMP (e.g. hour(ts), 
dayofmonth(ts) which reads CAST(ts AS DATE)) to V2 Extract/Cast, which carry no 
time zone. JDBC exchanges timestamps in the JVM default zone, so the remote 
source evaluates the field in its own zone and a filter like WHERE hour(ts) = 
21 returns wrong rows when the session time zone differs from the JVM default.

Fix: in V2ExpressionBuilder, do not push a zone-dependent cast or datetime 
field extraction when the expression's time zone does not have the rules of the 
JVM default time zone; Spark then evaluates it in the session time zone. A new 
legacy conf spark.sql.legacy.dataSource.pushDownDatetimeIgnoringTimeZone 
(default false) restores the previous behavior. Found via correctness analysis.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to