[ 
https://issues.apache.org/jira/browse/CALCITE-7637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18093735#comment-18093735
 ] 

Julian Hyde commented on CALCITE-7637:
--------------------------------------

Also, the issue seems VERY particular to the "-" operator on TIMESTAMP (which, 
as far as I know, only allows subtracting TIMESTAMP and INTERVAL). It would be 
moderately surprising if an operator behaves differently in SELECT than UPDATE, 
because we have taken pains to ensure the same code path.

> Fix DML for overloaded binary operators in Calcite engine
> ---------------------------------------------------------
>
>                 Key: CALCITE-7637
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7637
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Kirill Tkalenko
>            Assignee: Kirill Tkalenko
>            Priority: Major
>              Labels: ignite-2
>
> I discovered that when overloading a binary operator in the Calcite engine, 
> it works for SELECT statements but not for UPDATE statements.
> For example, when overloading the binary operator "-" for the operation 
> TIMESTAMP -NIMERIC, SELECT queries work as expected, but UPDATE queries do 
> not; this needs to be fixed.
> {code:java}
>  
> sql("create table person(id int primary key, val_ts timestamp)"); 
> sql("insert into person values (?, ?)", 1, Timestamp.valueOf("2024-01-01 
> 00:00:00"));
> // Check SELECT - works. 
> assertQuery("SELECT val_ts - 1 FROM person") 
>     .returns(Timestamp.valueOf("2023-12-31 00:00:00")) 
>     .check();
> // Check UPDATE - fails. 
> assertQuery("UPDATE person SET val_ts = val_ts - 1 WHERE id = ?") 
>     .withParams(1) 
>     .returns(1L) 
>     .check(); 
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to