Re: Tenanted SQL

2016-03-27 Thread Julian Hyde
See comments inline.

Julian


> On Mar 25, 2016, at 9:29 AM, Dan Di Spaltro  wrote:
> 
> So I definitely understand the data side of the target database ("A"), that
> I am virtualizing.
> 
> I guess more specific questions would be:
> * How would I expose only two tables from "A" (they would both include the
> tenantId field), I'm guess I might override the JdbcSchema using some
> whitelist.

A whitelist is one approach. Another is to keep the JdbcSchema private, but 
create views in another schema that reference those tables. Tenants would only 
see the views.

> * Since I want to give everyone the same virtual table space (with
> different "data"), would I need to look in overriding some of the Jdbc core
> implementation?

I don’t think you need to change anything in the JDBC adapter. All of the 
smarts will be in the views. 

> * I would need to use the parsed tree and then add the tenantId filter
> * Somehow pass in the tenantId during query time, ideally at the statement
> vs the connection level.

You could put tenantId into the DataContext. In SQL it would be accessed using 
a function. This is very similar to how CURRENT_TIMESTAMP function works.

> 
> Anyways, was just looking for some pointers, as there is a lot of code
> here. And anything would be much appreciated.  I am happy to share some of
> the work once it's done.





[jira] [Created] (CALCITE-1172) Add rule to flatten two Aggregate operators into one

2016-03-27 Thread Julian Hyde (JIRA)
Julian Hyde created CALCITE-1172:


 Summary: Add rule to flatten two Aggregate operators into one
 Key: CALCITE-1172
 URL: https://issues.apache.org/jira/browse/CALCITE-1172
 Project: Calcite
  Issue Type: Bug
Reporter: Julian Hyde
Assignee: Julian Hyde


If there is an Aggregate on top of an Aggregate, and the top aggregate's group 
key is a subset of the lower aggregate's group key, and the aggregates are 
expansions of rollups, then a rule would convert into a single aggregate.

For example, SUM of SUM becomes SUM; SUM of COUNT becomes COUNT; MAX of MAX 
becomes MAX; MIN of MIN becomes MIN. AVG of AVG would not match, nor would 
COUNT of COUNT.

The rule would convert

{noformat}
Aggregate({x}, SUM(c1), MIN(c2), MAX(c3))
  Aggregate({x, y}, SUM(c1), MIN(c2), MAX(c3))
R
{noformat}

into

{noformat}
Aggregate({x}, SUM(c1), MIN(c2), MAX(c3))
  R
{noformat}

The rule would not work if there was anything between the two {{Aggregate}} 
operators.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


Re: Starting a transaction with avatica and a few other things

2016-03-27 Thread F21

Hi James,

Thanks for the quick reply. The docs does talk about how to use 
transactions with phoenix, but doesn't seem to answer my questions 
regarding implementing transactions for a phoenix query server client.


Cheers!

On 27/03/2016 5:04 PM, James Taylor wrote:

Please read https://phoenix.apache.org/transactions.html and let us know if
it doesn't answer your questions.

Thanks,
James

On Sat, Mar 26, 2016 at 10:00 PM, F21  wrote:


Hi guys,

As I posted on the Phoenix list a few days ago, I am working on a golang
client for the phoenix query service (which uses avatica).

In regards to starting a transaction, I see that the protobuf reference
contains Commit and Rollback requests, but there isn't any Begin request.

Is sending a ConnectionSync request and setting autoCommit to false the
correct way to start a transaction?

Also, what is the state of autoCommit when I send an Open request to the
server?

Finally, the Open request allows me to send a map called info. What is
suppose to go into this map?

Cheers!





Re: Starting a transaction with avatica and a few other things

2016-03-27 Thread James Taylor
Please read https://phoenix.apache.org/transactions.html and let us know if
it doesn't answer your questions.

Thanks,
James

On Sat, Mar 26, 2016 at 10:00 PM, F21  wrote:

> Hi guys,
>
> As I posted on the Phoenix list a few days ago, I am working on a golang
> client for the phoenix query service (which uses avatica).
>
> In regards to starting a transaction, I see that the protobuf reference
> contains Commit and Rollback requests, but there isn't any Begin request.
>
> Is sending a ConnectionSync request and setting autoCommit to false the
> correct way to start a transaction?
>
> Also, what is the state of autoCommit when I send an Open request to the
> server?
>
> Finally, the Open request allows me to send a map called info. What is
> suppose to go into this map?
>
> Cheers!
>