It’s fair to say that if Calcite throws a NullPointerException then it’s a bug. 
(Except if it’s Calcite calling your code, or if you called an API with a null 
value for a not-null parameter.)

In this case, you are calling the CSV adapter and asking it to modify a table, 
something it is not designed to do. Calcite ought to give you a better error 
message.

Note that the CSV adapter is intended as an example, and therefore has limited 
functionality and even more limited error-checking. The file adapter has a 
superset of the functionality, and is intended for production use, so you 
should try that.

Julian


> On Sep 3, 2023, at 7:54 PM, Morsy <[email protected]> wrote:
> 
> Hi,
> I have put the
> 
> org.apache.calcite.adapter.csv.CsvScannableTable
> 
> and its related classes (Factory, Reader......, etc.) into my test project.
> When I tried to execute a sql like
> 
> insert into mysql.calcite_test (select * from csv)
> 
> an NPE was thrown. where `mysql` is recognised by JdbcSchema#Factory. When
> I debugged, I found that the bind method of the dynamically generated
> Bindable code called the JdbcTable's getModifiableCollection() method,
> which returned null directly. the bind method's subsequent call to
> collection.size() threw an NPE. This code is generated by
> EnumerableTableModify.class.
> After that, I tried to execute
> 
> insert into mysql.calcite(select * from mysql2.calcite2)
> 
> There are two JdbcSchema#Factory recognised data sources here, but I found
> that the code that was eventually generated by
> JdbcToEnumerableConverter.class executed
> 
> insert into calcite(select * from mysql2.calcite)
> 
> in `mysql2` without performing the insert in the `mysql` library.
> Are these issues intentional with calcite or are they bugs?

Reply via email to