2010YOUY01 commented on code in PR #11571:
URL: https://github.com/apache/datafusion/pull/11571#discussion_r1685701612


##########
datafusion/functions/src/math/log.rs:
##########
@@ -82,7 +82,13 @@ impl ScalarUDFImpl for LogFunc {
     }
 
     fn output_ordering(&self, input: &[ExprProperties]) -> 
Result<SortProperties> {
-        match (input[0].sort_properties, input[1].sort_properties) {
+        let (base_sort_properties, num_sort_properties) = if input.len() == 1 {
+            // log(x) defaults to log(10, x)
+            (SortProperties::Singleton, input[0].sort_properties)

Review Comment:
   This change makes sense to me 👍🏼 



##########
datafusion/functions/src/math/log.rs:
##########
@@ -82,7 +82,13 @@ impl ScalarUDFImpl for LogFunc {
     }
 
     fn output_ordering(&self, input: &[ExprProperties]) -> 
Result<SortProperties> {
-        match (input[0].sort_properties, input[1].sort_properties) {
+        let (base_sort_properties, num_sort_properties) = if input.len() == 1 {
+            // log(x) defaults to log(10, x)
+            (SortProperties::Singleton, input[0].sort_properties)
+        } else {
+            (input[0].sort_properties, input[1].sort_properties)
+        };
+        match (num_sort_properties, base_sort_properties) {

Review Comment:
   Looks like the following logic is not completely correct 🤔 
   e.g.
   base is `DESC NULLS FIRST`
   num is `ASC NULLS LAST`
   This implementation will return `log(base, num)` is `ASC NULLS LAST`
   But the actual output might look like
   ```
   NULL
   NULL
   1
   2
   NULL
   ```
   Which is unordered.



-- 
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: github-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to