FAQ
I'm writing a python UDF that returns a tuple with three fields. I'm wondering if it's ok to return None if for some reason I can't build the tuple, but don't want to throw an Exception and stop processing.

For example, on a much-simplified version of the UDF:

@outputSchema('t:tuple(a:int, b:int, c:int)')
def get_tpl(input):
if input < 5:
return (1, 2, 3)
else:
return None;

Should I be returning None or (None, None, None). Also, will there be any type issues if I return None back instead of a int?

Thanks,
Doug

Search Discussions

  • Alan Gates at Sep 29, 2011 at 11:17 pm
    Returning None should result in that tuple being null, which is exactly what you want when something is wrong but you don't want to break the entire process.

    Alan.
    On Sep 29, 2011, at 3:56 PM, Doug Daniels wrote:

    I'm writing a python UDF that returns a tuple with three fields. I'm wondering if it's ok to return None if for some reason I can't build the tuple, but don't want to throw an Exception and stop processing.

    For example, on a much-simplified version of the UDF:

    @outputSchema('t:tuple(a:int, b:int, c:int)')
    def get_tpl(input):
    if input < 5:
    return (1, 2, 3)
    else:
    return None;

    Should I be returning None or (None, None, None). Also, will there be any type issues if I return None back instead of a int?

    Thanks,
    Doug

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriespig, hadoop
postedSep 29, '11 at 10:56p
activeSep 29, '11 at 11:17p
posts2
users2
websitepig.apache.org

2 users in discussion

Doug Daniels: 1 post Alan Gates: 1 post

People

Translate

site design / logo © 2021 Grokbase