Concatenating CHAR(N) and VARCHAR strings

2023-06-29 Thread mbudiu
Hello,

 

What happens when you concatenate a CHAR(N) and a VARCHAR value?

Calcite seems to insert no casts before concatenation, so the trailing
spaces for the CHAR(N) value are preserved.

However, Postgres has the following test:

 

https://github.com/postgres/postgres/blob/5bcc7e6dc8cb6fb6ab16c118a1e710fc85
096f76/src/test/regress/expected/strings.out#L1802C1-L1805C21

 

SELECT char(20) 'characters' || ' and text' AS "Concat char to unknown
type";

Concat char to unknown type 

-

characters and text

 

The same test (adapted for the Babel syntax) evaluates statically in Calcite
to:

 

"characters   and text"

 

It looks like Postgres implicitly casts the CHAR(20) value to TEXT before
concatenation.

I have stared at tables with type conversions in various databases for a
long time, but I could not figure out what the result is supposed to be. 

 

Thank you,

Mihai



[jira] [Created] (CALCITE-5811) Error messages produced for constant out-of-bounds arguments are confusing

2023-06-29 Thread Mihai Budiu (Jira)
Mihai Budiu created CALCITE-5811:


 Summary: Error messages produced for constant out-of-bounds 
arguments are confusing
 Key: CALCITE-5811
 URL: https://issues.apache.org/jira/browse/CALCITE-5811
 Project: Calcite
  Issue Type: Bug
Affects Versions: 1.34.0
Reporter: Mihai Budiu


Supplying arguments that are out-of-bounds for functions can produce 
uninformative messages. Consider this test case that can be added to 
SqlOperatorTest.checkSubstringFunction():
{code:java}
f.checkString("substring('abc' from 2 for 2147483650)",
"bc", "VARCHAR(3) NOT NULL");
{code}
The signature of the substring function requires int arguments. The constant 
2147483650 is out of bounds for an integer. This causes the test to fail with 
the following exception:
{code:java}
Error while executing SQL "values (substring('abc' from 2 for 2147483650))": 
Unable to implement EnumerableCalc(expr#0=[{inputs}], expr#1=['abc'], 
expr#2=[2], expr#3=[2147483650:BIGINT], expr#4=[SUBSTRING($t1, $t2, $t3)], 
EXPR$0=[$t4]): rowcount = 1.0, cumulative cost = {2.0 rows, 7.0 cpu, 0.0 io}, 
id = 153424
  EnumerableValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 
rows, 1.0 cpu, 0.0 io}, id = 153408
{code}
I suspect this happens because of a combination of features:
 - type inference does not reject the call to substring, although the inferred 
type of the argument is probably bigint
 - an attempt to evaluate the constant function fails because of some overflow
 - the detailed exception about the overflow is lost when handling the error

I suspect this is a deeper problem which may affect all functions, and it is 
really about type inference and implicit cast insertion.

I can imagine two possible implementation strategies:
 - Postgres rejects such a call because the substring function cannot take a 
bigint argument
 - The compiler could add an implicit cast from bigint to int, which should at 
least give a warning because the value is too large to fit in an integer

Both these solutions would avoid a crash in the expression evaluation. I 
personally do not yet understand well enough the type inference mechanisms in 
Calcite to propose a solution.

To make matters worse, some SQL dialects have substring functions with bigint 
arguments. In this case there should be two different substring functions, with 
different signatures.

