[ 
https://issues.apache.org/jira/browse/MADLIB-1204?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Frank McQuillan updated MADLIB-1204:
------------------------------------
    Fix Version/s: v1.14

> madpack: SQL result parsing is fragile
> --------------------------------------
>
>                 Key: MADLIB-1204
>                 URL: https://issues.apache.org/jira/browse/MADLIB-1204
>             Project: Apache MADlib
>          Issue Type: Bug
>          Components: Madpack
>            Reporter: Rahul Iyer
>            Priority: Major
>             Fix For: v1.14
>
>
> For a reinstall operation, {{madpack}} looks at any possible affected objects 
> that will dropped using below query: 
> {code}
>   affected_objects = _internal_run_query("""
>             SELECT
>                 n1.nspname AS schema,
>                 relname AS relation,
>                 attname AS column,
>                 typname AS type
>             FROM
>                 pg_attribute a,
>                 pg_class c,
>                 pg_type t,
>                 pg_namespace n,
>                 pg_namespace n1
>             WHERE
>                 n.nspname = '%s'
>                 AND t.typnamespace = n.oid
>                 AND a.atttypid = t.oid
>                 AND c.oid = a.attrelid
>                 AND c.relnamespace = n1.oid
>                 AND c.relkind = 'r'
>             ORDER BY
>                 n1.nspname, relname, attname, typname""" % schema.lower(), 
> True)
> {code}
> The results of this query is parsed line-by-line in the function 
> {{run_query}}. 
> For my database, a clean reinstall gives following result for above query
> {code}
>  schema | relation | column | type
> --------+----------+--------+------
> (0 rows)
> {code}
> This is parsed as
> {code}
> [{'schema': '(0 rows)'}]
> {code} by the function, which is clearly incorrect and leads to an error in 
> subsequent lines: 
> {code}
>   File ".../madpack/madpack.py", line 1366, in <module>
>     main(sys.argv[1:])
>   File ".../madpack/madpack.py", line 1136, in main
>     ao['column'] + ' : ' + ao['type'], True)
> KeyError: 'relation'
> {code} 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to