Class StringUtil
- java.lang.Object
-
- net.snowflake.hivemetastoreconnector.util.StringUtil
-
public class StringUtil extends Object
A utility class for formatting strings
-
-
Constructor Summary
Constructors Constructor Description StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringescapeSqlComment(String str)Helper method to escape text in a SQL commentstatic StringescapeSqlDataTypeSpec(String str)Helper method to escape text that's in a data type specstatic StringescapeSqlIdentifier(String str)Helper method to escape SQL text that's an identifierstatic StringescapeSqlText(String str)Helper method to escape SQL textstatic StringrelativizePartitionURI(org.apache.hadoop.hive.metastore.api.Table hiveTable, org.apache.hadoop.hive.metastore.api.Partition hivePartition)Helper method for getting a relative path between a Hive table and Hive partition.static Optional<String>relativizeURI(String base, String extended)Helper method for getting a relative path between two URIs.
-
-
-
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 toextended- 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
-
-