Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6702] Strong Policy for the POWER Function is wrong #4059

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/main/java/org/apache/calcite/plan/Strong.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ private static Map<SqlKind, Policy> createPolicyMap() {
map.put(SqlKind.TIMESTAMP_ADD, Policy.ANY);
map.put(SqlKind.TIMESTAMP_DIFF, Policy.ANY);
map.put(SqlKind.ITEM, Policy.ANY);
map.put(SqlKind.POWER, Policy.ANY);

// Assume that any other expressions cannot be simplified.
for (SqlKind k
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ public static SqlBasicFunction create(SqlKind kind,
SqlFunctionCategory.SYSTEM, call -> SqlMonotonicity.NOT_MONOTONIC, false);
}

/** Creates a {@code SqlBasicFunction} whose name is the same as its kind. */
public static SqlBasicFunction create(SqlKind kind,
SqlReturnTypeInference returnTypeInference,
SqlOperandTypeChecker operandTypeChecker,
SqlFunctionCategory category) {
return new SqlBasicFunction(kind.name(), kind,
SqlSyntax.FUNCTION, true, returnTypeInference, null,
OperandHandlers.DEFAULT, operandTypeChecker, 0,
category, call -> SqlMonotonicity.NOT_MONOTONIC, false);
}

/** Creates a {@code SqlBasicFunction}
* with kind {@link SqlKind#OTHER_FUNCTION}
* and category {@link SqlFunctionCategory#NUMERIC}. */
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/org/apache/calcite/sql/SqlKind.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ public enum SqlKind {
*/
PATTERN_CONCAT,

/** Exponentiation. **/
POWER,

// comparison operators

/** {@code IN} operator. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
* second operand is negative.
*/
public static final SqlBasicFunction POWER =
SqlBasicFunction.create("POWER",
SqlBasicFunction.create(SqlKind.POWER,
ReturnTypes.DOUBLE_NULLABLE,
OperandTypes.NUMERIC_NUMERIC,
SqlFunctionCategory.NUMERIC);
Expand Down
Loading