tree: d3e223a5648afce1fa4809ecf2f1d66cac80d481 [path history] [tgz]
  1. expected/
  2. po/
  3. sql/
  4. .gitignore
  5. generate-spiexceptions.pl
  6. init_file
  7. Makefile
  8. nls.mk
  9. plpy_cursorobject.c
  10. plpy_cursorobject.h
  11. plpy_elog.c
  12. plpy_elog.h
  13. plpy_exec.c
  14. plpy_exec.h
  15. plpy_main.c
  16. plpy_main.h
  17. plpy_planobject.c
  18. plpy_planobject.h
  19. plpy_plpymodule.c
  20. plpy_plpymodule.h
  21. plpy_procedure.c
  22. plpy_procedure.h
  23. plpy_resultobject.c
  24. plpy_resultobject.h
  25. plpy_spi.c
  26. plpy_spi.h
  27. plpy_subxactobject.c
  28. plpy_subxactobject.h
  29. plpy_typeio.c
  30. plpy_typeio.h
  31. plpy_util.c
  32. plpy_util.h
  33. plpython.h
  34. plpython2u--1.0.sql
  35. plpython2u.control
  36. plpython3u--1.0.sql
  37. plpython3u.control
  38. plpython_system.h
  39. plpythonu--1.0.sql
  40. plpythonu.control
  41. README.md
  42. regress-python3-mangle.mk
src/pl/plpython/README.md

Python3 Support

How to build:

# Install Python3 (take centos7 as example)
yum install -y python36-devel

# Configure build environment to install at /usr/local/gpdb
PYTHON=/usr/bin/python3.6 ./configure --with-perl --with-python --with-libxml --prefix=/usr/local/gpdb

# Compile and install
make -j8
make -j8 install

How to use:

# Ensure your environment include the SAME python version as the build environment, in our example is Python3.6.
# If you install Python in a non-system folder, you also need to add $PYTHONHOME/lib into your shared library path.
yum install -y python36-devel

# Install Python3 packages:
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
pip3 install numpy

# Test Python3 support in GPDB 
CREATE LANGUAGE plpython3u;
CREATE FUNCTION import_succeed() returns text AS $$
  import sys
  import numpy
  return "succeeded, as expected"
$$ LANGUAGE plpython3u;
SELECT import_succeed();

CREATE TYPE named_value AS (
         name  text,
         value  integer);

CREATE OR REPLACE FUNCTION make_pair_sets (name text)
RETURNS SETOF named_value AS $$
  import numpy as np
  return ((name, i) for i in np.arange(1))
$$ LANGUAGE plpython3u;

SELECT * from make_pair_sets('test');