[jira] [Commented] (CALCITE-1539) Enable proxy access to Avatica server for third party on behalf of end users

2017-04-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15979455#comment-15979455
 ] 

ASF GitHub Bot commented on CALCITE-1539:
-

Github user Wancy commented on a diff in the pull request:

https://github.com/apache/calcite-avatica/pull/6#discussion_r112783273
  
--- Diff: 
server/src/test/java/org/apache/calcite/avatica/server/RemoteUserExtractHttpServerTest.java
 ---
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.avatica.server;
+
+import org.apache.calcite.avatica.ConnectionSpec;
+import org.apache.calcite.avatica.jdbc.JdbcMeta;
+import org.apache.calcite.avatica.remote.AuthenticationType;
+import org.apache.calcite.avatica.remote.Driver;
+import org.apache.calcite.avatica.remote.LocalService;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Test class for HTTP Basic authentication.
+ */
+public class RemoteUserExtractHttpServerTest extends HttpAuthBase {
--- End diff --

I tried different ways like adding the startserver method in the 
constructor, but get different errors. It will be great if you offer some help 
on this, thanks :)


> Enable proxy access to Avatica server for third party on behalf of end users
> 
>
> Key: CALCITE-1539
> URL: https://issues.apache.org/jira/browse/CALCITE-1539
> Project: Calcite
>  Issue Type: Improvement
>  Components: avatica
>Reporter: Jerry He
>Assignee: Shi Wang
> Attachments: 
> 0001-CALCITE-1539-Enable-proxy-access-to-Avatica-server-f.patch, 
> 0001-CALCITE-1539.patch, 0001-CALCITE-1539_without_testcase.patch
>
>
> We want to enable proxy access to Avatica server from an end user, but the 
> end user comes in via a third party impersonation.  For example, Knox and Hue.
> The Knox server user conveys the end user to Avatica.
> Similar things have been done for HBase Rest Sever HBASE-9866 and Hive Server 
> HIVE-5155



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (CALCITE-1539) Enable proxy access to Avatica server for third party on behalf of end users

2017-04-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1539?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15979438#comment-15979438
 ] 

ASF GitHub Bot commented on CALCITE-1539:
-

Github user Wancy commented on a diff in the pull request:

https://github.com/apache/calcite-avatica/pull/6#discussion_r112782312
  
