korlov42 commented on code in PR #5479: URL: https://github.com/apache/ignite-3/pull/5479#discussion_r2024705918
########## modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/LogicalRelImplementor.java: ########## @@ -1168,6 +1155,20 @@ private static boolean canFuseProjectionInto(RelNode rel) { return joinProjection; } + private long validateAndGetFetchOffsetParams(RexNode node, String op) { + SqlScalar<RowT, Number> sqlScalar = expressionFactory.scalar(node); + Number param = sqlScalar.get(ctx); + + if (param instanceof BigDecimal) { + BigDecimal param0 = (BigDecimal) param; + if (param0.signum() == -1 || param0.compareTo(LIMIT_UPPER) > 0) { + throw new SqlException(Sql.STMT_VALIDATION_ERR, IgniteResource.INSTANCE.illegalFetchLimit(op).str()); + } + } Review Comment: this covers only `BigDecimal`, but parameter may be of any numeric type. I would suggest to use `org.apache.ignite.internal.sql.engine.util.IgniteMath#convertToLongExact(java.lang.Number)` to cover overflow part, and then validate result of conversion to make sure it's not negative. Let's also improve test coverage -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org