alamb commented on code in PR #27547:
URL: https://github.com/apache/datafusion/pull/27547#discussion_r4632610736


##########
datafusion/functions/src/datetime/date_trunc.rs:
##########
@@ -710,6 +721,16 @@ where
     1 + 3 * ((date.month() - 1) / 3)
 }
 
+/// The granularity `precision` always evaluates to, if that is known.
+fn constant_granularity(precision: &ExprProperties) -> Option<DatePart> {
+    let range = &precision.range;
+    if range.lower() != range.upper() {
+        return None;
+    }
+    let granularity = range.lower().try_as_str().flatten()?;

Review Comment:
   Why not compare the relevant rust types?



##########
datafusion/functions/src/datetime/date_trunc.rs:
##########
@@ -710,6 +721,16 @@ where
     1 + 3 * ((date.month() - 1) / 3)
 }
 
+/// The granularity `precision` always evaluates to, if that is known.
+fn constant_granularity(precision: &ExprProperties) -> Option<DatePart> {
+    let range = &precision.range;
+    if range.lower() != range.upper() {
+        return None;
+    }
+    let granularity = range.lower().try_as_str().flatten()?;

Review Comment:
   do we really have to convert to a string here?



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