LuciferYang commented on code in PR #59545:
URL: https://github.com/apache/spark/pull/59545#discussion_r4346099229


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/constraints.scala:
##########
@@ -142,6 +160,17 @@ case class CheckConstraint(
       .build()
   }
 
+  /**
+   * Whether the rules that compute the current time, date, catalog and the 
like change part of `e`,

Review Comment:
   Updated in e2322baf889. The scaladoc of `readsCurrentContext` now uses your 
wording, the comment above `toV2Constraint` says why the predicate is not built 
from the analyzed condition and that CREATE and REPLACE TABLE convert their 
constraints before analysis finishes, and the comment of the `nullif` test says 
why it uses `nullif`.
   



##########
sql/core/src/test/scala/org/apache/spark/sql/execution/command/v2/CheckConstraintSuite.scala:
##########
@@ -170,6 +170,60 @@ class CheckConstraintSuite extends QueryTest with 
CommandSuiteBase with DDLComma
     }
   }
 
+  test("SPARK-60032: Check constraint added by ALTER TABLE reading the current 
time") {
+    // The check compares with the time of the write, not the time of the 
ALTER TABLE.
+    Seq(
+      ("TIMESTAMP", "current_timestamp()", "current_timestamp()", "INTERVAL 1 
DAY"),
+      ("TIMESTAMP", "CAST('now' AS TIMESTAMP)", "current_timestamp()", 
"INTERVAL 1 DAY"),

Review Comment:
   Confirmed: `>=` rejects a row written with `current_timestamp()` and `<=` 
accepts it. The test comment now says that 'now' is read after the snapshot 
`current_timestamp()` takes.
   



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