diff --git a/isthmus/src/main/java/io/substrait/isthmus/expression/SqlMapValueConstructorCallConverter.java b/isthmus/src/main/java/io/substrait/isthmus/expression/SqlMapValueConstructorCallConverter.java index 65d24a0ed..936818c48 100644 --- a/isthmus/src/main/java/io/substrait/isthmus/expression/SqlMapValueConstructorCallConverter.java +++ b/isthmus/src/main/java/io/substrait/isthmus/expression/SqlMapValueConstructorCallConverter.java @@ -13,10 +13,29 @@ import org.apache.calcite.sql.SqlOperator; import org.apache.calcite.sql.fun.SqlMapValueConstructor; +/** + * Converts Calcite {@link SqlMapValueConstructor} calls into Substrait map literals. + * + *
Expects an even-numbered operand list (key/value pairs) and produces an {@link Expression} map
+ * literal via {@link ExpressionCreator}.
+ */
public class SqlMapValueConstructorCallConverter implements CallConverter {
public SqlMapValueConstructorCallConverter() {}
+ /**
+ * Attempts to convert a Calcite {@link RexCall} representing a {@link SqlMapValueConstructor}
+ * into a Substrait map literal.
+ *
+ * @param call The Calcite call to convert.
+ * @param topLevelConverter Function for converting {@link RexNode} operands to Substrait {@link
+ * Expression}s.
+ * @return An {@link Optional} containing the converted {@link Expression} if the operator is a
+ * {@link SqlMapValueConstructor}; otherwise {@link Optional#empty()}.
+ * @throws ClassCastException if operands converted by {@code topLevelConverter} are not {@link
+ * Expression.Literal} instances.
+ * @throws AssertionError if the number of operands is not even (expecting key/value pairs).
+ */
@Override
public Optional Supports {@code CURRENT ROW}, {@code UNBOUNDED}, and integer-offset {@code PRECEDING}/{@code
+ * FOLLOWING} bounds.
+ */
public class WindowBoundConverter {
- /** Converts a {@link RexWindowBound} to a {@link WindowBound}. */
+ /**
+ * Converts a Calcite {@link RexWindowBound} to a Substrait {@link WindowBound}.
+ *
+ * Accepted forms:
+ *
+ * Handles partitioning, ordering, bounds (ROWS/RANGE, lower/upper), and DISTINCT/ALL invocation.
+ */
public class WindowFunctionConverter
extends FunctionConverter<
SimpleExtension.WindowFunctionVariant,
Expression.WindowFunctionInvocation,
WindowFunctionConverter.WrappedWindowCall> {
+ /**
+ * Returns the supported window function signatures used for matching.
+ *
+ * @return immutable list of supported signatures.
+ */
@Override
protected ImmutableList Resolves the corresponding Substrait aggregate function variant, checks arity using
+ * signatures, and builds the invocation if match succeeds.
+ *
+ * @param over Calcite windowed aggregate call.
+ * @param topLevelConverter Function converting top-level {@link RexNode}s to Substrait {@link
+ * Expression}s.
+ * @param rexExpressionConverter Converter for nested {@link RexNode} expressions.
+ * @return {@link Optional} containing the {@link Expression.WindowFunctionInvocation} if matched;
+ * otherwise empty.
+ */
public Optional Handles bounds type (ROWS/RANGE), lower/upper bounds, DISTINCT/ALL invocation, and function
+ * signature matching against configured Substrait window function variants.
+ */
public class WindowRelFunctionConverter
extends FunctionConverter<
SimpleExtension.WindowFunctionVariant,
ConsistentPartitionWindow.WindowRelFunctionInvocation,
WindowRelFunctionConverter.WrappedWindowRelCall> {
+ /**
+ * Returns the supported window function signatures used for matching.
+ *
+ * @return immutable list of supported signatures.
+ */
@Override
protected ImmutableList Resolves the corresponding Substrait aggregate function variant, checks arity using
+ * signatures, and builds the invocation if match succeeds.
+ *
+ * @param winAggCall Calcite window aggregate call.
+ * @param lowerBound Lower bound of the window.
+ * @param upperBound Upper bound of the window.
+ * @param isRows Whether the window uses ROWS (true) or RANGE (false).
+ * @param topLevelConverter Function converting top-level {@link RexNode}s to Substrait {@link
+ * Expression}s.
+ * @return {@link Optional} containing the {@link
+ * ConsistentPartitionWindow.WindowRelFunctionInvocation} if matched; otherwise empty.
+ */
public Optional
+ *
+ *
+ * @param rexWindowBound The Calcite window bound to convert.
+ * @return The corresponding Substrait {@link WindowBound}.
+ * @throws IllegalStateException if the bound is not one of CURRENT ROW, UNBOUNDED, PRECEDING, or
+ * FOLLOWING.
+ * @throws IllegalArgumentException if the offset is not an exact integer type supported by
+ * Substrait.
+ */
public static WindowBound toWindowBound(RexWindowBound rexWindowBound) {
if (rexWindowBound.isCurrentRow()) {
return WindowBound.CURRENT_ROW;
diff --git a/isthmus/src/main/java/io/substrait/isthmus/expression/WindowFunctionConverter.java b/isthmus/src/main/java/io/substrait/isthmus/expression/WindowFunctionConverter.java
index 9e35492e3..17c651ebc 100644
--- a/isthmus/src/main/java/io/substrait/isthmus/expression/WindowFunctionConverter.java
+++ b/isthmus/src/main/java/io/substrait/isthmus/expression/WindowFunctionConverter.java
@@ -24,22 +24,47 @@
import org.apache.calcite.rex.RexWindow;
import org.apache.calcite.sql.SqlAggFunction;
+/**
+ * Converts Calcite window function calls ({@link RexOver}) into Substrait {@link
+ * Expression.WindowFunctionInvocation}s using configured Substrait window function variants.
+ *
+ *