I am trying to append a set of polygons from a shapefile to an existing table in a PostgreSQL/PostGIS database. The destination table only has a geography column and an 'attributes' column with jsonb data type, in which I would like to store all outstanding fields of the shapefile as a JSON. I am attempting something like this:
ogr2ogr -f PostgreSQL PG:dbname=destination_db input_polygons.shp \
-nln destination_table -update -append -t_srs "EPSG:4326" \
-sql "SELECT *, row_to_json(input_polygons) as attributes from input_polygons"
and am getting:
ERROR 1: Undefined function 'row_to_json' used.
Should I assume that row_to_json() is not usable within the scope of the ogr2ogr -sql command? From the documentation files here and here, my understanding is that the -sql command passes SQL statements directly to PostgreSQL, and that "anything possible in SQL can then be accomplished".