Package org.apache.pinot.parsers.utils
Class ParserUtils
- java.lang.Object
-
- org.apache.pinot.parsers.utils.ParserUtils
-
public class ParserUtils extends Object
Class for holding Parser specific utility functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FilterOperatorfilterKindToOperator(FilterKind filterKind)Utility method to mapFilterKindtoFilterOperator.static StringgetFilterColumn(Expression expression)Returns the filter column from a given expression.static FilterKindgetFilterKind(Expression expression)Utility method that returns theFilterKindfor a given expression.static FilterOperatorgetFilterType(Expression expression)Utility method that returns theFilterOperatorfor a given expression.static List<String>getFilterValues(Expression filterExpression)Utility method that returns the RHS of a filter expression as a list of String's.static List<String>getFilterValues(FilterKind filterKind, List<Expression> operands)Given a expression filter, returns the values (RHS) on which the filter predicate applies.static StringstandardizeExpression(Expression expression, boolean treatLiteralAsIdentifier)Standardizes a given expression, by quoting String literals.static StringstandardizeExpression(Expression expression, boolean treatLiteralAsIdentifier, boolean forceSingleQuoteOnNonStringLiteral)static StringstandardizeFunction(Function functionCall)Standardizes a function call by quoting literal operands.
-
-
-
Method Detail
-
getFilterType
public static FilterOperator getFilterType(Expression expression)
Utility method that returns theFilterOperatorfor a given expression. Assumes that the passed in expression is a filter expression.- Parameters:
expression- Expression for which to get the filter type- Returns:
- Filter Operator for the given Expression.
-
getFilterKind
public static FilterKind getFilterKind(Expression expression)
Utility method that returns theFilterKindfor a given expression. Assumes that the passed in expression is a filter expression.- Parameters:
expression- Expression for which to get the filter type- Returns:
- Filter Kind for the given Expression.
-
filterKindToOperator
public static FilterOperator filterKindToOperator(FilterKind filterKind)
Utility method to mapFilterKindtoFilterOperator.- Parameters:
filterKind- Filter kind for which to get the Filter Operator- Returns:
- Filter Operator for the given Filter kind
-
getFilterColumn
public static String getFilterColumn(Expression expression)
Returns the filter column from a given expression. Assumes that the passed expression is a filter expression of form LHS Operator RHS. LHS is expected to be a single column name.- Parameters:
expression- Filter expression- Returns:
-
getFilterValues
public static List<String> getFilterValues(Expression filterExpression)
Utility method that returns the RHS of a filter expression as a list of String's.- Parameters:
filterExpression- Filter expression- Returns:
- RHS of the filter expression
-
getFilterValues
public static List<String> getFilterValues(FilterKind filterKind, List<Expression> operands)
Given a expression filter, returns the values (RHS) on which the filter predicate applies.- Parameters:
filterKind- Kind of filteroperands- Filter operands- Returns:
- Values to filter on, as a list of strings.
-
standardizeExpression
public static String standardizeExpression(Expression expression, boolean treatLiteralAsIdentifier)
Standardizes a given expression, by quoting String literals.- Parameters:
expression- Expression to standardizetreatLiteralAsIdentifier- If true, literals are not quoted- Returns:
- Standardized expression
-
standardizeExpression
public static String standardizeExpression(Expression expression, boolean treatLiteralAsIdentifier, boolean forceSingleQuoteOnNonStringLiteral)
-
-