ERROR: function lag(numeric, bigint) does not exist (SQLSTATE 42883)
gpevlu=# CREATE VIEW vw_lag_example gpevlu-# AS gpevlu-# SELECT s.a, lag(s.a, 2) OVER( gpevlu(# ORDER BY s.a) AS lag2 gpevlu-# FROM generate_series(1, 10) s(a); CREATE VIEW Time: 971.053 ms gpevlu=# \d+ vw_lag_example View "public.vw_lag_example" Column | Type | Modifiers | Storage | Description --------+---------+-----------+---------+------------- a | integer | | plain | lag2 | integer | | plain | View definition: SELECT s.a, lag(s.a, 2::bigint) OVER( ORDER BY s.a) AS lag2 FROM generate_series(1, 10) s(a)
This is documented in the migration guide below. gprestore will not restore this object.
https://docs.vmware.com/en/VMware-Greenplum/5/greenplum-database/utility_guide-admin_utilities-gprestore.html
When preparing Greenplum 4.3 databases and Greenplum 5 databases for backup, note that the offset argument of the lag(expr, offset[, default]) window function changed from int8 in Greenplum 4.3 to int4 in Greenplum 5 and 6.
As a workaround, drop the views, do the backup & restore, and recreate these views by dropping the ::bigint.
Using the example above, you can recreate the view using this command on 6.x:
CREATE VIEW public.vw_lag_example AS SELECT s.a, lag(s.a, 2) OVER( ORDER BY s.a) AS lag2 FROM generate_series(1, 10) s(a);