i'm trying return datetime object python udf use in pig script (note i'm simplfying problem here, actual udf thing lot more complex returning current time object returned same):
pig version 0.12.1, hortonworks distribution.
my udf follows:
@outputschema("timenowschema") def time_now(dt): return datetime.datetime.now() @outputschema("timenowschema") def timenowschema(dt): dt = [datatype.datetime] return schemautil.newtupleschema(dt) however, when using udf following:
org.apache.pig.backend.executionengine.execexception: error 0: non supported pig datatype found, cast failed: org.python.core.pyobjectderived looking in responsible org.apache.pig.scripting.jython.jythonutils pigtopython function, see there no apparent means carry out conversion, despite datatype.datetime allowable returntype.
is there way return datetime/timestamp object pig process datetime?
update: i've tried returning time.struct_time object instead. still doesn't work, though @ least function completes: however, tuple returned pig instead, not datetime object want:
[python] time.struct_time(tm_year=2000, tm_mon=11, tm_mday=30, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=335, tm_isdst=-1) [pig] ((2000,11,30,0,0,0,0,0,-1)) update 2 i'm outputting iso formatted datetime string udf, per fred's suggestion. after poking around in pig source, doesn't yet possible.
Comments
Post a Comment