Class StringUtil


  • public class StringUtil
    extends Object
    A utility class for formatting strings
    • Constructor Detail

      • StringUtil

        public StringUtil()
    • Method Detail

      • relativizePartitionURI

        public static String relativizePartitionURI​(org.apache.hadoop.hive.metastore.api.Table hiveTable,
                                                    org.apache.hadoop.hive.metastore.api.Partition hivePartition)
                                             throws IllegalArgumentException
        Helper method for getting a relative path between a Hive table and Hive partition. The partition location must be a subpath of the table location.
        Parameters:
        hiveTable - The table to get a relative path from.
        hivePartition - The partition with a location relative to the table
        Returns:
        The relative path between the table and partition.
        Throws:
        IllegalArgumentException - Thrown if bad arguments were provided, e.g. if the partition is not a relative path of the table.
      • relativizeURI

        public static Optional<String> relativizeURI​(String base,
                                                     String extended)
        Helper method for getting a relative path between two URIs.
        Parameters:
        base - The URI that the output path will be relative to
        extended - The URI that contains the relative path
        Returns:
        The relative path if possible.
      • escapeSqlText

        public static String escapeSqlText​(String str)
        Helper method to escape SQL text
        Parameters:
        str - the string to escape
        Returns:
        the escaped string
      • escapeSqlIdentifier

        public static String escapeSqlIdentifier​(String str)
        Helper method to escape SQL text that's an identifier
        Parameters:
        str - the string to escape
        Returns:
        the escaped string
      • escapeSqlComment

        public static String escapeSqlComment​(String str)
        Helper method to escape text in a SQL comment
        Parameters:
        str - the string to escape
        Returns:
        the escaped string
      • escapeSqlDataTypeSpec

        public static String escapeSqlDataTypeSpec​(String str)
        Helper method to escape text that's in a data type spec
        Parameters:
        str - the string to escape
        Returns:
        the escaped string