hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruilong Huo (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HAWQ-815) KeyError while compiling PLPython function due to deletion of non-existent record from Python global dict
Date Tue, 14 Jun 2016 15:02:01 GMT
Ruilong Huo created HAWQ-815:
--------------------------------

             Summary: KeyError while compiling PLPython function due to deletion of non-existent
record from Python global dict
                 Key: HAWQ-815
                 URL: https://issues.apache.org/jira/browse/HAWQ-815
             Project: Apache HAWQ
          Issue Type: Bug
          Components: Query Execution
            Reporter: Ruilong Huo
            Assignee: George Caragea


It raise KeyError while compiling PLPython function due to deletion of non-existent record
from Python global dict. Below are two example to reproduce the issue:

Example 1:
{noformat}
-- 1) prepare schema and data
CREATE LANGUAGE plpythonu;

CREATE TABLE gp_single_row(a int) DISTRIBUTED BY (a);
INSERT INTO gp_single_row VALUES (1);

CREATE OR REPLACE FUNCTION test_return_table(s TEXT)
RETURNS TABLE(first TEXT, second INT4)
AS $$
   exec('y = ' + s)
   return y
$$ LANGUAGE plpythonu;

SELECT (test_return_table('[]')).*;
SELECT (test_return_table('[]')).*
FROM gp_single_row;

-- 2) Actual output
SELECT (test_return_table('[]')).*;
 first | second
-------+--------
(0 rows)

SELECT (test_return_table('[]')).*
FROM gp_single_row;
ERROR:  could not compile PL/Python function "test_return_table" (plpython.c:4651)  (seg5
test1:31100 pid=36826) (dispatcher.c:1801)
DETAIL:  KeyError: 's'

-- 3) Expected output
SELECT (test_return_table('[]')).*;
 first | second
-------+--------
(0 rows)

SELECT (test_return_table('[]')).*
FROM gp_single_row;
 first | second
-------+--------
(0 rows)
{noformat}
Example 2:
{noformat}
-- 1) prepare schema and data
CREATE LANGUAGE plpythonu;

CREATE OR REPLACE FUNCTION func1(var_cause_bug int4[])
RETURNS SETOF INT4 AS $$
for el in var_cause_bug:
    yield el
$$ LANGUAGE plpythonu;

CREATE OR REPLACE FUNCTION func2()
RETURNS INT4 AS $$
return 1
$$ LANGUAGE plpythonu;

SELECT func1(ARRAY[1,2,3]), func1(ARRAY[1,2,3]);
SELECT func2();

-- 2) Actual output
SELECT func1(ARRAY[1,2,3]), func1(ARRAY[1,2,3]);
 func1 | func1 
-------+-------
     1 |     1
     2 |     2
     3 |     3
(3 rows)

SELECT func2();
ERROR:  could not compile PL/Python function "func2" (plpython.c:4648)
DETAIL:  KeyError: 'var_cause_bug'

-- 3) Expected output
SELECT func1(ARRAY[1,2,3]), func1(ARRAY[1,2,3]);
 func1 | func1
-------+-------
     1 |     1
     2 |     2
     3 |     3
(3 rows)

SELECT func2();
 func2
-------
     1
(1 row)
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message