https://pinot.apache.org/ logo
Join Slack
Powered by
# udf-type-matching
  • x

    Xiang Fu

    11/08/2021, 7:41 PM
    set the channel topic: https://github.com/MeihanLi/pinot/pull/1
  • x

    Xiang Fu

    11/08/2021, 7:41 PM
    set the channel description: https://github.com/MeihanLi/pinot/pull/1
  • y

    Yupeng Fu

    11/08/2021, 7:41 PM
    thanks
  • y

    Yupeng Fu

    11/08/2021, 7:42 PM
    folks, created a channel to discuss https://github.com/MeihanLi/pinot/pull/1
  • y

    Yupeng Fu

    11/08/2021, 7:43 PM
    we see more and more users run into this issue
  • y

    Yupeng Fu

    11/08/2021, 7:43 PM
    and it's a concerning one, as it could return incorrect result silently
  • y

    Yupeng Fu

    11/08/2021, 7:43 PM
    any suggestions on having a stop-gap sooner?
  • a

    Amrish Lal

    11/08/2021, 7:54 PM
    I agree that this is concerning, although I am not quite sure if there is a good enough stop-gap fix that is available. Seems to me that any stop-gap fix would still suffer from some of the type issues that we see now. So, at the very least it would be good to know what our final solution would be to fix this issue before we start adding stop-gap fixes.
  • y

    Yupeng Fu

    11/08/2021, 8:03 PM
    makes sense. we can discuss the ideal state, and then see if there's opportunity to have some easy solution to approximate
  • y

    Yupeng Fu

    11/08/2021, 8:04 PM
    add @User @User too, since i brought this up a while ago to them
  • y

    Yupeng Fu

    11/08/2021, 8:07 PM
    my thoughts is to have a typing hierarchy from high precision to low precision. so any high precision will short-circuit and map to its corresponding implementation
  • j

    Jackie

    11/08/2021, 9:47 PM
    Ideally we should pick the same way as how java performs the type matching (high to low precision, and implicit type conversion)
  • y

    Yupeng Fu

    11/08/2021, 9:53 PM
    good point
  • y

    Yupeng Fu

    11/08/2021, 10:08 PM
    we need to implement this implicit cast rule https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements002.htm#g195937
  • a

    Amrish Lal

    11/08/2021, 11:10 PM
    we would also need to detect if implicit conversion is lossy. For example, while java allows implicit conversion of
    long
    to
    double
    , that conversion is lossy.
    Copy code
    public static void main(String[] args) {
      long l = 8223372036854775802l;
      double d = l;
      long f = (long) d;
    
      System.out.println("Original Long Value      : " + l);
      System.out.println("Intermediate Double Value: " + d);
      System.out.println("Final Long Value         : " + f);
    
      System.out.println( l == f ? "Not a lossy conversion" : "Lossy conversion");
    }
    If we convert a
    long
    value to
    double
    and then convert the resulting
    double
    value back to
    long
    , then the final
    long
    value may not be same as initial
    long
    value due to lossy conversion of
    long
    to
    double
    . Currently the output type of all functions in
    ArithmeticFunctions.java
    is set to
    double
    .
  • y

    Yupeng Fu

    11/08/2021, 11:19 PM
    interesting
  • y

    Yupeng Fu

    11/08/2021, 11:20 PM
    also add @User to this channel, as there was a similar conv on a PR review
  • a

    Amrish Lal

    11/08/2021, 11:25 PM
    Adding @User as well, since he had a few thoughts regarding scalar functions using templates.