[jira] Commented: (PIG-385) Should support 'null' as a constant

2008-12-03 Thread Olga Natkovich (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653041#action_12653041
 ] 

Olga Natkovich commented on PIG-385:


Pig-538 that I just committed solves adds this functionality. Will keep this 
bug open till we add a few more test cases.

> Should support 'null' as a constant
> ---
>
> Key: PIG-385
> URL: https://issues.apache.org/jira/browse/PIG-385
> Project: Pig
>  Issue Type: New Feature
>  Components: impl
>Affects Versions: types_branch
>Reporter: Alan Gates
>Priority: Minor
> Fix For: types_branch
>
>
> It would be nice to be able to do things like:
> B = foreach A generate $0 > 0 ? $0 : null;
> but right now null is not allowed as a constant.  This null constant should 
> be allowed anywhere an expression would be, and should be castable (that is 
> (int)null).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (PIG-385) Should support 'null' as a constant

2008-11-18 Thread Santhosh Srinivasan (JIRA)

[ 
https://issues.apache.org/jira/browse/PIG-385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12648872#action_12648872
 ] 

Santhosh Srinivasan commented on PIG-385:
-

The NULL constant can be used in any context where other constants or 
expressions are used. The difference between constants and NULL constants will 
be the type inference. The interred type for NULL will be based on the context. 
For example, in the statement used in the bug report (shown below for 
reference), the type of null will be the same as the type of $0. By default, 
the type of null will be a bytearray.

{code}

B = foreach A generate $0 > 0 ? $0 : null;

{code}

Casting null
-

If the user chooses to, he/she can cast the null to the appropriate type. For 
example:

{code}

B = foreach A generate $0 > 0 ? $0 : (int)null;

{code}

Use of null with complex types
---

Since complex types are made of simple types, the same rules (as stated above) 
apply. Null constant as map keys will be disallowed.

Examples follow:

{code}

B = foreach A generate $0 > 0 ? $0 : {(null)};
-- here we have a bag with a tuple with a bytearray null constant

C = foreach A generate [2#null];
-- a map constant with key 2 and value bytearray null

D = foreach A generate [null#10];
--- error maps cannot have null keys
{code}

Open questions
--

1. When nulls are stored using PigStorage and then read back using PigStorage, 
a distinction between the various types of null cannot be made.

Thoughts/suggestions/comments welcome.

> Should support 'null' as a constant
> ---
>
> Key: PIG-385
> URL: https://issues.apache.org/jira/browse/PIG-385
> Project: Pig
>  Issue Type: New Feature
>  Components: impl
>Affects Versions: types_branch
>Reporter: Alan Gates
>Priority: Minor
> Fix For: types_branch
>
>
> It would be nice to be able to do things like:
> B = foreach A generate $0 > 0 ? $0 : null;
> but right now null is not allowed as a constant.  This null constant should 
> be allowed anywhere an expression would be, and should be castable (that is 
> (int)null).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.