From 7875ff2d2d39f7586bc0444f2fa4318b8cca0ce2 Mon Sep 17 00:00:00 2001 From: "David W. Streever" Date: Wed, 14 Jun 2023 21:34:44 -0400 Subject: [PATCH] Missing queries for postgesql and Oracle for the 'sre' proc. --- pom.xml | 2 +- .../sre/ORACLE/hive_sre_queries.yaml | 87 ++++++++++++++++++ .../sre/POSTGRES/hive_sre_queries.yaml | 90 +++++++++++++++++++ 3 files changed, 178 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 60c7b9d..c0cbad9 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ com.cloudera.utils.hive hive-sre - 2.5.1.3 + 2.5.1.4 hive-sre diff --git a/src/main/resources/sre/ORACLE/hive_sre_queries.yaml b/src/main/resources/sre/ORACLE/hive_sre_queries.yaml index 6836e1e..7ba61f8 100644 --- a/src/main/resources/sre/ORACLE/hive_sre_queries.yaml +++ b/src/main/resources/sre/ORACLE/hive_sre_queries.yaml @@ -274,6 +274,49 @@ query_definitions: statement: " SELECT COUNT(*) as count FROM FUNCS " + tbl_part_locations: + statement: "SELECT DISTINCT + D.NAME , + T.TBL_NAME , + T.TBL_TYPE , + P.PART_NAME , + CASE + WHEN PS.LOCATION IS NULL + THEN S.LOCATION + ELSE PS.LOCATION + END AS PATH_LOCATION + FROM + DBS D + INNER JOIN + TBLS T + ON + D.DB_ID = T.DB_ID + LEFT OUTER JOIN + SDS S + ON + T.SD_ID = S.SD_ID + LEFT OUTER JOIN + TABLE_PARAMS PARAMS + ON + T.TBL_ID = PARAMS.TBL_ID + LEFT OUTER JOIN + PARTITIONS P + ON + T.TBL_ID = P.TBL_ID + LEFT OUTER JOIN + SDS PS + ON + P.SD_ID = PS.SD_ID + WHERE + D.NAME LIKE ? + AND D.NAME != 'sys' + AND T.TBL_TYPE != 'VIRTUAL_VIEW' + ORDER BY D.NAME, T.TBL_NAME" + parameters: + dbs: + initial: "%" + sqlType: 12 + location: 1 db_tbl_count: statement: "SELECT name, @@ -293,6 +336,50 @@ query_definitions: initial: "%" sqlType: 12 location: 1 + managed_tbl_locations: + statement: "SELECT DISTINCT + D.NAME , + T.TBL_NAME , + T.TBL_TYPE , + P.PART_NAME , + CASE + WHEN PS.LOCATION IS NULL + THEN S.LOCATION + ELSE PS.LOCATION + END AS PATH_LOCATION + FROM + DBS D + INNER JOIN + TBLS T + ON + D.DB_ID = T.DB_ID + LEFT OUTER JOIN + SDS S + ON + T.SD_ID = S.SD_ID + LEFT OUTER JOIN + TABLE_PARAMS PARAMS + ON + T.TBL_ID = PARAMS.TBL_ID + LEFT OUTER JOIN + PARTITIONS P + ON + T.TBL_ID = P.TBL_ID + LEFT OUTER JOIN + SDS PS + ON + P.SD_ID = PS.SD_ID + WHERE + D.NAME LIKE ? + AND T.TBL_TYPE = 'MANAGED_TABLE' + AND PARAMS.PARAM_KEY = 'transactional' + AND LOWER(PARAMS.PARAM_VALUE) = 'true' + ORDER BY D.NAME, T.TBL_NAME" + parameters: + dbs: + initial: "%" + sqlType: 12 + location: 1 acid_table_list: statement: " SELECT diff --git a/src/main/resources/sre/POSTGRES/hive_sre_queries.yaml b/src/main/resources/sre/POSTGRES/hive_sre_queries.yaml index 43d8f5b..301a850 100644 --- a/src/main/resources/sre/POSTGRES/hive_sre_queries.yaml +++ b/src/main/resources/sre/POSTGRES/hive_sre_queries.yaml @@ -37,6 +37,50 @@ query_definitions: statement: " SELECT \"TBL_TYPE\", COUNT(*) as count FROM \"TBLS\" GROUP BY \"TBL_TYPE\" " + tbl_part_locations: + statement: "SELECT DISTINCT + \"D\".\"NAME\", + \"T\".\"TBL_NAME\", + \"T\".\"TBL_TYPE\", + \"P\".\"PART_NAME\", + CASE + WHEN \"PS\".\"LOCATION\" IS NULL + THEN \"S\".\"LOCATION\" + ELSE \"PS\".\"LOCATION\" + END AS \"PATH_LOCATION\" + FROM + \"DBS\" \"D\" + INNER JOIN + \"TBLS\" \"T\" + ON + \"D\".\"DB_ID\" = \"T\".\"DB_ID\" + LEFT OUTER JOIN + \"SDS\" \"S\" + ON + \"T\".\"SD_ID\" = \"S\".\"SD_ID\" + LEFT OUTER JOIN + \"TABLE_PARAMS\" \"PARAMS\" + ON + \"T\".\"TBL_ID\" = \"PARAMS\".\"TBL_ID\" + LEFT OUTER JOIN + \"PARTITIONS\" \"P\" + ON + \"T\".\"TBL_ID\" = \"P\".\"TBL_ID\" + LEFT OUTER JOIN + \"SDS\" \"PS\" + ON + \"P\".\"SD_ID\" = \"PS\".\"SD_ID\" + WHERE + \"D\".\"NAME\" LIKE ? + AND \"D\".\"NAME\" != 'sys' + AND \"T\".\"TBL_TYPE\" != 'VIRTUAL_VIEW' + ORDER BY + \"D\".\"NAME\", \"T\".\"TBL_NAME\"" + parameters: + dbs: + initial: "%" + sqlType: 12 + location: 1 dbs_table_type_count: statement: " SELECT @@ -296,6 +340,52 @@ FROM initial: "%" sqlType: 12 location: 1 + managed_tbl_locations: + statement: "SELECT DISTINCT + \"D\".\"NAME\" + , \"T\".\"TBL_NAME\" + , \"T\".\"TBL_TYPE\" + , \"P\".\"PART_NAME\" + , CASE + WHEN \"PS\".\"LOCATION\" IS NULL + THEN \"S\".\"LOCATION\" + ELSE \"PS\".\"LOCATION\" + END AS PATH_LOCATION +FROM + \"DBS\" \"D\" + INNER JOIN + \"TBLS\" \"T\" + ON + \"D\".\"DB_ID\" = \"T\".\"DB_ID\" + LEFT OUTER JOIN + \"SDS\" \"S\" + ON + \"T\".\"SD_ID\" = \"S\".\"SD_ID\" + LEFT OUTER JOIN + \"TABLE_PARAMS\" \"PARAMS\" + ON + \"T\".\"TBL_ID\" = \"PARAMS\".\"TBL_ID\" + LEFT OUTER JOIN + \"PARTITIONS\" \"P\" + ON + \"T\".\"TBL_ID\" = \"P\".\"TBL_ID\" + LEFT OUTER JOIN + \"SDS\" \"PS\" + ON + \"P\".\"SD_ID\" = \"PS\".\"SD_ID\" +WHERE + \"D\".\"NAME\" LIKE ? + AND \"T\".\"TBL_TYPE\" = 'MANAGED_TABLE' + AND \"PARAMS\".\"PARAM_KEY\" = 'transactional' + AND LOWER(\"PARAMS\".\"PARAM_VALUE\") = 'true' +ORDER BY + \"D\".\"NAME\" + , \"T\".\"TBL_NAME\"" + parameters: + dbs: + initial: "%" + sqlType: 12 + location: 1 acid_table_list: statement: " SELECT