For info, I was able to achieve this by subclassing Calcite’s Driver class and 
implementing my own driver which registers my Schema objects on the 
CalciteConnections it creates before returning them to the client.

I was then able to use a jdbc URL to use this same Driver class from both the 
Avatica Server and from the local service’s DataSource, and share the same 
Schema objects across all connections.

Nick


On 18/09/2017, 11:40, "Nick Stephen" <[email protected]> wrote:

    Thx for the quick responses. Today I have one or more local 
CalciteConnections (created by my data source implementation) each of which, at 
the time of creation, I register a small number of my own schemas. The schemas 
are read-only from the database connection (but their contents can evolve since 
they map to underlying heterogeneous data sources). I’m already reusing the 
schemas between these connections from this DataSource, initial tests show it 
working fine, but it’s not stress tested, and I’ve no thread safety in there 
yet (maybe not required as it’s not mutable).
    
    If I want to also expose this over JDBC avatica, then I need an avatica 
Meta object to be manipulating a CalciteConnection which I can configure to 
pre-seed with my multiple Schemas. The CalciteMetaImpl class looked interesting 
until I discovered it takes a CalciteConnectionImpl parameter which is package 
protected so I can’t unwrap my connection to this class type.  Is there another 
way of populating the avatica server with a calcite connection which I can 
configure myself?  (ideally I’d get this from my DataSource which is also used 
for local connections).
    
    Many thanks,
    
    Nick
    
    
    On 18/09/2017, 09:30, "Julian Hyde" <[email protected]> wrote:
    
        That's not true. You can use a Schema from multiple connections. 
Obviously you're responsible for thread safety if the Schema is mutable. 
        
        Julian
        
        > On Sep 17, 2017, at 11:49 PM, Christian Beikov 
<[email protected]> wrote:
        > 
        > I might be wrong, but as far as my knowledge goes, you can't have 
more than
        > a single connection to the same schema right now. I am planning to 
work on
        > that soon by implementing a datasource. As part of that I would take 
a look
        > at how Aviatica's remote capabilities fit into. Until then, I'd rather
        > stick to testing for now.
        > 
        > Regards,
        > Christian
        > 
        > 
        > Am 18.09.2017 8:36 vorm. schrieb "Nick Stephen" <[email protected]>:
        > 
        > Hi folks,
        > 
        > We’ve started experimenting with Calcite for some work and have been
        > running it in-process using a datasource wrapped around a local 
connection
        > (using jdbc:calcite).
        > 
        > I’d now like to expose this same database remotely using avatica, but 
can’t
        > see any APIs in avatica which can take a Connection object. If I 
create a
        > Meta with the same local URL then I understandably get a different DB
        > instance.
        > 
        > Could someone point out the appropriate API, or are there any 
examples of
        > exposing a calcite DB remotely using avatica whilst still being able 
to use
        > it locally in-process to avoid the additional network hop.
        > 
        > Thanks!
        > 
        > Nick
        
    
    

Reply via email to