Question Details

No question body available.

Tags

sql postgresql

Answers (1)

Accepted Answer Available
Accepted Answer
February 20, 2026 Score: 7 Rep: 2,163 Quality: Expert Completeness: 80%

I suggest looking into the operator precedence table (highest to lowest):

Operator/Element Associativity Description
... ...
:: left PostgreSQL-style typecast
... ...
+ - left addition, subtraction
(any other operator) left all other native and user-defined operators
... ...

The JSON field extraction operator (->) falls into the category of any other operator, which comes after the subtraction/deletion of keys (-). So the initial expression is equivalent to this:

feat -> ('properties' - ('{highway,surface,tracktype,maxwidth}'::text[]))

A cast works since it has higher precedence than both of the other operators. Also, just brackets work:

SELECT (feat -> 'properties') - '{highway,surface,tracktype,maxwidth}'::text[] FROM ( SELECT jsonbarrayelements(fc->'features') As feat FROM data ) as f;