Re: Documentation for maths operations between different types?

2019-08-19 Thread Divya Gehlot
Hi ,
Can someone help me guide through to start with  update the Drill
documentation by adding the missing functions ?
Appreciate the pointers / link to update the Drill doc and how  can I
gather all the information and create the JIRA for it ?

Thanks,
Divya

On Sat, 17 Aug 2019 at 01:06, Paul Rogers  wrote:

> Hi Divya,
>
> Would be great to add to the docs. First step is to gather the info in a
> JIRA ticket. Then, someone (thanks for volunteering) can update the various
> tables in the docs.
>
> I believe that the documentation is generated via some process other than
> a direct edit of the MD files in the repo. Perhaps someone can fill in the
> details about how to update the material.
>
> When writing the Learning Apache Drill book, Charles found that many
> functions are not documented in the "official" documentation. Would be
> great to review the function tables in the book and apply any missing
> information to the Drill documentation.
>
> Thanks,
> - Paul
>
>
>
> On Friday, August 16, 2019, 08:25:14 AM PDT, Divya Gehlot <
> divinediv...@gmail.com> wrote:
>
>  Can we add this as part of Drill Function docs , will be useful for other
> ppl as well ?
> I can help to add , unsure if I have access to edit Drill doc
>
> Thanks ,
> Divya
>
> On Fri, 16 Aug 2019 at 01:04, Paul Rogers 
> wrote:
>
> > Hi Dave,
> >
> > As it turns out, improving the detail in function documentation is a
> > long-standing request. The historical answer has been to either 1) read
> the
> > code, or 2) try it with a test query.
> >
> > You can use the sqlTypeOf() function to learn the answer to your
> question:
> >
> > SELECT sqlTypeOf(cast(1 AS INT) / cast(2 AS INT)) FROM values(1)
> >
> > Charles Givre patiently tracked down and documented all the Drill
> > functions in his appendix to our book "Learning Apache Drill." But, even
> > there, the level of detail you request is missing.
> >
> > Maybe, once you do the research to find the answers you want, you could
> > submit a Documentation JIRA ticket with the results so that it can be
> added
> > to the documentation.
> >
> > Thanks,
> > - Paul
> >
> >
> >
> >On Thursday, August 15, 2019, 03:55:11 AM PDT, Dave Challis <
> > dave.chal...@cipher.ai> wrote:
> >
> >  Is there any documentation out there on how mathematical functions are
> > handled when operating on different types?
> >
> > E.g.:
> >
> > * would integer division of 1 / 2 produce a float or double of 0.5? Or an
> > integer of the same type set to 0?
> >
> > * if two INT are multipled and produce a result larger than INT can
> > support, is the result returned as a BIGINT?
> >
>


Re: Documentation for maths operations between different types?

2019-08-16 Thread Paul Rogers
Hi Divya,

Would be great to add to the docs. First step is to gather the info in a JIRA 
ticket. Then, someone (thanks for volunteering) can update the various tables 
in the docs.

I believe that the documentation is generated via some process other than a 
direct edit of the MD files in the repo. Perhaps someone can fill in the 
details about how to update the material.

When writing the Learning Apache Drill book, Charles found that many functions 
are not documented in the "official" documentation. Would be great to review 
the function tables in the book and apply any missing information to the Drill 
documentation.

Thanks,
- Paul

 

On Friday, August 16, 2019, 08:25:14 AM PDT, Divya Gehlot 
 wrote:  
 
 Can we add this as part of Drill Function docs , will be useful for other
ppl as well ?
I can help to add , unsure if I have access to edit Drill doc

Thanks ,
Divya

On Fri, 16 Aug 2019 at 01:04, Paul Rogers  wrote:

> Hi Dave,
>
> As it turns out, improving the detail in function documentation is a
> long-standing request. The historical answer has been to either 1) read the
> code, or 2) try it with a test query.
>
> You can use the sqlTypeOf() function to learn the answer to your question:
>
> SELECT sqlTypeOf(cast(1 AS INT) / cast(2 AS INT)) FROM values(1)
>
> Charles Givre patiently tracked down and documented all the Drill
> functions in his appendix to our book "Learning Apache Drill." But, even
> there, the level of detail you request is missing.
>
> Maybe, once you do the research to find the answers you want, you could
> submit a Documentation JIRA ticket with the results so that it can be added
> to the documentation.
>
> Thanks,
> - Paul
>
>
>
>    On Thursday, August 15, 2019, 03:55:11 AM PDT, Dave Challis <
> dave.chal...@cipher.ai> wrote:
>
>  Is there any documentation out there on how mathematical functions are
> handled when operating on different types?
>
> E.g.:
>
> * would integer division of 1 / 2 produce a float or double of 0.5? Or an
> integer of the same type set to 0?
>
> * if two INT are multipled and produce a result larger than INT can
> support, is the result returned as a BIGINT?
>
  

Re: Documentation for maths operations between different types?

2019-08-16 Thread Paul Rogers
Hi Dave,

Charles and I added the sqlTypeOf() function while writing the book so we could 
clearly explain types. Drill also has a SQL-standard function, typeOf(), but 
this tends to report "NULL" if the value is null, regardless of type, which 
made it hard to explain the behavior of nullable types (which are the kind most 
often used in Drill...)

The other way to check this is to find the template used to generate the math 
functions. See [1]. This template is fed by a table in [2]. Turns out that 
table will answer your original question:


      {className: "Divide", funcName: "divide", op: "/", types: [
          {input1: "Int", input2: "Int", outputType: "Int", castType: "int"},

That is, for a (INT, INT) input to divide, the output is also INT.

To answer your other question: I believe Drill does type promotion, but I don't 
know the details. For example, is INT + INT an INT or a BIGINT? Is a SHORT + 
INT an INT or a BIGINT? The info is not in the table referenced above, but is 
probably available in the template or surrounding files.

Thanks,
- Paul

[1] 
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/codegen/templates/MathFunctions.java
[2] 
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/codegen/data/MathFunctionTypes.tdd



On Friday, August 16, 2019, 07:09:58 AM PDT, Dave Challis 
 wrote:  
 
 Thanks Paul, I hadn't seen sqlTypeOf before, that looks perfect for
checking this sort of thing.

Dave

On Thu, 15 Aug 2019 at 18:04, Paul Rogers  wrote:

> Hi Dave,
>
> As it turns out, improving the detail in function documentation is a
> long-standing request. The historical answer has been to either 1) read the
> code, or 2) try it with a test query.
>
> You can use the sqlTypeOf() function to learn the answer to your question:
>
> SELECT sqlTypeOf(cast(1 AS INT) / cast(2 AS INT)) FROM values(1)
>
> Charles Givre patiently tracked down and documented all the Drill
> functions in his appendix to our book "Learning Apache Drill." But, even
> there, the level of detail you request is missing.
>
> Maybe, once you do the research to find the answers you want, you could
> submit a Documentation JIRA ticket with the results so that it can be added
> to the documentation.
>
> Thanks,
> - Paul
>
>
>
>    On Thursday, August 15, 2019, 03:55:11 AM PDT, Dave Challis <
> dave.chal...@cipher.ai> wrote:
>
>  Is there any documentation out there on how mathematical functions are
> handled when operating on different types?
>
> E.g.:
>
> * would integer division of 1 / 2 produce a float or double of 0.5? Or an
> integer of the same type set to 0?
>
> * if two INT are multipled and produce a result larger than INT can
> support, is the result returned as a BIGINT?
>
  

Re: Documentation for maths operations between different types?

2019-08-16 Thread Divya Gehlot
Can we add this as part of Drill Function docs , will be useful for other
ppl as well ?
I can help to add , unsure if I have access to edit Drill doc

Thanks ,
Divya

On Fri, 16 Aug 2019 at 01:04, Paul Rogers  wrote:

