huor
发布于

给定表名查表在HDFS上的路径

SELECT t1.fselocation || E'\/' || t2.dat2tablespace || E'\/' || t2.oid || E'\/' || t3.relfilenode
FROM pg_filespace_entry t1, pg_database t2, pg_class t3
WHERE t1.fsefsoid = t2.dat2tablespace::int - 1 AND t2.datname=current_database() AND t2.oid is not null AND t3.relname = 'TABLE_NAME';
评论(1)
  • huor
    huor 回复

    举例:

    testdb=# SELECT t1.fselocation || E'\/' || t2.dat2tablespace || E'\/' || t2.oid || E'\/' || t3.relfilenode
    testdb-# FROM pg_filespace_entry t1, pg_database t2, pg_class t3
    testdb-# WHERE t1.fsefsoid = t2.dat2tablespace::int - 1 AND t2.datname=current_database() AND t2.oid is not null AND t3.relname = 'lineitem';
                           ?column?
    ------------------------------------------------------
     hdfs://localhost:8020/hawq_default/16385/16513/31373
    (1 row)
    
test