Dandandan commented on a change in pull request #9373:
URL: https://github.com/apache/arrow/pull/9373#discussion_r570153622



##########
File path: rust/datafusion/src/sql/planner.rs
##########
@@ -894,6 +908,131 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             ))),
         }
     }
+
+    fn sql_interval_to_literal(
+        &self,
+        value: &String,
+        leading_field: &Option<DateTimeField>,
+        leading_precision: &Option<u64>,
+        last_field: &Option<DateTimeField>,
+        fractional_seconds_precision: &Option<u64>,
+    ) -> Result<Expr> {
+        if leading_field.is_some() {
+            return Err(DataFusionError::NotImplemented(format!(
+                "Unsupported Interval Expression with leading_field {:?}",
+                leading_field
+            )));
+        }
+
+        if leading_precision.is_some() {
+            return Err(DataFusionError::NotImplemented(format!(
+                "Unsupported Interval Expression with leading_precision {:?}",
+                leading_precision
+            )));
+        }
+
+        if last_field.is_some() {
+            return Err(DataFusionError::NotImplemented(format!(
+                "Unsupported Interval Expression with last_field {:?}",
+                last_field
+            )));
+        }
+
+        if fractional_seconds_precision.is_some() {
+            return Err(DataFusionError::NotImplemented(format!(
+                "Unsupported Interval Expression with 
fractional_seconds_precision {:?}",
+                fractional_seconds_precision
+            )));
+        }
+
+        // Should we resort parts on overflow?
+        let resort_parts = |days: i32, seconds: f32| -> (i32, f32) { (days, 
seconds) };
+
+        let calculate_from_part =
+            |interval_period_str: &str, interval_type: &str| -> Result<(i32, 
f32)> {
+                let interval_period = match interval_period_str.parse::<f32>() 
{

Review comment:
       I am not sure whether rounding errors are going to be a problem, I could 
imagine some calculation might cause for example the number of milliseconds to 
be off for non-trivial fractions?
   In that case we should use some decimal type instead of `f32` in order to 
avoid those rounding errors.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to