Konstantin Orlov created IGNITE-26636:
-----------------------------------------

             Summary: Introduce basic API for expression execution and 
predicate implementation
                 Key: IGNITE-26636
                 URL: https://issues.apache.org/jira/browse/IGNITE-26636
             Project: Ignite
          Issue Type: Improvement
          Components: sql ai3
            Reporter: Konstantin Orlov


Let's introduce basic set of interfaces and simple implementation of one 
expression.

The proposed API is as follow:

{code}
/**
 * A context enclosing information for a context-dependent function, such
 * as CURRENT_USER, CURRENT_TIMESTAMP, etc.
 */
public interface EvaluationContext {
    EvaluationContext EMPTY = new EvaluationContext() {};
}

/**
 * Class representing a reader for the input row.
 *
 * @param <RowT> Type of the supported row.
 */
@FunctionalInterface
public interface RowFieldAccessor<RowT> {
    /** Reads the specified field of the given row. */
    @Nullable Object get(int field, RowT row);
}

@FunctionalInterface
public interface IgnitePredicate {
    <RowT> boolean test(
            EvaluationContext context,
            RowFieldAccessor<RowT> accessor,
            RowT row
    );
}

public interface IgniteExpressionFactory {
    /**
     * Creates predicate which accepts a single row as input.
     *
     * @param expression String representation of expression to create.
     * @param inputRowType A type of the input row.
     * @return A predicate representing the provided expression.
     */
    IgnitePredicate predicate(
            String expression,
            RowNativeType inputRowType
    );
}
{code}

h3. Definition of Done
It's possible to execute arbitrary expression over a provided row. All types 
should be supported. Validation exceptions should have reasonable message. 
Runtime exceptions (e.g. division by zero) should have reasonable message.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to