--- Diff: 
server/src/test/java/org/apache/calcite/avatica/server/RemoteUserExtractHttpServerTest.java
 ---
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.avatica.server;
+
+import org.apache.calcite.avatica.ConnectionSpec;
+import org.apache.calcite.avatica.jdbc.JdbcMeta;
+import org.apache.calcite.avatica.remote.AuthenticationType;
+import org.apache.calcite.avatica.remote.Driver;
+import org.apache.calcite.avatica.remote.LocalService;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+import java.util.concurrent.Callable;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Test class for HTTP Basic authentication.
+ */
+public class RemoteUserExtractHttpServerTest extends HttpAuthBase {
+  private static final Logger LOG = 
LoggerFactory.getLogger(RemoteUserExtractHttpServerTest.class);
+
+  private static final ConnectionSpec CONNECTION_SPEC = 
ConnectionSpec.HSQLDB;
+  private static HttpServer server;
+  private static String url1;
+  private static String url2;
+
+  @BeforeClass public static void startServer() throws Exception {
+
+final String userPropertiesFile = BasicAuthHttpServerTest.class
+.getResource("/auth-users.properties").getFile();
+assertNotNull("Could not find properties file for basic auth users", 
userPropertiesFile);
+
+// Create a LocalService around HSQLDB
+final JdbcMeta jdbcMeta = new JdbcMeta(CONNECTION_SPEC.url,
+CONNECTION_SPEC.username, CONNECTION_SPEC.password);
+LocalService service = new LocalService(jdbcMeta);
+
+HandlerFactory factory = new HandlerFactory();
+AvaticaHandler avaticaHandler = factory.getHandler(service, 
Driver.Serialization.PROTOBUF, null,
+new AvaticaServerConfiguration() {
+  @Override public AuthenticationType getAuthenticationType() {
+return AuthenticationType.BASIC;
+  }
+
+  @Override public String getKerberosRealm() {
+return null;
+  }
+
+  @Override public String getKerberosPrincipal() {
+return null;
+  }
+
+  @Override public boolean supportsImpersonation() {
+return true;
+  }
+
+  @Override public  T doAsRemoteUser(String remoteUserName, 
String remoteAddress,
+Callable action) throws 
Exception {
+
+if (remoteUserName.equals("USER4")) {
+  throw new RuntimeException("USER4 is a disallowed user");
+} else if (remoteUserName.equals("USER2")) {
+  return action.call();
+} else {
+  throw new RuntimeException("Unknown user.");
+}
+  }
+
+  @Override public RemoteUserExtractor getRemoteUserExtractor() {
+return new RemoteUserExtractor() {
--- End diff --

Yeah I realize it is missing in the implementation of throwing exception if 
the extracted user is null, added it in the new commit. Thanks.


> Enable proxy access to Avatica server for third party on behalf of end users
> 

[jira] [Commented] (CALCITE-1740) Distinct aggregate flag in window function

2017-04-21 Thread radu (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15979151#comment-15979151
 ] 

radu commented on CALCITE-1740:
---

[~julianhyde] I have updated the PR with the new code implementation that 
addresses your remarks. Please have a look

> Distinct aggregate flag in window function
> --
>
> Key: CALCITE-1740
> URL: https://issues.apache.org/jira/browse/CALCITE-1740
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: radu
>Assignee: Julian Hyde
>  Labels: build, windows
>
> When parsing queries such as
> SELECT B1, SUM(DISTINCT B2) OVER  (ORDER BY  B4 RANGE BETWEEN INTERVAL '10' 
> SECOND PRECEDING AND CURRENT ROW) FROM T
> The aggregates in the LogicalWindow do not have any marker of being distinct. 
> isDistinct() flag is not set. Probably some rule(s) silently swallow the 
> DISTINCT keyword
> The LogicalWindow object that result is
> LogicalWindow(window#0=[window(partition {} order by [2] range between $3 
> PRECEDING and CURRENT ROW aggs [COUNT($1), $SUM0($1)])])



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Comment Edited] (CALCITE-1740) Distinct aggregate flag in window function

2017-04-21 Thread radu (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15979003#comment-15979003
 ] 

radu edited comment on CALCITE-1740 at 4/21/17 4:30 PM:


[~julianhyde]

I have addressed the remarks except managing to create a test class in the 
SqlToRelConverterTest. I am following the model of the existing function but it 
seems that when the result is parsed for comparison (the result is correct - i 
manually checked and distinct is set correctly)..the checker does not find the 
plan. I did not manage to understand how to set and work with the objects that 
are verified. Basically the resourceName for which the resource element is 
checked is "plan" while the object contains as attribute  "sql"

Failed tests: 
  SqlToRelConverterTest.testSelectOverDistinct:452 plan expected:<[${plan}]> 
but was:<[
LogicalProject(SUMC=[CASE(>(COUNT($7) OVER (ROWS BETWEEN 10 PRECEDING AND 
CURRENT ROW), 0), CAST($SUM0($7) OVER (ROWS BETWEEN 10 PRECEDING AND CURRENT 
ROW)):INTEGER, null)])
  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]>

let me know if you have any thoughts on this.

Anyway..regardless of this we should keep the existing test because we need to 
ensure that also the distinct is preserved when the project to window rule is 
applied.


was (Author: rtudoran):
[~julianhyde]

I have addressed the remarks except managing to create a test class in the 
SqlToRelConverterTest. I am following the model of the existing function but it 
seems that when the result is parsed for comparison (the result is correct - i 
manually checked and distinct is set correctly)..the checker does not find the 
plan. I did not manage to understand how to set and work with the objects that 
are verified.

Failed tests: 
  SqlToRelConverterTest.testSelectOverDistinct:452 plan expected:<[${plan}]> 
but was:<[
LogicalProject(SUMC=[CASE(>(COUNT($7) OVER (ROWS BETWEEN 10 PRECEDING AND 
CURRENT ROW), 0), CAST($SUM0($7) OVER (ROWS BETWEEN 10 PRECEDING AND CURRENT 
ROW)):INTEGER, null)])
  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]>

let me know if you have any thoughts on this.

Anyway..regardless of this we should keep the existing test because we need to 
ensure that also the distinct is preserved when the project to window rule is 
applied.

> Distinct aggregate flag in window function
> --
>
> Key: CALCITE-1740
> URL: https://issues.apache.org/jira/browse/CALCITE-1740
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: radu
>Assignee: Julian Hyde
>  Labels: build, windows
>
> When parsing queries such as
> SELECT B1, SUM(DISTINCT B2) OVER  (ORDER BY  B4 RANGE BETWEEN INTERVAL '10' 
> SECOND PRECEDING AND CURRENT ROW) FROM T
> The aggregates in the LogicalWindow do not have any marker of being distinct. 
> isDistinct() flag is not set. Probably some rule(s) silently swallow the 
> DISTINCT keyword
> The LogicalWindow object that result is
> LogicalWindow(window#0=[window(partition {} order by [2] range between $3 
> PRECEDING and CURRENT ROW aggs [COUNT($1), $SUM0($1)])])



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (CALCITE-1740) Distinct aggregate flag in window function

2017-04-21 Thread radu (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15979003#comment-15979003
 ] 

radu commented on CALCITE-1740:
---

[~julianhyde]

I have addressed the remarks except managing to create a test class in the 
SqlToRelConverterTest. I am following the model of the existing function but it 
seems that when the result is parsed for comparison (the result is correct - i 
manually checked and distinct is set correctly)..the checker does not find the 
plan. I did not manage to understand how to set and work with the objects that 
are verified.

Failed tests: 
  SqlToRelConverterTest.testSelectOverDistinct:452 plan expected:<[${plan}]> 
but was:<[
LogicalProject(SUMC=[CASE(>(COUNT($7) OVER (ROWS BETWEEN 10 PRECEDING AND 
CURRENT ROW), 0), CAST($SUM0($7) OVER (ROWS BETWEEN 10 PRECEDING AND CURRENT 
ROW)):INTEGER, null)])
  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]>

let me know if you have any thoughts on this.

Anyway..regardless of this we should keep the existing test because we need to 
ensure that also the distinct is preserved when the project to window rule is 
applied.

> Distinct aggregate flag in window function
> --
>
> Key: CALCITE-1740
> URL: https://issues.apache.org/jira/browse/CALCITE-1740
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: radu
>Assignee: Julian Hyde
>  Labels: build, windows
>
> When parsing queries such as
> SELECT B1, SUM(DISTINCT B2) OVER  (ORDER BY  B4 RANGE BETWEEN INTERVAL '10' 
> SECOND PRECEDING AND CURRENT ROW) FROM T
> The aggregates in the LogicalWindow do not have any marker of being distinct. 
> isDistinct() flag is not set. Probably some rule(s) silently swallow the 
> DISTINCT keyword
> The LogicalWindow object that result is
> LogicalWindow(window#0=[window(partition {} order by [2] range between $3 
> PRECEDING and CURRENT ROW aggs [COUNT($1), $SUM0($1)])])



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (CALCITE-1740) Distinct aggregate flag in window function

2017-04-21 Thread radu (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15978239#comment-15978239
 ] 

radu commented on CALCITE-1740:
---

[~julianhyde] Thanks a lot for the feedback. I will address these remarks and 
update the code

> Distinct aggregate flag in window function
> --
>
> Key: CALCITE-1740
> URL: https://issues.apache.org/jira/browse/CALCITE-1740
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: radu
>Assignee: Julian Hyde
>  Labels: build, windows
>
> When parsing queries such as
> SELECT B1, SUM(DISTINCT B2) OVER  (ORDER BY  B4 RANGE BETWEEN INTERVAL '10' 
> SECOND PRECEDING AND CURRENT ROW) FROM T
> The aggregates in the LogicalWindow do not have any marker of being distinct. 
> isDistinct() flag is not set. Probably some rule(s) silently swallow the 
> DISTINCT keyword
> The LogicalWindow object that result is
> LogicalWindow(window#0=[window(partition {} order by [2] range between $3 
> PRECEDING and CURRENT ROW aggs [COUNT($1), $SUM0($1)])])



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)