You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/02/27 11:19:24 UTC

[GitHub] [druid] sascha-coenen edited a comment on issue #9417: SQL: improve division behaviour

sascha-coenen edited a comment on issue #9417: SQL: improve division behaviour
URL: https://github.com/apache/druid/issues/9417#issuecomment-591918423
 
 
   > Btw, I've never seen a one-arg NVL function.
   
   yeah. missing an arg. alternatively NULLIF(denominator, 0)
   
   > For the 1/NULL case, I think we should probably return NULL instead of throwing an error.
   
   that would be perfect 
   
   > Would adding that function solve your problem?
   
   yes, it would make things more concise.
   I mentioned the function DIV(nominator, denominator, null-fallback) above which is probably similar to their SAFE_DIVIDE function. 
   Having this as an infix operator rather than in function syntax would be even nicer so that there are less nesting levels, but I guess that's out of the question.
   
   Most importantly though, for this to be a perfectly useful function, it would have to divide numerically, meaning DIV(1, 2) should be 0.5 not 0.
   I would argue that user experience trumps technical arguments. So in the real world the expectation of 1 divided by 2 is 0.5 Having equal types is nice from a technical perspective, but to quote Steve Jobs, one should start with the user perspective and work one's way backwards to technology. (https://www.youtube.com/watch?v=r2O5qKZlI50)
   Also why have two different ways to do integer division and none for numerical division, so to even out the scales I would petition for having this DIV() function apply numerical division.
   
   Although it also has to be said that DIV usually represents integer division (https://www.w3schools.com/sql/func_mysql_div.asp) so it would be misleading to have it be a numerical division in Druid, so a different name like SAFE_DIV would be better I think.
   It is sad that databases differ so much on what "/" is doing. Since decimal division is the common case, IT should be the default, especially in the context of having a DIV function for doing the integer division. 
   Paragon of consistency indeed, lol :D

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org