Class TransformExpressionTree
- java.lang.Object
-
- org.apache.pinot.common.request.transform.TransformExpressionTree
-
public class TransformExpressionTree extends Object
Class for representing expression trees for transforms.- A TransformExpressionTree node has either transform function or a column name, or a literal.
- Leaf nodes either have column name or literal, whereas non-leaf nodes have transform function.
- Transform function is applied to its children.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTransformExpressionTree.ExpressionType
-
Constructor Summary
Constructors Constructor Description TransformExpressionTree(TransformExpressionTree.ExpressionType expressionType, String value, List<TransformExpressionTree> children)TransformExpressionTree(AstNode root)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TransformExpressionTreecompileToExpressionTree(String expression)booleanequals(Object obj)List<TransformExpressionTree>getChildren()Returns the children of the node.voidgetColumns(Set<String> columns)Add all columns to the passed in column set.TransformExpressionTree.ExpressionTypegetExpressionType()Returns the expression type of the node, which can be one of the following:TransformExpressionTree.ExpressionType.FUNCTIONTransformExpressionTree.ExpressionType.IDENTIFIERTransformExpressionTree.ExpressionType.LITERALstatic StringgetStandardExpression(AstNode astNode)Converts anAstNodeinto a standard expression.StringgetValue()Returns the value of the node.inthashCode()booleanisColumn()Returns if the tree represents a column name (ie no expression), false otherwisebooleanisFunction()booleanisLiteral()voidsetValue(String value)allows value to be set (needed to fix the case)static StringstandardizeExpression(String expression)Compiles the expression and serializes it back to standard format.StringtoString()
-
-
-
Constructor Detail
-
TransformExpressionTree
public TransformExpressionTree(AstNode root)
-
TransformExpressionTree
public TransformExpressionTree(TransformExpressionTree.ExpressionType expressionType, String value, @Nullable List<TransformExpressionTree> children)
-
-
Method Detail
-
compileToExpressionTree
public static TransformExpressionTree compileToExpressionTree(String expression)
-
standardizeExpression
public static String standardizeExpression(String expression)
Compiles the expression and serializes it back to standard format.E.g. " foo\t ( bar ('a'\t ,foobar( b, 'c'\t, 123) ) ,d )\t" -> "foo(bar('a',foobar(b,'c','123')),d)"
The standard format expressions will be used in the broker response.
-
getStandardExpression
public static String getStandardExpression(AstNode astNode)
Converts anAstNodeinto a standard expression.
-
getExpressionType
public TransformExpressionTree.ExpressionType getExpressionType()
Returns the expression type of the node, which can be one of the following:- Returns:
- Expression type
-
getValue
public String getValue()
Returns the value of the node.- Returns:
- Function name for FUNCTION; column name for IDENTIFIER; string value for LITERAL
-
setValue
public void setValue(String value)
allows value to be set (needed to fix the case)- Parameters:
value-
-
getChildren
public List<TransformExpressionTree> getChildren()
Returns the children of the node.- Returns:
- List of children
-
isColumn
public boolean isColumn()
Returns if the tree represents a column name (ie no expression), false otherwise- Returns:
- True if tress represents column, false otherwise.
-
isFunction
public boolean isFunction()
-
isLiteral
public boolean isLiteral()
-
getColumns
public void getColumns(Set<String> columns)
Add all columns to the passed in column set.- Parameters:
columns- Output columns
-
-