When a view is defined, the parser resolves the operator and the rewriter converts shorthand syntax into an explicit operator call to ensure portability. Since the operator's formal definition utilizes the anyarray pseudotype, the rewriter automatically attaches ::anyarray to the literal '{n/a}'.
WHEN ((array_agg(r.test_test_location_id))::text[] = '{n/a}'::text[]) THEN 3
This line in the database is begin re-written to:
WHEN ((array_agg(r.test_test_location_id))::text[] OPERATOR(pg_catalog.=) '{n/a}'::anyarray COLLATE "default") THEN 3
gpbackup failure:
20260318:05:11:44 gpbackup:gpadmin:mdw:22222-[CRITICAL]:-Detected anyarray type cast in view definition for View 'test_view_demo': Drop the view or recreate the view without explicit array type casts.
gpbackup: 1.32.1
gpdb: 7.6.0
While the database can execute this syntax, gpbackup includes a safety check that blocks any view containing ::anyarray. This restriction is in place because, during certain upgrade scenarios, this explicit cast in the catalog can prevent metadata from being successfully restored or dumped by standard tools.
20260318:05:11:44 gpbackup:gpadmin:mdw:22222-[CRITICAL]:-Detected anyarray type cast in view definition for View 'test_view_demo': Drop the view or recreate the view without explicit array type casts.
To fix this, you need to write the comparison in a way that prevents the rewriter from defaulting to the polymorphic anyarray operator resolution in the system catalog. Instead of using a string literal with a cast ('{n/a}'::text[]), use the explicit ARRAY constructor so that the rewriter is less likely to simplify this into an anyarray cast in the stored definition.
Change lines from this:
WHEN ((array_agg(r.test_test_location_id))::text[] OPERATOR(pg_catalog.=) '{n/a}'::anyarray COLLATE "default") THEN 3
To This:
WHEN ((array_agg(r.distribution_meter_location_id))::text[] = ARRAY['n/a']::text[]) THEN 3