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-6325] Add LOG function (enabled in Mysql and Spark library) #3789

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caicancai
Copy link
Member

@caicancai caicancai commented May 5, 2024

@@ -512,8 +512,7 @@ public enum BuiltInMethod {
SAFE_DIVIDE(SqlFunctions.class, "safeDivide", double.class, double.class),
SAFE_MULTIPLY(SqlFunctions.class, "safeMultiply", double.class, double.class),
SAFE_SUBTRACT(SqlFunctions.class, "safeSubtract", double.class, double.class),
LOG(SqlFunctions.class, "log", long.class, long.class),
LOG2(SqlFunctions.class, "log2", long.class),
LOG(SqlFunctions.class, "log", long.class, long.class, int.class),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this requires an enum instead of a numeric flag?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tanclary I'm sorry that it took so long to improve it. If you have time, please review this PR.

Co-authored-by: Tanner Clary <tannerclary@google.com>
Copy link

sonarcloud bot commented May 6, 2024


map.put(LN, new LogImplementor());
map.put(LOG, new LogImplementor());
map.put(LOG10, new LogImplementor());

map.put(LOG_MYSQLSPARK, new LogMysqlSparkImplementor());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SQL function name that you are registering is LOG, which is the same as what is added on line 651. The equals and hashCode methods used for the key is from the class SqlOperator and will only use the name+kind.

The result is that you overwrite the map entry from line 651. One way around this is set LOG_MYSQLSPARK to a new anonymous inner subclass of SqlBasicFunction. You would need to increase visibility of the SqlBasicFunction constructor.

LOG_MYSQLSPARK = new SqlBasicFunction(...) {};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants