shamim8888 / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

If-Then-Else statements should allow for production of different types from then/else branches #676

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
use dataverse Metadata;

if (true) then
null
else
1

What is the expected output?
null

What do you see instead?
The two branches of the if-else clause should return the same type. 
[AlgebricksException]

Original issue reported on code.google.com by zheilb...@gmail.com on 18 Nov 2013 at 9:10

GoogleCodeExporter commented 9 years ago
Is null the only case that we need (i.e. would it be good enough if the 
resulting type in the example were integer?) or do we also need 

if (condition) then
  "result"
else
  { "type": "object" }

?

Original comment by westm...@gmail.com on 19 Nov 2013 at 5:23

GoogleCodeExporter commented 9 years ago
I'm going to blindly say that it would be nice to have arbitrary types as your 
examples shows, but "blindly" because I don't know the work it entails.

Original comment by zheilb...@gmail.com on 19 Nov 2013 at 8:14

GoogleCodeExporter commented 9 years ago
Could this be related to issue 218 ? 

Original comment by khfaraaz82 on 19 Nov 2013 at 9:10

GoogleCodeExporter commented 9 years ago
No, the scenario in 218 throws an NPE, returns the same type, and is part of a 
UDF.

Original comment by zheilb...@gmail.com on 19 Nov 2013 at 9:12

GoogleCodeExporter commented 9 years ago
We should relax the requirement that the two types (then and else) be the same 
to be either the two types should be the same or one of them should be null.

Original comment by vinay...@x15soft.com on 3 Dec 2013 at 8:33

GoogleCodeExporter commented 9 years ago

Original comment by zheilb...@gmail.com on 3 Dec 2013 at 9:35

GoogleCodeExporter commented 9 years ago
Fixed by allowing null + T or T + T, but not T + Q as Vinayak suggested.

Keeping this issue open but de-escalating from MSRBlocker as we should 
eventually allow for T + Q.

Original comment by zheilb...@gmail.com on 6 Dec 2013 at 10:25

GoogleCodeExporter commented 9 years ago
Zach, you already did "null + T or T + T, but not T + Q ", correct?   I'm 
working on it.  If you did that, I can switch to work on another one.

Original comment by buyingyi@gmail.com on 6 Dec 2013 at 10:28