Skip to content

Instantly share code, notes, and snippets.

@sankars
Created October 28, 2020 10:07
Show Gist options
  • Save sankars/71a9887d0c4a4caa77d5175ea868e965 to your computer and use it in GitHub Desktop.
Save sankars/71a9887d0c4a4caa77d5175ea868e965 to your computer and use it in GitHub Desktop.
hive table metadata with row and column count
SELECT d.NAME AS DB_NAME, t. TBL_NAME, COUNT(1) AS COL_COUNT, tp.PARAM_VALUE AS ROW_COUNT
FROM hive.TBLS t
JOIN hive.DBS d
ON t.DB_ID = d.DB_ID
JOIN hive.SDS s
ON t.SD_ID = s.SD_ID
JOIN hive.COLUMNS_V2 c
ON s.CD_ID = c.CD_ID
JOIN hive.TABLE_PARAMS tp
ON t.TBL_ID = tp.TBL_ID
WHERE tp.PARAM_KEY = 'numRows'
GROUP BY d.NAME, t.TBL_NAME
ORDER BY d.NAME, t.TBL_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment