Interface Expr

    • Field Detail

      • ARG_JOINER

        static final com.google.common.base.Joiner ARG_JOINER
    • Method Detail

      • isLiteral

        default boolean isLiteral()
        Indicates expression is a constant whose literal value can be extracted by getLiteralValue(), making evaluating with arguments and bindings unecessary
      • isNullLiteral

        default boolean isNullLiteral()
      • isIdentifier

        default boolean isIdentifier()
      • getLiteralValue

        @Nullable
        default Object getLiteralValue()
        Returns the value of expr if expr is a literal, or throws an exception otherwise.
        Returns:
        ConstantExpr's literal value
        Throws:
        IllegalStateException - if expr is not a literal
      • getIdentifierExprIfIdentifierExpr

        @Nullable
        default org.apache.druid.math.expr.IdentifierExpr getIdentifierExprIfIdentifierExpr()
        Returns an IdentifierExpr if it is one, else null
      • getIdentifierIfIdentifier

        @Nullable
        default String getIdentifierIfIdentifier()
        Returns the string identifier of an IdentifierExpr, else null. Use this method to analyze an Expr tree when trying to distinguish between different IdentifierExpr with the same IdentifierExpr.binding. Do NOT use this method to analyze the input binding (e.g. backing column name), use getBindingIfIdentifier() instead.
      • getBindingIfIdentifier

        @Nullable
        default String getBindingIfIdentifier()
        Returns the string key to use to get a value from Expr.ObjectBinding of an IdentifierExpr, else null. Use this method to analyze the inputs required to an Expr tree (e.g. backing column name).
      • getOutputType

        @Nullable
        default ExpressionType getOutputType​(Expr.InputBindingInspector inspector)
        Given an Expr.InputBindingInspector, compute what the output ExpressionType will be for this expression. In the vectorized expression engine, if canVectorize(InputBindingInspector) returns true, a return value of null MUST ONLY indicate that the expression has all null inputs (non-existent columns) or null constants for the entire expression. Otherwise, all vectorizable expressions must produce an output type to correctly operate with the vectorized engine. Outside the context of vectorized expressions, a return value of null can also indicate that the given type information was not enough to resolve the output type, so the expression must be evaluated using default eval(org.apache.druid.math.expr.Expr.ObjectBinding) handling where types are only known after evaluation, through ExprEval.type(), such as transform expressions at ingestion time
      • asVectorProcessor

        default <T> ExprVectorProcessor<T> asVectorProcessor​(Expr.VectorInputBindingInspector inspector)
        Builds a 'vectorized' expression processor, that can operate on batches of input values for use in vectorized query engines.
        Parameters:
        inspector -
      • decorateCacheKeyBuilder

        default void decorateCacheKeyBuilder​(CacheKeyBuilder builder)
        Decorates the CacheKeyBuilder for the default implementation of getCacheKey(). The default cache key implementation includes the output of stringify() and then uses a Expr.Shuttle to call this method on all children. The stringified representation is sufficient for most expressions, but for any which rely on external state that might change, this method allows the cache key to change when the state does, even if the expression itself is otherwise the same.
      • getCacheKey

        default byte[] getCacheKey()
        Description copied from interface: Cacheable
        Get a byte array used as a cache key.
        Specified by:
        getCacheKey in interface Cacheable
        Returns:
        a cache key
      • singleThreaded

        static Expr singleThreaded​(Expr expr,
                                   Expr.InputBindingInspector inspector)
        Returns the single-threaded version of the given expression tree. Nested expressions in the subtree are also optimized.