I'm sorry if I don't understand it correctly but if I can't insert data in my database through calcite nor create materialized views through calcite then what is the use case of Calcite?
I would have assumed that it could do both of these use cases seeing as Calcite clearly supports both of those commands. However a "create materialized view v1 ...." command translates to a "insert into v1" command through [1] [2] on postgres (which obviously does not work seeing as I'm creating a materialized view which does not exist). And what means on an insert, when I try to execute "insert into db1.table_name ..." it retains the schemaname given to calcite in the final query to postgres (so on postgres, I get the incoming query "insert into db1.table_name"). This behaviour is not consistent with spja-queries so I cannot hack around this by renaming the postgres schema to db1. Now I am not sure if this is intented behaviour, but as of now I can not see a clear solution to these problems. Or perhaps Calcite is not intended to be used this way? Mark [1] https://github.com/apache/calcite/blob/72e952d1a79ee2d7ba05de88cbc2ac11f65cd879/server/src/main/java/org/apache/calcite/sql/ddl/SqlCreateMaterializedView.java#L125 [2] https://github.com/apache/calcite/blob/72e952d1a79ee2d7ba05de88cbc2ac11f65cd879/server/src/main/java/org/apache/calcite/sql/ddl/SqlDdlNodes.java#L221 ________________________________ Van: Stamatis Zampetakis <[email protected]> Verzonden: woensdag 10 april 2019 00:23 Aan: [email protected] Onderwerp: Re: expose existing materialized views from postgres to calcite If I am not mistaken the current implementation of JdbcSchema (and in general implementations of Schema) is not modifiable which means that changes to the database will not be reflected to the schema. I don't think it is possible to dynamically create views or tables through the JdbcAdapter. Of course, you can create a new schema whenever you want so in principle you could do this after every change in the database. Best, Stamatis On Tue, Apr 9, 2019 at 1:32 PM mark pasterkamp <[email protected]> wrote: > Hi Stamatis, > > I have looked at the example but I am still a bit confused what I need to > do when I want to create a new materialized view. > Am I then supposed to create a jdbc connection to postgres, create a > materialized view and then change the model again for calcite? Because I am > unable to create a materialized view directly via calcite. > > I am sorry if this reply reached you twice, I accidentally replied with > the wrong email and I was not able to find an entry of my reply in the > archives. > > Mark > > ________________________________ > Van: Stamatis Zampetakis <[email protected]> > Verzonden: dinsdag 9 april 2019 00:03 > Aan: [email protected] > Onderwerp: Re: expose existing materialized views from postgres to calcite > > Hi Mark, > > It is not easy to understand what is missing from the pieces of code you > shared. > > In the example that I've shared with you, I don't remember seeing anywhere > CREATE VIEW statements. I suppose you are trying to execute a > java.sql.Statement but I am afraid this will not work. You don't need to > create the view in Postgres (assuming that is already there) but you just > need to make Calcite aware of it. This will not be done by executing a > Statement but by using various APIs like the one in the test case mentioned > earlier. > > I think the easiest way to go would be to modify the test case itself and > see if how it can be adapted based on your schema. > > Best, > Stamatis > > > > On Mon, Apr 8, 2019 at 3:29 PM Yuzhao Chen <[email protected]> wrote: > > > Or you can config your framework config with a schema implemented by your > > self [1], the getTable should be implemented correctly [2]. Then config > the > > CalciteCatalogReader with the schema and schemaPath [3]. > > The validator used your CalciteCatalogReader will recognize your tables > in > > Postgres. > > > > [1] > > > https://github.com/apache/calcite/blob/a8e71f9f295e36e472d9f650d1c76d2501e1fdbf/core/src/main/java/org/apache/calcite/tools/FrameworkConfig.java#L55 > > [2] > > > https://github.com/apache/calcite/blob/a8e71f9f295e36e472d9f650d1c76d2501e1fdbf/core/src/main/java/org/apache/calcite/schema/Schema.java#L63 > > [3] > > > https://github.com/apache/calcite/blob/a8e71f9f295e36e472d9f650d1c76d2501e1fdbf/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java#L100 > > > > Best, > > Danny Chan > > 在 2019年4月5日 +0800 PM10:00,Mark Pasterkamp <[email protected] > > >,写道: > > > Dear all, > > > > > > I have connected my postgresql database as a datasource to calcite. I > am > > > however not able to find out how I can expose the existing materialized > > > views in postgres to calcite. I am unable to find much help on the > > internet > > > so if anyone is knowledgeable about this I would really appreciate a > > small > > > code example as to how this is supposed to work in Java. > > > > > > > > > Mark > > >
