Class BasicTablesRequests
java.lang.Object
org.apache.drill.metastore.components.tables.BasicTablesRequests
Provides handy methods to retrieve Metastore Tables data for analysis.
Contains list of most frequent requests to the Metastore Tables without a need
to write filters and transformers from
TableMetadataUnit
class.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Request metadata holder that provides request metadata types, filters and columns. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfileMetadata
(TableInfo tableInfo, String metadataKey, String path) Returns file metadata based on given table information, metadata key and full path.filesLastModifiedTime
(TableInfo tableInfo, String metadataKey, List<String> locations) Returns map of file full paths and their last modified time.filesMetadata
(TableInfo tableInfo, String metadataKey, List<String> paths) Returns files metadata based on given table information, metadata key and files paths.filesMetadata
(TableInfo tableInfo, List<MetadataInfo> metadataInfos) Returns files metadata based on the given table information and metadata keys.fullSegmentsMetadataWithoutPartitions
(TableInfo tableInfo, List<String> metadataKeys, List<String> locations) Returns metadata for segments, files and row groups based on given metadata keys and locations.boolean
hasMetastoreTableInfoChanged
(MetastoreTableInfo metastoreTableInfo) Checks if given metastore table information is the same with current one.interestingColumnsAndPartitionKeys
(TableInfo tableInfo) Returns tables interesting columns and partition keys based on given table information.metadata
(TableInfo tableInfo, Collection<MetadataInfo> metadataInfos) Returns list ofTableMetadataUnit
metadata based on the given table information, and metadata identifiers.metastoreTableInfo
(TableInfo tableInfo) Returns metastore table information, including metastore version and table last modified time.partitionsMetadata
(TableInfo tableInfo, List<String> metadataKeys, String column) Returns partitions metadata based on given table information, metadata keys and column name.request
(BasicTablesRequests.RequestMetadata requestMetadata) Executes Metastore Tables read request based on given information inBasicTablesRequests.RequestMetadata
.rowGroupsMetadata
(TableInfo tableInfo, String metadataKey, String path) Returns row groups metadata based on given table information, metadata key and location.Returns row groups metadata based on the given table information, metadata keys and locations.rowGroupsMetadata
(TableInfo tableInfo, List<MetadataInfo> metadataInfos) Returns row groups metadata based on given table information and metadata identifiers.segmentsLastModifiedTime
(TableInfo tableInfo, List<String> locations) Returns map of segments metadata keys and their last modified time.segmentsMetadata
(TableInfo tableInfo, List<MetadataInfo> metadataInfos) Returns segments metadata based on the given table information and metadata identifiers.segmentsMetadataByColumn
(TableInfo tableInfo, List<String> locations, String column) Returns segments metadata based on given table information, locations and column name.segmentsMetadataByMetadataKey
(TableInfo tableInfo, List<String> locations, String metadataKey) Returns segments metadata based on given table information, locations and column name.tableMetadata
(TableInfo tableInfo) Returns table general information metadata based on given table information.tablesMetadata
(FilterExpression filter) Returns tables general information metadata based on given filter.
-
Constructor Details
-
BasicTablesRequests
-
-
Method Details
-
metastoreTableInfo
Returns metastore table information, including metastore version and table last modified time. Schematic SQL request:select lastModifiedTime from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'GENERAL_INFO' and metadataType = 'TABLE'
- Parameters:
tableInfo
- table information- Returns:
MetastoreTableInfo
instance
-
hasMetastoreTableInfoChanged
Checks if given metastore table information is the same with current one. If Metastore supports versioning, first checks metastore versions, if metastore version did not change, it is assumed table metadata did not change as well. If Metastore version has changed or Metastore does not support versioning, retrieves current metastore table info and checks against given one.- Parameters:
metastoreTableInfo
- metastore table information- Returns:
- true is metastore table information has changed, false otherwise
-
tablesMetadata
Returns tables general information metadata based on given filter. For example, can return list of tables that belong to particular storage plugin or storage plugin and workspace combination. Schematic SQL request:select [$TABLE_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and metadataKey = 'GENERAL_INFO' and metadataType = 'TABLE'
- Parameters:
filter
- filter expression- Returns:
- list of table metadata
-
tableMetadata
Returns table general information metadata based on given table information. Expects only one qualified result, otherwise will fail. If no data is returned, will return null. Schematic SQL request:select [$TABLE_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'GENERAL_INFO' and metadataType = 'TABLE'
- Parameters:
tableInfo
- table information- Returns:
- table metadata
-
segmentsMetadataByMetadataKey
public List<SegmentMetadata> segmentsMetadataByMetadataKey(TableInfo tableInfo, List<String> locations, String metadataKey) Returns segments metadata based on given table information, locations and column name. Schematic SQL request:select [$SEGMENT_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and location in ('.../part_int=3/d3', '.../part_int=3/d4') and metadataKey = 'part_int=3' and metadataType = 'SEGMENT'
- Parameters:
tableInfo
- table informationlocations
- segments locationsmetadataKey
- metadata key- Returns:
- list of segment metadata
-
segmentsMetadataByColumn
public List<SegmentMetadata> segmentsMetadataByColumn(TableInfo tableInfo, List<String> locations, String column) Returns segments metadata based on given table information, locations and column name. Schematic SQL request:select [$SEGMENT_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and location in ('.../dir0', '.../dir1') and column = 'n_nation' and metadataType = 'SEGMENT'
- Parameters:
tableInfo
- table informationlocations
- segments locationscolumn
- column name- Returns:
- list of segment metadata
-
segmentsMetadata
public List<SegmentMetadata> segmentsMetadata(TableInfo tableInfo, List<MetadataInfo> metadataInfos) Returns segments metadata based on the given table information and metadata identifiers. Schematic SQL request:select [$SEGMENT_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and identifier in ('part_int=3', …) and metadataType = 'SEGMENT'
- Parameters:
tableInfo
- table informationmetadataInfos
- list of MetadataInfo for required segments to obtain- Returns:
- list of segment metadata
-
metadata
public List<TableMetadataUnit> metadata(TableInfo tableInfo, Collection<MetadataInfo> metadataInfos) Returns list ofTableMetadataUnit
metadata based on the given table information, and metadata identifiers. Schematic SQL request:select * from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and identifier in ('part_int=3', …) and metadataType in ('SEGMENT', …)
- Parameters:
tableInfo
- table informationmetadataInfos
- list of MetadataInfo for required metadata to obtain- Returns:
- list of metadata
-
partitionsMetadata
public List<PartitionMetadata> partitionsMetadata(TableInfo tableInfo, List<String> metadataKeys, String column) Returns partitions metadata based on given table information, metadata keys and column name. Schematic SQL request:select [$PARTITION_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey in ('part_int=3', 'part_int=4') and column = 'n_nation' and metadataType = 'PARTITION'
- Parameters:
tableInfo
- table informationmetadataKeys
- list of metadata keyscolumn
- partition column- Returns:
- list of partition metadata
-
filesMetadata
public List<FileMetadata> filesMetadata(TableInfo tableInfo, String metadataKey, List<String> paths) Returns files metadata based on given table information, metadata key and files paths. Schematic SQL request:select [$FILE_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'part_int=3' and path in ('/tmp/nation/part_int=3/part_varchar=g/0_0_0.parquet', …) and metadataType = 'FILE'
- Parameters:
tableInfo
- table informationmetadataKey
- metadata keypaths
- list of full file paths- Returns:
- list of files metadata
-
filesMetadata
Returns files metadata based on the given table information and metadata keys. Schematic SQL request:select [$FILE_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and identifier = in ('part_int=3', …) and metadataType = 'FILE'
- Parameters:
tableInfo
- table informationmetadataInfos
- list of MetadataInfo for required row groups to obtain- Returns:
- list of row group metadata
-
fileMetadata
Returns file metadata based on given table information, metadata key and full path. Expects only one qualified result, otherwise will fail. If no data is returned, will return null. Schematic SQL request:select [$FILE_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'part_int=3' and path = '/tmp/nation/part_int=3/part_varchar=g/0_0_0.parquet' and metadataType = 'FILE'
- Parameters:
tableInfo
- table informationmetadataKey
- metadata keypath
- full file path- Returns:
- list of files metadata
-
rowGroupsMetadata
public List<RowGroupMetadata> rowGroupsMetadata(TableInfo tableInfo, String metadataKey, String path) Returns row groups metadata based on given table information, metadata key and location. Schematic SQL request:select [$ROW_GROUP_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'part_int=3' and path = '/tmp/nation/part_int=3/part_varchar=g/0_0_0.parquet' and metadataType = 'ROW_GROUP'
- Parameters:
tableInfo
- table informationmetadataKey
- metadata keypath
- full path to the file of the row group- Returns:
- list of row group metadata
-
rowGroupsMetadata
public List<RowGroupMetadata> rowGroupsMetadata(TableInfo tableInfo, List<String> metadataKeys, List<String> paths) Returns row groups metadata based on the given table information, metadata keys and locations. Schematic SQL request:select [$ROW_GROUP_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey in ('part_int=3', …) and path in ('/tmp/nation/part_int=3/part_varchar=g/0_0_0.parquet', …) and metadataType = 'ROW_GROUP'
- Parameters:
tableInfo
- table informationmetadataKeys
- metadata keypaths
- list of full paths to the file of the row group- Returns:
- list of row group metadata
-
rowGroupsMetadata
public List<RowGroupMetadata> rowGroupsMetadata(TableInfo tableInfo, List<MetadataInfo> metadataInfos) Returns row groups metadata based on given table information and metadata identifiers. Schematic SQL request:select [$ROW_GROUP_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and identifier in ('part_int=3', …) and metadataType = 'ROW_GROUP'
- Parameters:
tableInfo
- table informationmetadataInfos
- list of MetadataInfo for required row groups to obtain- Returns:
- list of row group metadata
-
fullSegmentsMetadataWithoutPartitions
public BasicTablesTransformer.MetadataHolder fullSegmentsMetadataWithoutPartitions(TableInfo tableInfo, List<String> metadataKeys, List<String> locations) Returns metadata for segments, files and row groups based on given metadata keys and locations. Schematic SQL request:select [$SEGMENT_METADATA$] / [$FILE_METADATA$] / [$ROW_GROUP_METADATA$] from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey in ('part_int=1', 'part_int=2', 'part_int=5') and location in ('.../dir0/d3', '.../dir0/d4', '.../part_int=3/d3', '.../part_int=4/d4') and metadataType in ('SEGMENT', 'FILE', 'ROW_GROUP')
- Parameters:
tableInfo
- table informationmetadataKeys
- metadata keyslocations
- locations- Returns:
- list of segments / files / rows groups metadata in
BasicTablesTransformer.MetadataHolder
instance
-
filesLastModifiedTime
public Map<String,Long> filesLastModifiedTime(TableInfo tableInfo, String metadataKey, List<String> locations) Returns map of file full paths and their last modified time. Schematic SQL request:select path, lastModifiedTime from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'part_int=3' and location in ('/tmp/nation/part_int=3/part_varchar=g', ...) and metadataType = 'FILE'
- Parameters:
tableInfo
- table informationmetadataKey
- metadata keylocations
- files locations- Returns:
- result map where key is file full path and value is file last modification time
-
segmentsLastModifiedTime
Returns map of segments metadata keys and their last modified time. Schematic SQL request:select metadataKey, lastModifiedTime from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and location in ('.../dir0', '.../dir1') and metadataType = 'SEGMENT'
- Parameters:
tableInfo
- table informationlocations
- segments locations- Returns:
- result map where key is metadata key and value is its last modification time
-
interestingColumnsAndPartitionKeys
Returns tables interesting columns and partition keys based on given table information. Expects only one qualified result, otherwise will fail. If no data is returned, will return null. Schematic SQL request:select interestingColumns, partitionKeys from METASTORE where storage = 'dfs' and workspace = 'tmp' and tableName = 'nation' and metadataKey = 'GENERAL_INFO' and metadataType = 'TABLE'
- Parameters:
tableInfo
- table information- Returns:
TableMetadataUnit
instance with set interesting columns and partition keys if present
-
request
Executes Metastore Tables read request based on given information inBasicTablesRequests.RequestMetadata
.- Parameters:
requestMetadata
- request metadata- Returns:
- list of metadata units
-