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

Yu Xu edited comment on CALCITE-7033 at 5/21/25 11:43 AM:
----------------------------------------------------------

[~vladsz83] Hi, I had test it in 1.39 version with copy your test code, and the 
test you provided work well and not throws exception as mention.


was (Author: JIRAUSER307770):
[~vladsz83] Hi, I had test it in 1.39 version, and the test you provided work 
well and not throws exception as mention.

> Extended string literals on insert.
> -----------------------------------
>
>                 Key: CALCITE-7033
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7033
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.38.0, 1.39.0
>            Reporter: Vladimir Steshin
>            Priority: Minor
>
> Values of string literals might be extended with spaces to a shared least 
> restrictive type on insert.
> Reproducer:
> {code:java}
> package org.apache.calcite.test;
> class ServerTest {
>  @Test void testInsert() throws Exception {
>   try (Connection c = connect(); Statement s = c.createStatement()) {
>     s.execute("CREATE TABLE t (id INTEGER, name VARCHAR(255), ts TIMESTAMP)");
>     s.executeUpdate("INSERT INTO t VALUES (5, 'name3', '2021-09-01 
> 17:00:00'), (6, 'name11', '2021-12-01 18:00:00')");
>     try (ResultSet r = s.executeQuery("select name from t")) {
>       assertThat(r.next(), is(true));
>       assertThat(r.getString(1), is("name3"));
>       assertThat(r.next(), is(true));
>       assertThat(r.getString(1), is("name11"));
>     }
>   }
>  }
> } {code}
>  
> Result:
> {code:java}
> java.lang.AssertionError: 
> Expected: is "name3"
>      but: was "name3 "{code}
>  
> Value 'name3' is extended to 'name3 '.
>  
> Appears {*}in v1.38{*}. 
>  
> This happens in _RelBuilder#_
> _setOp(boolean all, SqlKind kind, int n) -> convertLiteralTypes(...)_ because 
> it takes shared least restrictive value type for both value sets. This value 
> type becomes VARCHAR(6) for the string literals. Whereas one value is 
> actually VARCHAR(5).
>  



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

Reply via email to