我的python UDF代码,诞生了来自Pig的日期时间变量, 我尝试将它作为字符串对象,但它也给出了错误, 并将其视为日期时间对象也给出了错误
Dim oval
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
oval = Target.Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C2:C1048576")) Is Nothing Then
Range("G" & Target.Row) = Now()
Range("H" & Target.Row) = oval
End If
End Sub
我收到错误:
TypeError:' org.joda.time.DateTime'对象是不可取消的
from datetime import date
@outputSchema("age_key:chararray")
def agekeyed(born):
today = date.today()
return born[:4]
答案 0 :(得分:0)
born
是org.joda.time.DateTime
对象,此处不能应用子字符串。
你需要将一个chararray
从猪传递到udf,或用它的方法处理对象
rightnow.monthOfYear().getAsText()