This issue surfaced during a discussion for 
[https://github.com/apache/calcite/pull/3286,] and is related to 
https://issues.apache.org/jira/browse/CALCITE-5810.

 



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


Re: Virtual key signing party

2023-06-29 Thread Michael Mior
Signed key attached.
--
Michael Mior
mm...@apache.org


On Tue, Jun 27, 2023 at 3:32 AM Ruben Q L  wrote:

> Hello,
>
> I'll try to attend too.
> Best,
> Ruben
>
>
> pub   rsa4096 2020-09-26 [SC]
>
>   464F A4A3 D7E4 2112 E4CB  68F2 DF92 5FEB A08B 032B
>
> uid[  absoluta ] Ruben Quesada Lopez 
>
> sub   rsa4096 2020-09-26 [E]
>
>
>
>
> On Tue, Jun 27, 2023 at 8:29 AM Stamatis Zampetakis 
> wrote:
>
> > Great let's do one on June 29, 2023, 14:30 UTC+2 [1, 2]. For those who
> > can't make it in this slot feel free to propose additional ones.
> >
> > Best,
> > Stamatis
> >
> > [1] https://s.apache.org/cn5xq
> > [2] https://meet.google.com/vwx-mxxz-ibk
> >
> >
> > On Tue, Jun 27, 2023 at 4:22 AM xiong duan  wrote:
> > >
> > > Hi Stamatis,
> > > Thanks for organizing this party. I am in UTC+8. How about June 29,
> > > 2023, 20:30 (UTC+8) So the UTC+2 time should be June 29, 2023, 14:30?
> > > Here is my fingerprint:
> > >
> > > pub   rsa4096 2023-06-27 [SC]
> > >
> > >   EC78 877D 98B8 CDD4 9613  3DF2 B989 C696 D102 A552
> > >
> > > uid   [ultimate] Xiong Duan (CODE SIGNING KEY) <
> xi...@apache.org
> > >
> > >
> > > sub   rsa4096 2023-06-27 [E]
> > >
> > > Michael Mior  于2023年6月27日周二 02:19写道:
> > >
> > > > I'll attend if possible. My key needs to be updated. (Not
> compromised,
> > but
> > > > I lost access to my previous signing key.)
> > > >
> > > > pub   rsa4096 2022-06-17 [SC] [expires: 2038-06-13]
> > > >   EAC5 89C4 44F4 68FE 7E11  3D2D D8D7 2C13 CF2D 8DDB
> > > > uid   [ultimate] Michael Mior 
> > > > uid   [ultimate] Michael Mior 
> > > > uid   [ultimate] Michael Mior 
> > > > sub   rsa4096 2022-06-17 [E] [expires: 2038-06-13]
> > > >
> > > > --
> > > > Michael Mior
> > > > mm...@apache.org
> > > >
> > > >
> > > > On Mon, Jun 26, 2023 at 3:27 AM Stamatis Zampetakis <
> zabe...@gmail.com
> > >
> > > > wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > The last virtual key signing party [1] was about a year ago [2]. In
> > > > > the upcoming releases, we have some people that are serving as
> > release
> > > > > managers for the first time, thus it may be a good time to hold
> > > > > another party.
> > > > >
> > > > > Since Duan Xiong is the RM for the next release, I would suggest
> > > > > holding a meeting in a timezone that is convenient for him.
> > > > >
> > > > > @Duan: Can you please propose a time slot that works for you?
> > > > >
> > > > > I am in UTC+2 and will try to attend if the slot doesn't fall in
> the
> > > > > middle of the night (23:00 - 06:00).
> > > > >
> > > > > For those that would like to attend, please reply to this thread
> with
> > > > > your public
> > > > > keys' fingerprint (gpg --fingerprint) before the meeting.
> > > > >
> > > > > pub   rsa4096 2019-03-15 [SC] [expires: 2027-03-15]
> > > > >   0474 9577 FD93 4674 B9CD  45C5 D77C 3383 F192 7570
> > > > > uid   [ultimate] Stamatis Zampetakis 
> > > > > uid   [ultimate] Stamatis Zampetakis 
> > > > > sub   rsa4096 2019-03-15 [E] [expires: 2027-03-15]
> > > > >
> > > > > To verify your identity, please bring with you a government issued
> ID
> > > > > (preferably passport).
> > > > >
> > > > > As a reminder of the procedure, have a look at the notes [1] taken
> by
> > > > > Francis
> > > > > during a previous party!
> > > > >
> > > > > Anybody can participate (not need to be a committer to the
> project).
> > > > >
> > > > > Best,
> > > > > Stamatis
> > > > >
> > > > > [1]
> > > > >
> > > > >
> > > >
> >
> http://www.cryptnet.net/fdp/crypto/keysigning_party/en/keysigning_party.html
> > > > > [2]
> https://lists.apache.org/thread/4lvch7sfwszbylpzjt11jc9tokm3d0l4
> > > > > [3] https://gist.github.com/F21/b0e8c62c49dfab267ff1d0c6af39ab84
> > > > >
> > > >
> >
>


Re: Virtual key signing party

2023-06-29 Thread Michael Mior
Signed key attached.
--
Michael Mior
mm...@apache.org


On Mon, Jun 26, 2023 at 10:22 PM xiong duan  wrote:

> Hi Stamatis,
> Thanks for organizing this party. I am in UTC+8. How about June 29,
> 2023, 20:30 (UTC+8) So the UTC+2 time should be June 29, 2023, 14:30?
> Here is my fingerprint:
>
> pub   rsa4096 2023-06-27 [SC]
>
>   EC78 877D 98B8 CDD4 9613  3DF2 B989 C696 D102 A552
>
> uid   [ultimate] Xiong Duan (CODE SIGNING KEY) 
>
> sub   rsa4096 2023-06-27 [E]
>
> Michael Mior  于2023年6月27日周二 02:19写道:
>
> > I'll attend if possible. My key needs to be updated. (Not compromised,
> but
> > I lost access to my previous signing key.)
> >
> > pub   rsa4096 2022-06-17 [SC] [expires: 2038-06-13]
> >   EAC5 89C4 44F4 68FE 7E11  3D2D D8D7 2C13 CF2D 8DDB
> > uid   [ultimate] Michael Mior 
> > uid   [ultimate] Michael Mior 
> > uid   [ultimate] Michael Mior 
> > sub   rsa4096 2022-06-17 [E] [expires: 2038-06-13]
> >
> > --
> > Michael Mior
> > mm...@apache.org
> >
> >
> > On Mon, Jun 26, 2023 at 3:27 AM Stamatis Zampetakis 
> > wrote:
> >
> > > Hello,
> > >
> > > The last virtual key signing party [1] was about a year ago [2]. In
> > > the upcoming releases, we have some people that are serving as release
> > > managers for the first time, thus it may be a good time to hold
> > > another party.
> > >
> > > Since Duan Xiong is the RM for the next release, I would suggest
> > > holding a meeting in a timezone that is convenient for him.
> > >
> > > @Duan: Can you please propose a time slot that works for you?
> > >
> > > I am in UTC+2 and will try to attend if the slot doesn't fall in the
> > > middle of the night (23:00 - 06:00).
> > >
> > > For those that would like to attend, please reply to this thread with
> > > your public
> > > keys' fingerprint (gpg --fingerprint) before the meeting.
> > >
> > > pub   rsa4096 2019-03-15 [SC] [expires: 2027-03-15]
> > >   0474 9577 FD93 4674 B9CD  45C5 D77C 3383 F192 7570
> > > uid   [ultimate] Stamatis Zampetakis 
> > > uid   [ultimate] Stamatis Zampetakis 
> > > sub   rsa4096 2019-03-15 [E] [expires: 2027-03-15]
> > >
> > > To verify your identity, please bring with you a government issued ID
> > > (preferably passport).
> > >
> > > As a reminder of the procedure, have a look at the notes [1] taken by
> > > Francis
> > > during a previous party!
> > >
> > > Anybody can participate (not need to be a committer to the project).
> > >
> > > Best,
> > > Stamatis
> > >
> > > [1]
> > >
> > >
> >
> http://www.cryptnet.net/fdp/crypto/keysigning_party/en/keysigning_party.html
> > > [2] https://lists.apache.org/thread/4lvch7sfwszbylpzjt11jc9tokm3d0l4
> > > [3] https://gist.github.com/F21/b0e8c62c49dfab267ff1d0c6af39ab84
> > >
> >
>