Package org.apache.flink.table.utils
Class PartitionPathUtils
java.lang.Object
org.apache.flink.table.utils.PartitionPathUtils
Utils for file system.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectconvertStringToInternalValue(String valStr, DataType type) Restore partition value from string and type.static LinkedHashMap<String,String> extractPartitionSpecFromPath(org.apache.flink.core.fs.Path currPath) Make partition spec from path.extractPartitionValues(org.apache.flink.core.fs.Path currPath) Make partition values from path.static GenericRowDatafillPartitionValueForRecord(String[] fieldNames, DataType[] fieldTypes, int[] selectFields, List<String> partitionKeys, org.apache.flink.core.fs.Path path, String defaultPartValue) Extract partition value from path and fill to record.static StringgeneratePartitionPath(LinkedHashMap<String, String> partitionSpec) Make partition path from partition spec.static org.apache.flink.core.fs.FileStatus[]listStatusWithoutHidden(org.apache.flink.core.fs.FileSystem fs, org.apache.flink.core.fs.Path dir) List file status without hidden files.static List<org.apache.flink.api.java.tuple.Tuple2<LinkedHashMap<String,String>, org.apache.flink.core.fs.Path>> searchPartSpecAndPaths(org.apache.flink.core.fs.FileSystem fs, org.apache.flink.core.fs.Path path, int partitionNumber) Search all partitions in this path.static StringunescapePathName(String path)
-
Constructor Details
-
PartitionPathUtils
public PartitionPathUtils()
-
-
Method Details
-
generatePartitionPath
Make partition path from partition spec.- Parameters:
partitionSpec- The partition spec.- Returns:
- An escaped, valid partition name.
-
extractPartitionValues
Make partition values from path.- Parameters:
currPath- partition file path.- Returns:
- Sequential partition specs.
-
extractPartitionSpecFromPath
public static LinkedHashMap<String,String> extractPartitionSpecFromPath(org.apache.flink.core.fs.Path currPath) Make partition spec from path.- Parameters:
currPath- partition file path.- Returns:
- Sequential partition specs.
-
unescapePathName
-
listStatusWithoutHidden
public static org.apache.flink.core.fs.FileStatus[] listStatusWithoutHidden(org.apache.flink.core.fs.FileSystem fs, org.apache.flink.core.fs.Path dir) throws IOException List file status without hidden files.- Throws:
IOException
-
searchPartSpecAndPaths
public static List<org.apache.flink.api.java.tuple.Tuple2<LinkedHashMap<String,String>, searchPartSpecAndPathsorg.apache.flink.core.fs.Path>> (org.apache.flink.core.fs.FileSystem fs, org.apache.flink.core.fs.Path path, int partitionNumber) Search all partitions in this path.- Parameters:
path- search path.partitionNumber- partition number, it will affect path structure.- Returns:
- all partition specs to its path.
-
fillPartitionValueForRecord
public static GenericRowData fillPartitionValueForRecord(String[] fieldNames, DataType[] fieldTypes, int[] selectFields, List<String> partitionKeys, org.apache.flink.core.fs.Path path, String defaultPartValue) Extract partition value from path and fill to record.- Parameters:
fieldNames- record field names.fieldTypes- record field types.selectFields- the selected fields.partitionKeys- the partition field names.path- the file path that the partition located.defaultPartValue- default value of partition field.- Returns:
- the filled record.
-
convertStringToInternalValue
Restore partition value from string and type.- Parameters:
valStr- string partition value.type- type of partition field.- Returns:
- partition value.
-