1

I need to expose for users an SQL like engine on top of specific jdbc datasource. Each user should only see a specific filtered data from this jdbc datasource.

So when a specific user runs his SQL against datasource, like:

select * from table where column = value

the engine should perform rather enhanced query:

select * from (select * from table where user = specific_user) where column = value

I have started messing around Calcite - how can achieve such logic with it? Should I add a custom view on top of JDBCSchema or try to build some new schema delegating to JDBCSchema?

1 Answers1

0

Is the list of tables to be filtered (and the columns that hold the user name) known in advance? If so, you could build a JSON model file containing hand-written view definitions.

Julian Hyde
  • 1,239
  • 7
  • 10
  • Yes, whole base, existing schema is well known. Users should have possibility to query only a subset of tables (or projections) and subset of data. How can I parametrize a view in calcite? Through a custom function, like select a,b,c from table where user=customuserfunction() ? – Piotr Bojko Oct 06 '17 at 09:53
  • Yes, write a user-defined function. Or maybe CURRENT_USER will do what you need. – Julian Hyde Oct 07 '17 at 18:31
  • I am wondering whether such solution implies that whole calculation will be done at jvm (in-memory), not at DB lvl. – Piotr Bojko Oct 09 '17 at 13:21