madlib-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Verges <cver...@medallia.com>
Subject JSONB and MADLib
Date Sat, 17 Nov 2018 06:14:39 GMT
Hi MADLib users,

I have a table that contains a JSONB field (Postgres 10.x) and am now
looking to analyze all that rich data with MADLib.  Example query:

SELECT madlib.linregr_train (
  'regr_example',         -- source table
  'regr_example_model',   -- output model table
  '(data->>''y'')::int',     -- dependent variable
  'ARRAY[1, (data->>''x1'')::int, (data->>''x2'')::int]'      --
independent variables
);


However, it looks like MADLib isn't liking using these fields when it comes
to creating the temporary table:

ERROR:  spiexceptions.SyntaxError: syntax error at or near "')::int'"
LINE 7:                     , '(data->>'y')::int'::varchar      as d...
                                         ^
QUERY:
            create table regr_example_model_summary as
                select
                      'linregr'::varchar                  as method
                    , 'regr_example'::varchar           as source_table
                    , 'regr_example_model'::varchar              as
out_table
                    , '(data->>'y')::int'::varchar      as dependent_varname
                    , 'ARRAY[1, (data->>'x1')::int,
(data->>'x2')::int]'::varchar    as independent_varname
                    , 0::integer       as num_rows_processed
                    , 4::integer         as num_missing_rows_skipped
                    , NULL::text                as grouping_col

CONTEXT:  Traceback (most recent call last):
  PL/Python function "linregr_train", line 20, in <module>
    return linear.linregr_train(**globals())
  PL/Python function "linregr_train", line 146, in linregr_train
PL/Python function "linregr_train"


Are there recipes or examples of using JSONB with MADLib?  Is this a known
limit?

Thanks for the guidance,
Chris

Mime
View raw message