--------------------------------------------------------
--  DDL for View OSEARCH_MIGRATETELEMETRY_MIGVAL_LONG_RUNNING_VW
--------------------------------------------------------

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "OTHQ_OWN"."OSEARCH_MIGRATETELEMETRY_MIGVAL_LONG_RUNNING_VW" ("ROW_NUMBER", "DURATIONINMINUTES", "MIGRATEFILE_SHORT", "DOC_COUNT", "INDEX_", "DBINSTANCE", "DURATIONINSECONDS", "MIGRATIONTASKID", "MIGRATEFILE", "CONTROLSTATE", "NETSUITEPRODUCT", "TIMESTAMP", "MIGRATEVERSION", "DBID", "MIGRATECONTROLFILE", "CONTROLSECTION", "STARTTIME", "MOLECULE", "REGION", "EXCEPTIONMESSAGE", "METADATA_REGION", "METADATA_DOWNLOADED_TIMESTAMP_UTC", "ENDTIME", "EXCEPTIONCLASS", "DBENDSIZEINGB", "EXCEPTIONMESSAGE_HASH", "MIGRATESTATE") DEFAULT COLLATION "USING_NLS_COMP"  AS 
  SELECT
    *
FROM
    (
        SELECT
            ROW_NUMBER() OVER(PARTITION BY dbid, migrateversion, migrationtaskid, REGEXP_SUBSTR(migratefile, '[^/]+$') ORDER BY TIMESTAMP DESC) AS row_number,
            durationinseconds / 60 AS durationinminutes,
            REGEXP_SUBSTR(migratefile, '[^/]+$') as migratefile_short,
            l.*
        FROM
            src_osearch_migratetelemetry_migval_tb l
        WHERE
            migratefile IS NOT NULL AND migratefile <> '__missing__' AND durationinseconds > 600
    )
WHERE
    row_number = 1
;
