Redshift UDF中的murmur2软件包导入失败

时间:2018-10-12 11:12:31

标签: python amazon-redshift user-defined-functions murmurhash

我正在尝试将murmur2软件包作为Redshift数据库中的库导入。我做了以下步骤

  1. 运行模块打包程序
    $ ./installPipModuleAsRedshiftLibrary.sh -m murmur2 -s s3://path/to/murmur2/lib

  2. 在redshift上创建库
    CREATE OR REPLACE LIBRARY murmur2 LANGUAGE plpythonu from 's3://path/to/murmur2/lib/murmur2.zip' WITH CREDENTIALS AS 'aws_access_key_id=AAAAAAAAAAAAAAAAAAAA;aws_secret_access_key=SSSSSSSSSSSSSSSSS' region 'us-east-1';

  3. 创建函数并查询

    create OR REPLACE function f_py_kafka_partitioner (s varchar, ps int)
    returns int stable as $$ import murmur2
    m2 = murmur2.murmur64a(s, len(s), 0x9747b28c)
    return m2 % ps
    $$ language plpythonu;

SELECT f_py_kafka_partitioner('jiimit', 100);

这将导致以下错误:

[Amazon](500310) Invalid operation: ImportError: No module named murmur2. Please look at svl_udf_log for more information
Details: 
 -----------------------------------------------
  error:  ImportError: No module named murmur2. Please look at svl_udf_log for more information
  code:      10000
  context:   UDF
  query:     0
  location:  udf_client.cpp:366
  process:   padbmaster [pid=31381]
  -----------------------------------------------;

这是svl_udf_log的内容

0   ImportError: No module named murmur2 2018-10-14 07:05:43.431561 line 2, in f_py_kafka_partitioner\n  f_py_kafka_partitioner  1000 20000 0

文件夹结构如下所示
Murmur2 Directory tree

0 个答案:

没有答案