java.lang.Object
org.apache.arrow.gandiva.expression.TreeBuilder

public class TreeBuilder extends Object
Contains helper functions for constructing expression trees.
  • Method Details

    • makeLiteral

      public static TreeNode makeLiteral(Boolean booleanConstant)
      Helper functions to create literal constants.
    • makeLiteral

      public static TreeNode makeLiteral(Float floatConstant)
    • makeLiteral

      public static TreeNode makeLiteral(Double doubleConstant)
    • makeLiteral

      public static TreeNode makeLiteral(Integer integerConstant)
    • makeLiteral

      public static TreeNode makeLiteral(Long longConstant)
    • makeStringLiteral

      public static TreeNode makeStringLiteral(String stringConstant)
    • makeBinaryLiteral

      public static TreeNode makeBinaryLiteral(byte[] binaryConstant)
    • makeDecimalLiteral

      public static TreeNode makeDecimalLiteral(String decimalConstant, int precision, int scale)
    • makeNull

      public static TreeNode makeNull(ArrowType type)
      create a null literal.
    • makeField

      public static TreeNode makeField(Field field)
      Invoke this function to create a node representing a field, e.g. a column name.
      Parameters:
      field - represents the input argument - includes the name and type of the field
      Returns:
      Node representing a field
    • makeFunction

      public static TreeNode makeFunction(String function, List<TreeNode> children, ArrowType retType)
      Invoke this function to create a node representing a function.
      Parameters:
      function - Name of the function, e.g. add
      children - The arguments to the function
      retType - The type of the return value of the operator
      Returns:
      Node representing a function
    • makeIf

      public static TreeNode makeIf(TreeNode condition, TreeNode thenNode, TreeNode elseNode, ArrowType retType)
      Invoke this function to create a node representing an if-clause.
      Parameters:
      condition - Node representing the condition
      thenNode - Node representing the if-block
      elseNode - Node representing the else-block
      retType - Return type of the node
      Returns:
      Node representing an if-clause
    • makeAnd

      public static TreeNode makeAnd(List<TreeNode> nodes)
      Invoke this function to create a node representing an and-clause.
      Parameters:
      nodes - Nodes in the 'and' clause.
      Returns:
      Node representing an and-clause
    • makeOr

      public static TreeNode makeOr(List<TreeNode> nodes)
      Invoke this function to create a node representing an or-clause.
      Parameters:
      nodes - Nodes in the 'or' clause.
      Returns:
      Node representing an or-clause
    • makeExpression

      public static ExpressionTree makeExpression(TreeNode root, Field resultField)
      Invoke this function to create an expression tree.
      Parameters:
      root - is returned by a call to MakeField, MakeFunction, or MakeIf
      resultField - represents the return value of the expression
      Returns:
      ExpressionTree referring to the root of an expression tree
    • makeExpression

      public static ExpressionTree makeExpression(String function, List<Field> inFields, Field resultField)
      Short cut to create an expression tree involving a single function, e.g. a+b+c.
      Parameters:
      function - Name of the function, e.g. add()
      inFields - In arguments to the function
      resultField - represents the return value of the expression
      Returns:
      ExpressionTree referring to the root of an expression tree
    • makeCondition

      public static Condition makeCondition(TreeNode root)
      Invoke this function to create a condition.
      Parameters:
      root - is returned by a call to MakeField, MakeFunction, MakeIf, ..
      Returns:
      condition referring to the root of an expression tree
    • makeCondition

      public static Condition makeCondition(String function, List<Field> inFields)
      Short cut to create an expression tree involving a single function, e.g. a+b+c.
      Parameters:
      function - Name of the function, e.g. add()
      inFields - In arguments to the function
      Returns:
      condition referring to the root of an expression tree
    • makeInExpressionInt32

      public static TreeNode makeInExpressionInt32(TreeNode resultNode, Set<Integer> intValues)
    • makeInExpressionBigInt

      public static TreeNode makeInExpressionBigInt(TreeNode resultNode, Set<Long> longValues)
    • makeInExpressionDecimal

      public static TreeNode makeInExpressionDecimal(TreeNode resultNode, Set<BigDecimal> decimalValues, Integer precision, Integer scale)
    • makeInExpressionFloat

      public static TreeNode makeInExpressionFloat(TreeNode resultNode, Set<Float> floatValues)
    • makeInExpressionDouble

      public static TreeNode makeInExpressionDouble(TreeNode resultNode, Set<Double> doubleValues)
    • makeInExpressionString

      public static TreeNode makeInExpressionString(TreeNode resultNode, Set<String> stringValues)
    • makeInExpressionBinary

      public static TreeNode makeInExpressionBinary(TreeNode resultNode, Set<byte[]> binaryValues)