Re: Transaction Support - Guidelines

2019-10-29 Thread Kiran Purandara
Hi Stamatis!

Thank you for the clarification.
It gives me some direction as to where to start.

Regards,
Kiran

On Mon, Oct 28, 2019 at 6:25 PM Stamatis Zampetakis 
wrote:

> Hi Kiran,
>
> This is definitely the place to ask such questions!
>
> Unfortunately, there is no specific documentation or guidelines on how to
> support transactions for adapters.
>
> Below some very rough ideas on how this could be done, assuming that the
> complete query can be pushed in the underlying DBMS, which supports
> transactions.
>
> I guess you need your own implementation of the Connection interface that
> wraps internally the real connection and delegate the planning process to
> Calcite.
> You could use the various components of Calcite to arrive to an executable
> plan in the JdbcConvention.
> Then you can transform the plan to SQL using RelToSqlConverter and the
> appropriate dialect and then execute it using the real connection.
>
> Best,
> Stamatis
>
>
>
>
>
> On Mon, Oct 28, 2019 at 4:11 PM Kiran Purandara 
> wrote:
>
> > Hello,
> >
> > This is my 1st question/post so please excuse me in case this is not
> > the right forum for such questions or it should be posted elsewhere.
> >
> > I am working on writing a custom adapter. We need to have finer control
> on
> > both read/write pipelines. In short, we want the adapter to be an
> interface
> > for applications that until now worked with conventional RDBMS which
> means
> > support all the SQL constructs *but also provides us the capabilities
> that
> > calcite enables*.
> > Are there any guidelines published for what needs to be extended in order
> > to support say something as basic as transactions?
> > Since CalciteMetaImpl commit is explicitly throwing exceptions, its not
> > possible to do something like...
> >
> > Connection conn = ...
> > conn.setAutoCommit(false);
> > try{
> > PreparedStatement prep_stmt = conn.prepareStatement(sql.toString());
> >
> > while(...){
> >   //set values..
> >   prep_stmt.addBatch()/prep_stmt.executeBatch();
> > }
> > }
> > conn.commit();//or abort
> >
> > Regards,
> > Kiran
> >
> > PS:  This is the only reference I found when I looked for "calcite
> > transactions not working".
> >
> > [1]
> >
> >
> https://mail-archives.apache.org/mod_mbox/calcite-dev/201502.mbox/%3ccamctme+wsqq8ehzapyc9-3stzpb7d5ayxy0aa7pzbyucjnh...@mail.gmail.com%3E
> >
>


Transaction Support - Guidelines

2019-10-28 Thread Kiran Purandara
Hello,

This is my 1st question/post so please excuse me in case this is not
the right forum for such questions or it should be posted elsewhere.

I am working on writing a custom adapter. We need to have finer control on
both read/write pipelines. In short, we want the adapter to be an interface
for applications that until now worked with conventional RDBMS which means
support all the SQL constructs *but also provides us the capabilities that
calcite enables*.
Are there any guidelines published for what needs to be extended in order
to support say something as basic as transactions?
Since CalciteMetaImpl commit is explicitly throwing exceptions, its not
possible to do something like...

Connection conn = ...
conn.setAutoCommit(false);
try{
PreparedStatement prep_stmt = conn.prepareStatement(sql.toString());

while(...){
  //set values..
  prep_stmt.addBatch()/prep_stmt.executeBatch();
}
}
conn.commit();//or abort

Regards,
Kiran

PS:  This is the only reference I found when I looked for "calcite
transactions not working".

[1]
https://mail-archives.apache.org/mod_mbox/calcite-dev/201502.mbox/%3ccamctme+wsqq8ehzapyc9-3stzpb7d5ayxy0aa7pzbyucjnh...@mail.gmail.com%3E