Re: Remove a specific type coersion rule

2024-02-22 Thread Gonzalo Ortiz Jaureguizar
> When I read CALCITE-6210 it wasn’t clear that you wanted Calcite to give a validation error when someone tries to cast a VARCHAR to a VARBINARY. I agree that that is the desirable behavior. (And I believe it is consistent with the SQL standard. In Apache Pinot we are still discussing the

Re: about optimization rules for over(partition by id, age order by id, age)

2024-02-22 Thread Benchao Li
FWIW, FLINK-12575 is a mechanism that removes redundant shuffle/sort in physical stage, and it's not a a generic rule, but it's in AbstractConverter while we try to satisfy Distribution and Collation trait. I'm not aware of any existing rules/RelBuilder in Calcite that has this optimization, it

Re: about optimization rules for over(partition by id, age order by id, age)

2024-02-22 Thread key lou
thanks I also found a rule in fink. https://issues.apache.org/jira/browse/FLINK-12575 Julian Hyde 于2024年2月23日周五 09:04写道: > I noticed that DuckDB implemented such an optimization recently. > > Can you please log a jira case to remove redundant ORDER BY keys from > OVER? Yes, it would be either

Re: Some questions about calcite

2024-02-22 Thread Ran Tao
Thanks cancai for opening this discussion. One additional point, regarding your so-called multi-version implementation of a certain library, such as Spark. Personally, I think we can implement it according to the latest release version. There will be updates in the future, which can be aligned in

Re: Some questions about calcite

2024-02-22 Thread Cancai Cai
Maybe I also overlooked some issues in the whole jira case Cancai Cai On 2024/02/23 02:01:53 Cancai Cai wrote: > I am still happy to implement them. As far as adapting the log2 function is > concerned, at present I may just not be able to guarantee that log2(0) > returns null, and I have

Re: Some questions about calcite

2024-02-22 Thread Cancai Cai
I am still happy to implement them. As far as adapting the log2 function is concerned, at present I may just not be able to guarantee that log2(0) returns null, and I have encountered some stuck points here. But you can see that I've raised two other jira issues [CALCITE-6259]

Re: Some questions about calcite

2024-02-22 Thread Cancai Cai
Hi, everyone Thank you very much for your answers. In fact, my doubts may not only be about adapting log2 (function), as I have discovered a lot when adapting log2 functions, such as log10(0) about the difference in return values ​​of mysql and postgres, about calcite Regarding the handling of

Re: about optimization rules for over(partition by id, age order by id, age)

2024-02-22 Thread Julian Hyde
I noticed that DuckDB implemented such an optimization recently. Can you please log a jira case to remove redundant ORDER BY keys from OVER? Yes, it would be either a planner rule or a rewrite by RelBuilder. Julian > On Feb 21, 2024, at 11:43 PM, key lou wrote: > > HI ALL : > I have the

Re: Some questions about calcite

2024-02-22 Thread Tanner Clary
The SAFE_* functions do this. On Thu, Feb 22, 2024 at 4:58 PM Mihai Budiu wrote: > The only complication that I can imagine is with the NullPolicy, but I > haven't tried to implement it myself. > > This function may return NULL when neither of the operands is NULL. This > is unusual for a

Re: Some questions about calcite

2024-02-22 Thread Mihai Budiu
The only complication that I can imagine is with the NullPolicy, but I haven't tried to implement it myself. This function may return NULL when neither of the operands is NULL. This is unusual for a function. Mihai From: Tanner Clary Sent: Thursday, February

Re: Some questions about calcite

2024-02-22 Thread Tanner Clary
I feel like I'm missing something about this whole issue. We have implemented so many functions that there's probably an existing pattern for just about any issue with dialect parity we encounter. What's the core problem? What behavior is so difficult to emulate and why? Caican let me know if you

Re: Some questions about calcite

2024-02-22 Thread Julian Hyde
I agree. https://issues.apache.org/jira/browse/CALCITE-6224 and its accompanying PR muddies the waters because it also mentions Spark, Postgres and “many databases”. The case should state that the function is consistent with MySQL and returns NULL if the argument is non-positive. > On Feb 22,

Re: Remove a specific type coersion rule

2024-02-22 Thread Mihai Budiu
When I filed the Jira issue I was planning to give an error, but I discovered that several dialects implement this cast, so my PR actually implements the behavior from Postgres. I will amend the Jira case when we decide what the implementation should do. I can change the corresponding PR to

Re: Some questions about calcite

2024-02-22 Thread Mihai Budiu
In the case of log2 it's simple, because the documentation says that it comes from the MySQL dialect. So there is a spec and a golden implementation to compare against. I certainly won't object to implementing a separate log2 function that is undefined for 0 and negative values (i.e., can

Re: Remove a specific type coersion rule

2024-02-22 Thread Julian Hyde
When I read CALCITE-6210 it wasn’t clear that you wanted Calcite to give a validation error when someone tries to cast a VARCHAR to a VARBINARY. I agree that that is the desirable behavior. (And I believe it is consistent with the SQL standard.) Can you amend the Jira case so that it clearly

Re: Some questions about calcite

2024-02-22 Thread Julian Hyde
But what is the spec of the LOG2 function? It’s not in the SQL standard. So, we need to write our own spec. We can say that LOG2(0) returns 42, if we wish, and go implement our own spec. Yes, Calcite is a compiler, but it is also a standard library, and it is also an extended library. LOG2 is

Re: Some questions about calcite

2024-02-22 Thread Mihai Budiu
If we can't even implement correctly the log2 function according to its spec, there is no hope that we will implement anything correctly. I am not a QA person, but I am spending more than 50% of my time diagnosing and fixing bugs in Calcite. It's not fun. I would rather implement interesting

Re: Some questions about calcite

2024-02-22 Thread Julian Hyde
Don’t let the perfect be the enemy of the good. Or as they say in open source, “Release early and often”. Just about everyone who wants a LOG2 function is intending to apply it to positive numbers. So they won’t notice, or care, that the function doesn’t do exactly what they expected when you

Remove a specific type coersion rule

2024-02-22 Thread Gonzalo Ortiz Jaureguizar
Hello there, In the context of https://issues.apache.org/jira/browse/CALCITE-6210, the Apache Pinot team is thinking about forbidding casting from VARCHAR to VARBINARY. I've been trying to implement that, but I'm not sure if it is possible or not. Following the Javadoc of SqlTypeCoercionRule

Some questions about calcite

2024-02-22 Thread Cancai Cai
When I was working CALCITE-6224 , I encountered some problems and I always had some doubts in my heart. I thought about it for a long time, maybe I think I already understand the doubts in my heart. As @mihaibudiu said, Java grammar has its own

[jira] [Created] (CALCITE-6278) Add REGEXP function (enabled in Spark library)

2024-02-22 Thread EveyWu (Jira)
EveyWu created CALCITE-6278: Summary: Add REGEXP function (enabled in Spark library) Key: CALCITE-6278 URL: https://issues.apache.org/jira/browse/CALCITE-6278 Project: Calcite Issue Type: