You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Ran Tao <ch...@gmail.com> on 2023/10/27 16:06:46 UTC

Can we enable '-ea' in csv sqlline by default

hi, community

Currently I have encountered a case where when I run a certain query in csv
sqlline, it runs correctly, but it fails in the IDE. The location of
failure is a certain assertion. The reason is that running tests in the IDE
will turn on -ea to activate assert by default, but sqlline will not be
turned on by default[1]. Therefore, some code behaviors are inconsistent on
both sides.

Frankly I know that asserts are useful in the testing and development
process and are typically omitted for production code.

Therefore, I only recommend opening '-ea' for sqlline by default under
example/csv, so that inconsistent behavior will not occur during the dev
process and when executing tests on the IDE.

what do you think?

[1] https://github.com/apache/calcite/blob/main/example/csv/sqlline#L43


Best Regards,
Ran Tao
https://github.com/chucheng92

Re: Can we enable '-ea' in csv sqlline by default

Posted by Ran Tao <ch...@gmail.com>.
In fact, I already found the bug so I asked this question.

How to reproduce:
use calcite-1.20[1] sqlline run this sql.

```sql
select t1.x from (values (1, 'a'), (2, 'b')) as t1(x, y) left join (values
(1, 'a'), (2, 'b')) as t2(x, y)
on t1.x=t2.x and t1.x in
(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21);
```

I will succeed.

but if we enable '-ea', it will cause an AssertionError.

In fact, our calcite was always wrong in this SQL case, and SQLLine covered
up the error.
I didn't find out until I happened to turn on -ea in the IDE by accident.

I guess '-ea' can be turned on by default,
but I also agree that a cmd similar to 'sqlline -ea' can be supported.

[1] From calcite 1.20 to the current 1.35, there is another bug that causes
this case to fail,
which has nothing to do with assert. Therefore, it is described here as
calcite-1.20.

Best Regards,
Ran Tao


Julian Hyde <jh...@gmail.com> 于2023年10月28日周六 03:38写道:

> I get how frustrating it must be for bugs to happen in tests but not from
> sqlline.
>
> Regarding example/csv/sqlline. I had forgotten that we have two copies of
> sqlline (and sqlline.bat). They arrived when we imported a different
> project, optiq-csv. Do the extra copies serve any useful purpose? If not,
> rather than make example/csv/sqlline diverge even further from sqlline, can
> we just delete it?
>
> As a developer, would it be OK to invoke sqlline with the command-line
> ‘./sqlline -ea’ or ‘./sqlline --jvmArgs=-ea'? Those options don’t currently
> work, but it wouldn’t be difficult to make them work.
>
> Julian
>
> [1]
> https://github.com/apache/calcite/commit/686c0ddd615fcd17211175952873a949d9249f43
>
> > On Oct 27, 2023, at 9:06 AM, Ran Tao <ch...@gmail.com> wrote:
> >
> > hi, community
> >
> > Currently I have encountered a case where when I run a certain query in
> csv
> > sqlline, it runs correctly, but it fails in the IDE. The location of
> > failure is a certain assertion. The reason is that running tests in the
> IDE
> > will turn on -ea to activate assert by default, but sqlline will not be
> > turned on by default[1]. Therefore, some code behaviors are inconsistent
> on
> > both sides.
> >
> > Frankly I know that asserts are useful in the testing and development
> > process and are typically omitted for production code.
> >
> > Therefore, I only recommend opening '-ea' for sqlline by default under
> > example/csv, so that inconsistent behavior will not occur during the dev
> > process and when executing tests on the IDE.
> >
> > what do you think?
> >
> > [1] https://github.com/apache/calcite/blob/main/example/csv/sqlline#L43
> >
> >
> > Best Regards,
> > Ran Tao
> > https://github.com/chucheng92
>
>

Re: Can we enable '-ea' in csv sqlline by default

Posted by Julian Hyde <jh...@gmail.com>.
I get how frustrating it must be for bugs to happen in tests but not from sqlline.

Regarding example/csv/sqlline. I had forgotten that we have two copies of sqlline (and sqlline.bat). They arrived when we imported a different project, optiq-csv. Do the extra copies serve any useful purpose? If not, rather than make example/csv/sqlline diverge even further from sqlline, can we just delete it?

As a developer, would it be OK to invoke sqlline with the command-line ‘./sqlline -ea’ or ‘./sqlline --jvmArgs=-ea'? Those options don’t currently work, but it wouldn’t be difficult to make them work.

Julian

[1] https://github.com/apache/calcite/commit/686c0ddd615fcd17211175952873a949d9249f43 

> On Oct 27, 2023, at 9:06 AM, Ran Tao <ch...@gmail.com> wrote:
> 
> hi, community
> 
> Currently I have encountered a case where when I run a certain query in csv
> sqlline, it runs correctly, but it fails in the IDE. The location of
> failure is a certain assertion. The reason is that running tests in the IDE
> will turn on -ea to activate assert by default, but sqlline will not be
> turned on by default[1]. Therefore, some code behaviors are inconsistent on
> both sides.
> 
> Frankly I know that asserts are useful in the testing and development
> process and are typically omitted for production code.
> 
> Therefore, I only recommend opening '-ea' for sqlline by default under
> example/csv, so that inconsistent behavior will not occur during the dev
> process and when executing tests on the IDE.
> 
> what do you think?
> 
> [1] https://github.com/apache/calcite/blob/main/example/csv/sqlline#L43
> 
> 
> Best Regards,
> Ran Tao
> https://github.com/chucheng92