> Hi Dave,
>
> As it turns out, improving the detail in function documentation is a
> long-standing request. The historical answer has been to either 1) read the
> code, or 2) try it with a test query.
>
> You can use the sqlTypeOf() function to learn the answer to your question:
>
> SELECT sqlTypeOf(cast(1 AS INT) / cast(2 AS INT)) FROM values(1)
>
> Charles Givre patiently tracked down and documented all the Drill
> functions in his appendix to our book "Learning Apache Drill." But, even
> there, the level of detail you request is missing.
>
> Maybe, once you do the research to find the answers you want, you could
> submit a Documentation JIRA ticket with the results so that it can be added
> to the documentation.
>
> Thanks,
> - Paul
>
>
>
> On Thursday, August 15, 2019, 03:55:11 AM PDT, Dave Challis <
> dave.chal...@cipher.ai> wrote:
>
>  Is there any documentation out there on how mathematical functions are
> handled when operating on different types?
>
> E.g.:
>
> * would integer division of 1 / 2 produce a float or double of 0.5? Or an
> integer of the same type set to 0?
>
> * if two INT are multipled and produce a result larger than INT can
> support, is the result returned as a BIGINT?
>


Re: Documentation for maths operations between different types?

2019-08-16 Thread Dave Challis
Thanks Paul, I hadn't seen sqlTypeOf before, that looks perfect for
checking this sort of thing.

Dave

On Thu, 15 Aug 2019 at 18:04, Paul Rogers  wrote:

> Hi Dave,
>
> As it turns out, improving the detail in function documentation is a
> long-standing request. The historical answer has been to either 1) read the
> code, or 2) try it with a test query.
>
> You can use the sqlTypeOf() function to learn the answer to your question:
>
> SELECT sqlTypeOf(cast(1 AS INT) / cast(2 AS INT)) FROM values(1)
>
> Charles Givre patiently tracked down and documented all the Drill
> functions in his appendix to our book "Learning Apache Drill." But, even
> there, the level of detail you request is missing.
>
> Maybe, once you do the research to find the answers you want, you could
> submit a Documentation JIRA ticket with the results so that it can be added
> to the documentation.
>
> Thanks,
> - Paul
>
>
>
> On Thursday, August 15, 2019, 03:55:11 AM PDT, Dave Challis <
> dave.chal...@cipher.ai> wrote:
>
>  Is there any documentation out there on how mathematical functions are
> handled when operating on different types?
>
> E.g.:
>
> * would integer division of 1 / 2 produce a float or double of 0.5? Or an
> integer of the same type set to 0?
>
> * if two INT are multipled and produce a result larger than INT can
> support, is the result returned as a BIGINT?
>


Re: Documentation for maths operations between different types?

2019-08-15 Thread Paul Rogers
Hi Dave,

As it turns out, improving the detail in function documentation is a 
long-standing request. The historical answer has been to either 1) read the 
code, or 2) try it with a test query.

You can use the sqlTypeOf() function to learn the answer to your question:

SELECT sqlTypeOf(cast(1 AS INT) / cast(2 AS INT)) FROM values(1)

Charles Givre patiently tracked down and documented all the Drill functions in 
his appendix to our book "Learning Apache Drill." But, even there, the level of 
detail you request is missing.

Maybe, once you do the research to find the answers you want, you could submit 
a Documentation JIRA ticket with the results so that it can be added to the 
documentation.

Thanks,
- Paul

 

On Thursday, August 15, 2019, 03:55:11 AM PDT, Dave Challis 
 wrote:  
 
 Is there any documentation out there on how mathematical functions are
handled when operating on different types?

E.g.:

* would integer division of 1 / 2 produce a float or double of 0.5? Or an
integer of the same type set to 0?

* if two INT are multipled and produce a result larger than INT can
support, is the result returned as a BIGINT?
  

Documentation for maths operations between different types?

2019-08-15 Thread Dave Challis
Is there any documentation out there on how mathematical functions are
handled when operating on different types?

E.g.:

* would integer division of 1 / 2 produce a float or double of 0.5? Or an
integer of the same type set to 0?

* if two INT are multipled and produce a result larger than INT can
support, is the result returned as a BIGINT?