I don't have HSTORE as a datatype in my PostgreSQL installation, so I can't test for definite... I'd normally expect FME to read in column types it doesn't recognise as TEXT (that's what it does with JSON and JSONB columns anyway).
If it doesn't do that for you, you could just alter the SELECT query on your reader (in the properties, under the Format Parameters tab), and add a direct cast, something like my_hstore_column::text, or even my_hstore_column -> value, if you don't mind pulling each value out one by one.
Once you've got it into FME, it should be parsable using one of the string transformers?
Hi @kouri1986, I tested it with FME 2016.1, and found that the PostgreSQL and PostGIS readers recognize an hstore type column as a text type column, and the value will be read as a 'comma-separated pairs of key and value', like this.
"bar"=>"9", "foo"=>"1", "foobar"=>"abc"
You can parse it with some string transformers, but I think it would be easier if you converted it to a JSON document using the hstore_to_json function or similar one, by setting the SELECT Statement parameter of the reader feature type. e.g.
select *, hstore_to_json(h) as x from your_table
Here, h is an hstore type column, and x will store a JSON doc like this.
{"bar": "9", "foo": "1", "foobar": "abc"}
Expose x with the AttributeExposer. You can then flatten the JSON doc to create attributes for each key-value pair with the JSONFlattener transformer.
I don't have HSTORE as a datatype in my PostgreSQL installation, so I can't test for definite... I'd normally expect FME to read in column types it doesn't recognise as TEXT (that's what it does with JSON and JSONB columns anyway).
If it doesn't do that for you, you could just alter the SELECT query on your reader (in the properties, under the Format Parameters tab), and add a direct cast, something like my_hstore_column::text, or even my_hstore_column -> value, if you don't mind pulling each value out one by one.
Once you've got it into FME, it should be parsable using one of the string transformers?
Hi @rollo, hstore is an extension for PostgreSQL/PostGIS database. You can add the extension with this SQL statement to any existing database.
create extension hstore;
Hi @kouri1986, I tested it with FME 2016.1, and found that the PostgreSQL and PostGIS readers recognize an hstore type column as a text type column, and the value will be read as a 'comma-separated pairs of key and value', like this.
"bar"=>"9", "foo"=>"1", "foobar"=>"abc"
You can parse it with some string transformers, but I think it would be easier if you converted it to a JSON document using the hstore_to_json function or similar one, by setting the SELECT Statement parameter of the reader feature type. e.g.
select *, hstore_to_json(h) as x from your_table
Here, h is an hstore type column, and x will store a JSON doc like this.
{"bar": "9", "foo": "1", "foobar": "abc"}
Expose x with the AttributeExposer. You can then flatten the JSON doc to create attributes for each key-value pair with the JSONFlattener transformer.
Found a variation. You can flatten an hstore value (comma-separated 'key=>value') directly with the JSONFlattener by setting this expression to the JSON Document parameter. With this way, you don't need to write SQL statement.
{@ReplaceString(@Value(hstore_value),=>,:)}