Python 无法在vertica_sdk中使用TransformFunction

Python 无法在vertica_sdk中使用TransformFunction,python,vertica,vsql,Python,Vertica,Vsql,我要做的是执行vertica的字符串标记器示例,该示例是用python编写的 下面是指向上述示例的链接:Vertica |开发%20用户定义的%20扩展%20(UDxs)|转换%20函数%20(UDTFs)| Python%20API | | 2 这就是我的代码的样子 import vertica_sdk class StringTokenizer(vertica_sdk.TransformFunction): """ Transform function which token

我要做的是执行vertica的字符串标记器示例,该示例是用python编写的

下面是指向上述示例的链接:Vertica |开发%20用户定义的%20扩展%20(UDxs)|转换%20函数%20(UDTFs)| Python%20API | | 2

这就是我的代码的样子

import vertica_sdk
class StringTokenizer(vertica_sdk.TransformFunction):
    """
    Transform function which tokenizes its inputs.
    For each input string, each of the whitespace-separated tokens of that
    string is produced as output.
    """
    def processPartition(self, server_interface, input, output):
        while True:
            for token in input.getString(0).split():
                output.setString(0, token)
                output.next()
            if not input.next():
                break


class StringTokenizerFactory(vertica_sdk.TransformFunctionFactory):
    def getPrototype(self, server_interface, arg_types, return_type):
        arg_types.addVarchar()
        return_type.addVarchar()
    def getReturnType(self, server_interface, arg_types, return_type):
        return_type.addColumn(arg_types.getColumnType(0), "tokens")
    def createTransformFunction(cls, server_interface):
        return StringTokenizer()

这是我执行命令时得到的输出

create library sampy as '/home/dbadmin/udx/tokenize.py' language 'Python';
输出
ROLLBACK 2175:在节点v_prmtest_node001上加载库文件时出错,消息:
UDx RPC调用InvokeCeckLibrary()失败:在用户定义对象[]中调用setupExecContext()时出错,位于[/scratch_a/release/svrtar19690/vbuild/vertica/OSS/UDxFence/PythonInterface.cpp:168]函数['import']处,错误代码:0,消息:错误[/scratch_a/release/svrtar19690/vbuild/vertica/OSS/UDxFence/PythonInterface.cpp:204]
(Python错误类型[])
回溯(最近一次呼叫最后一次):
文件“/home/dbadmin/PRMTEST/v_PRMTEST_node001_catalog/Libraries/02D86D505E41731D3615E9E9DA31AFC00B0000000561680/sampy_02D86D505E41731D3615E9E31AFC00B0000000561680.py”,第2行,在
类StringTokenizer(vertica_sdk.TransformFunction):
AttributeError:模块“vertica_sdk”没有属性“TransformFunction”
在wards上的vertica版本9中提供了转换功能。 我无法在上执行代码的原因是因为我使用的是Vertica版本8。Python用户定义的转换函数仅在Vertica版本9或更高版本中受支持。可以为java、C++或R.</P>编写Vista 8的UDDFS
ROLLBACK 2175:  An error occurred when loading library file on node v_prmtest_node0001, message:
Failure in UDx RPC call InvokeCheckLibrary(): Error calling setupExecContext() in User Defined Object [] at [/scratch_a/release/svrtar19690/vbuild/vertica/OSS/UDxFence/PythonInterface.cpp:168], error code: 0, message: Error [/scratch_a/release/svrtar19690/vbuild/vertica/OSS/UDxFence/PythonInterface.cpp:204] function ['import']
(Python error type [<class 'AttributeError'>])
Traceback (most recent call last):
  File "/home/dbadmin/PRMTEST/v_prmtest_node0001_catalog/Libraries/02d86d505e41731d36151e9e9da31afc00b0000000561680/sampy_02d86d505e41731d36151e9e9da31afc00b0000000561680.py", line 2, in <module>
    class StringTokenizer(vertica_sdk.TransformFunction):
AttributeError: module 'vertica_sdk' has no attribute 'TransformFunction'