[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-02-09 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy closed the pull request at:

https://github.com/apache/drill/pull/685


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-30 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r98425957
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE, isNiladic = true)
--- End diff --

:) I checked the niladic functions... Will make the commit shortly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-30 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r98414144
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE, isNiladic = true)
--- End diff --

Please exclude `timeofday, now, statement_timestamp, transaction_timestamp, 
unix_timestamp`. Just leave those that already behave like niladic functions 
(just execute function in Drill and see if it requires parenthesis or not, if 
not, then it's niladic :)). We don't won't to change existing behavior not to 
break queries.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-29 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r98355138
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE, isNiladic = true)
--- End diff --

@jinfengni @arina-ielchiieva am in the process of adding `isNiladic=true` 
to the standard functions. I am referring to 
[SqlStdOperatorTable.java](https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java)
 in Calcite and tried to find the equivalent functions in Drill.

I have marked following functions from 
[DateTypeFunctions.java](https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java)
 and 
[ContextFunctions.java](https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java)
 as isNiladic=true.

1. "current_date"
2. "timeofday" (**is this a niladic function? Not found in Calcite**)
3. {"localtimestamp", "current_timestamp", "now", "statement_timestamp", 
"transaction_timestamp"}
4. {"current_time", "localtime"}
5. "unix_timestamp" (**is this a niladic function? Not found in Calcite**)
6. {"user", "session_user", "system_user"}
7. "current_schema"
8. "session_id"

Please check the above list... and let me know if I should add more. Also, 
I should not be marking something niladic if it is not as that will break the 
existing queries.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-27 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r98186438
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE, isNiladic = true)
--- End diff --

Each drill function is converted to DrillFunctionHolder and though Calcite 
recognizes current_time/current_date & other context functions (ex: user, 
current_schema) as niladic, after introduction of isNilladic flag, 
DrillFunctionHolder would describe such functions as non-niladic, though they 
are. So we are intentionally hold incorrect info.

Let's say in future I would need to take list of all function holders in 
Drill (form local function registry) and filter out all niladic functions, 
since we do have such isNiladic flag I would assume that I can use this flag as 
filter but since current_time/current_date & other context functions (ex: user, 
current_schema) have isniladic=false, they would never be filtered out.

Also please add `isNiladic=true` to other niladic context functions [1].

[1] 
https://github.com/apache/drill/blob/5a4ad2a88331dfe7561ee76fc87e882afe170681/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-24 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r97721703
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE, isNiladic = true)
--- End diff --

- Functions like current_time/current_date already function like niladic as 
Calcite recognizes them so. 

- IsNiladic flag can be set by any UDF. Not restricted only to session_I'd

- If I understand right, currently there is no categorization of UDFs in 
Drill. If we want to restrict isNiladic flag only to a particular category of 
UDFs, then categorization of UDFs need to be designed n implemented.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-24 Thread jinfengni
Github user jinfengni commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r97449967
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE, isNiladic = true)
--- End diff --

I thought this new introduced flag "isNiladic" should not only applied to 
this new "session_id" function, but also for all the existing functions which 
falls into same category, for example, current_date /current_time? 

1. 
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java#L234
2. 
https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java#L290



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-17 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r96451356
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlOperator.java
 ---
@@ -147,6 +166,14 @@ public DrillSqlOperatorBuilder 
setDeterministic(boolean isDeterministic) {
   return this;
 }
 
+public DrillSqlOperatorBuilder setNiladic(boolean isNiladic) {
+  /*
+   * Set Operand type-checking strategy for an operator which takes no 
operands
+   */
--- End diff --

May also add that no parentheses as well: no operands and no parentheses?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-17 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r96463387
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlOperator.java
 ---
@@ -147,6 +166,14 @@ public DrillSqlOperatorBuilder 
setDeterministic(boolean isDeterministic) {
   return this;
 }
 
+public DrillSqlOperatorBuilder setNiladic(boolean isNiladic) {
+  /*
+   * Set Operand type-checking strategy for an operator which takes no 
operands
+   */
--- End diff --

Also let's add note here that making function niladic won't allow to select 
column with function name without table alias. Please also add example:
When querying table t with column session_id:
select session_id from table -> will return generated session_id 
select t1.session_id from table t1 -> will return session_id column value


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2017-01-17 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r96446816
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/ops/ContextInformation.java 
---
@@ -28,12 +28,14 @@
   private final String currentDefaultSchema;
   private final long queryStartTime;
   private final int rootFragmentTimeZone;
+  private final String sessionId;
 
-  public ContextInformation(final UserCredentials userCredentials, final 
QueryContextInformation queryContextInfo) {
+  public ContextInformation(UserCredentials userCredentials, final 
QueryContextInformation queryContextInfo) {
--- End diff --

Any particular reason to remove final for one param but leave for another? 
I guess you can just leave it as it was before.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93780471
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/ops/FragmentContext.java ---
@@ -141,7 +141,7 @@ public FragmentContext(final DrillbitContext dbContext, 
final PlanFragment fragm
 this.accountingUserConnection = new 
AccountingUserConnection(connection, sendingAccountor, statusHandler);
 this.fragment = fragment;
 this.funcRegistry = funcRegistry;
-contextInformation = new ContextInformation(fragment.getCredentials(), 
fragment.getContext());
+contextInformation = new ContextInformation(fragment.getCredentials(), 
fragment.getContext(), connection.getSession().getSessionId());
--- End diff --

accessing `connection` results into NPE for non-root fragment contexts.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93743678
  
--- Diff: protocol/src/main/protobuf/User.proto ---
@@ -361,7 +361,7 @@ message ResultColumnMetadata {
   optional ColumnSearchability searchability = 13;
 
   /*
-   * Defaults to READ_ONLY
+   * Defaults to READ_ONLU
--- End diff --

Revert the change


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93741547
  
--- Diff: 
protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java ---
@@ -25001,7 +25001,7 @@ public Builder 
setUpdatability(org.apache.drill.exec.proto.UserProtos.ColumnUpda
*
* 
*
-   * Defaults to READ_ONLU
+   * Defaults to READ_ONLY
--- End diff --

Revert changes as this has got nothing to do with this PR


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93741438
  
--- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/client/DrillClientSystemTest.java
 ---
@@ -17,6 +17,8 @@
  */
 package org.apache.drill.exec.client;
 
+import static org.junit.Assert.assertFalse;
+
--- End diff --

Remove unnecessary newline introduced


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93741386
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/util/Utilities.java ---
@@ -47,7 +47,7 @@ public static String 
getFileNameForQueryFragment(FragmentContext context, String
* QueryContextInformation is derived from the current state of the 
process.
*
* @param defaultSchemaName
-   * @return
+   * @return QueryContextInformation
--- End diff --

Revert the change as this has got nothing to do with this PR.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93740038
  
--- Diff: protocol/src/main/protobuf/UserBitShared.proto ---
@@ -319,4 +319,3 @@ message Jar {
   optional string name = 1;
   repeated string function_signature = 2;
 }
-
--- End diff --

Remove newline introduced


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-23 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93739906
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -343,7 +343,6 @@ public BitToUserHandshake 
getHandshakeResponse(UserToBitHandshake inbound) throw
   if (inbound.getRpcVersion() != UserRpcConfig.RPC_VERSION) {
 final String errMsg = String.format("Invalid rpc version. 
Expected %d, actual %d.",
 UserRpcConfig.RPC_VERSION, inbound.getRpcVersion());
-
--- End diff --

Remove newline introduced


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-21 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93394114
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -255,11 +257,12 @@ void disableReadTimeout() {
   getChannel().pipeline().remove(BasicServer.TIMEOUT_HANDLER);
 }
 
-void setUser(final UserToBitHandshake inbound) throws IOException {
+void setUser(final UserToBitHandshake inbound, Map 
sessionParams) throws IOException {
--- End diff --

@sudheeshkatkam I had created this few days back. But updated details with 
more clarity now. The ticket is: 
[DRILL-5132](https://issues.apache.org/jira/browse/DRILL-5132). Pls let me know 
your views.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread sudheeshkatkam
Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93307327
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -255,11 +257,12 @@ void disableReadTimeout() {
   getChannel().pipeline().remove(BasicServer.TIMEOUT_HANDLER);
 }
 
-void setUser(final UserToBitHandshake inbound) throws IOException {
+void setUser(final UserToBitHandshake inbound, Map 
sessionParams) throws IOException {
--- End diff --

Can you please open a ticket with a details about use case? How will these 
session parameters be used?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93267919
  
--- Diff: protocol/src/main/protobuf/UserBitShared.proto ---
@@ -320,3 +320,17 @@ message Jar {
   repeated string function_signature = 2;
 }
 
+
+/* Session parameter
+message SessionParam {
+  optional string key = 1;
+  optional string value = 2;
+}
+*/
+
+/* User session context that has session id and session parameters
+*/
+message UserSessionContextInformation {
+  optional string session_id = 1;
+  // repeated SessionParam session_params = 2
+}
--- End diff --

My understanding is that the various context information need to be 
transportable (serializable and parcelable) for distributed query execution. 
Hence made it a protobuf message. Pls let me know if my understanding is 
incorrect. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93267316
  
--- Diff: protocol/src/main/protobuf/UserBitShared.proto ---
@@ -320,3 +320,17 @@ message Jar {
   repeated string function_signature = 2;
 }
 
+
+/* Session parameter
+message SessionParam {
+  optional string key = 1;
+  optional string value = 2;
+}
--- End diff --

Though they have same key-value pairs, did not want to overload it for 
different purposes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93267171
  
--- Diff: protocol/src/main/protobuf/UserBitShared.proto ---
@@ -320,3 +320,17 @@ message Jar {
   repeated string function_signature = 2;
 }
 
+
+/* Session parameter
+message SessionParam {
+  optional string key = 1;
+  optional string value = 2;
+}
--- End diff --

Though they have same key-value pairs, did not want to overload it for 
different purposes. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93266381
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -255,11 +257,12 @@ void disableReadTimeout() {
   getChannel().pipeline().remove(BasicServer.TIMEOUT_HANDLER);
 }
 
-void setUser(final UserToBitHandshake inbound) throws IOException {
+void setUser(final UserToBitHandshake inbound, Map 
sessionParams) throws IOException {
--- End diff --

Lets say there is an external custom authenticator It validates the 
credentials with that external system and loads contextual information from 
that external system. Examples:
  - Tenant_Id of the currently logged in user
  - Roles of the user logged in
  - Any user preference details that are loaded in the context of that 
external system
  - Etc..

User Properties, as I understood seem to be the configuration variables 
(E.g., drill-override.conf). These are known expected properties. Whereas 
Session Parameters may not be known properties.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93205867
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/ops/ContextInformation.java 
---
@@ -28,12 +29,14 @@
   private final String currentDefaultSchema;
   private final long queryStartTime;
   private final int rootFragmentTimeZone;
+  private final String sessionId;
 
-  public ContextInformation(final UserCredentials userCredentials, final 
QueryContextInformation queryContextInfo) {
+  public ContextInformation(final UserCredentials userCredentials, final 
UserSessionContextInformation sessionContextInfo, final QueryContextInformation 
queryContextInfo) {
 this.queryUser = userCredentials.getUserName();
 this.currentDefaultSchema = queryContextInfo.getDefaultSchemaName();
 this.queryStartTime = queryContextInfo.getQueryStartTime();
 this.rootFragmentTimeZone = queryContextInfo.getTimeZone();
+this.sessionId = sessionContextInfo.getSessionId();
--- End diff --

If user didn't set sessionContextInfo in builder, we'll get NPE?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93206354
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -255,11 +257,12 @@ void disableReadTimeout() {
   getChannel().pipeline().remove(BasicServer.TIMEOUT_HANDLER);
 }
 
-void setUser(final UserToBitHandshake inbound) throws IOException {
+void setUser(final UserToBitHandshake inbound, Map 
sessionParams) throws IOException {
--- End diff --

sessionParams -> sessionParameters


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93206188
  
--- Diff: protocol/src/main/protobuf/UserBitShared.proto ---
@@ -320,3 +320,17 @@ message Jar {
   repeated string function_signature = 2;
 }
 
+
+/* Session parameter
+message SessionParam {
+  optional string key = 1;
+  optional string value = 2;
+}
--- End diff --

We have similar Property in User.proto, not sure we need to create new 
message with the same content.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93207023
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -255,11 +257,12 @@ void disableReadTimeout() {
   getChannel().pipeline().remove(BasicServer.TIMEOUT_HANDLER);
 }
 
-void setUser(final UserToBitHandshake inbound) throws IOException {
+void setUser(final UserToBitHandshake inbound, Map 
sessionParams) throws IOException {
   session = UserSession.Builder.newBuilder()
   .withCredentials(inbound.getCredentials())
   .withOptionManager(worker.getSystemOptions())
   .withUserProperties(inbound.getProperties())
+  .setSessionContextInfo(sessionParams)
--- End diff --

withSessionParameters(sessionParameters)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93208334
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -255,11 +257,12 @@ void disableReadTimeout() {
   getChannel().pipeline().remove(BasicServer.TIMEOUT_HANDLER);
 }
 
-void setUser(final UserToBitHandshake inbound) throws IOException {
+void setUser(final UserToBitHandshake inbound, Map 
sessionParams) throws IOException {
--- End diff --

Can you give example of sessionParameters? How they are different from 
UserProperties? Can we combine them?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93206036
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserSession.java ---
@@ -160,6 +173,14 @@ public int getQueryCount() {
 return queryCount.get();
   }
 
+  public String getSessionId() {
+return sessionId;
+  }
+
+  public UserSessionContextInformation getSessionContextInfo() {
+return sessionContextInfo;
+  }
--- End diff --

As above, will we return null if user didn't set session context info in 
builder?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93206853
  
--- Diff: protocol/src/main/protobuf/UserBitShared.proto ---
@@ -320,3 +320,17 @@ message Jar {
   repeated string function_signature = 2;
 }
 
+
+/* Session parameter
+message SessionParam {
+  optional string key = 1;
+  optional string value = 2;
+}
+*/
+
+/* User session context that has session id and session parameters
+*/
+message UserSessionContextInformation {
+  optional string session_id = 1;
+  // repeated SessionParam session_params = 2
+}
--- End diff --

Why we are using protobuf for UserSessionContextInformation and not regular 
class?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-20 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93209088
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -343,10 +346,10 @@ public BitToUserHandshake 
getHandshakeResponse(UserToBitHandshake inbound) throw
   if (inbound.getRpcVersion() != UserRpcConfig.RPC_VERSION) {
 final String errMsg = String.format("Invalid rpc version. 
Expected %d, actual %d.",
 UserRpcConfig.RPC_VERSION, inbound.getRpcVersion());
-
 return handleFailure(respBuilder, 
HandshakeStatus.RPC_VERSION_MISMATCH, errMsg, null);
   }
 
+  Map sessionParams = new LinkedHashMap();
--- End diff --

May be it's better to keep setUser method as is, I don't really like the 
idea of creating empty map each time we getHandshakeResponce


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-19 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93128753
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -359,12 +363,14 @@ public BitToUserHandshake 
getHandshakeResponse(UserToBitHandshake inbound) throw
 }
   }
   
authenticator.authenticate(inbound.getCredentials().getUserName(), password);
+  // TODO: make authenticator return a map of session 
parameters and store it in sessionParams.
 } catch (UserAuthenticationException ex) {
+  logger.debug(ex.getMessage());
--- End diff --

remove debug message


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-19 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93128502
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
@@ -343,10 +346,11 @@ public BitToUserHandshake 
getHandshakeResponse(UserToBitHandshake inbound) throw
   if (inbound.getRpcVersion() != UserRpcConfig.RPC_VERSION) {
 final String errMsg = String.format("Invalid rpc version. 
Expected %d, actual %d.",
 UserRpcConfig.RPC_VERSION, inbound.getRpcVersion());
-
+logger.debug(errMsg);
--- End diff --

Remove debug message


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-19 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r93128266
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -64,17 +65,45 @@ public void eval() {
 @Inject DrillBuf buffer;
 @Workspace int currentSchemaBytesLength;
 
+@Override
 public void setup() {
   final byte[] currentSchemaBytes = 
contextInfo.getCurrentDefaultSchema().getBytes();
   buffer = buffer.reallocIfNeeded(currentSchemaBytes.length);
   currentSchemaBytesLength= currentSchemaBytes.length;
   buffer.setBytes(0, currentSchemaBytes);
 }
 
+@Override
 public void eval() {
   out.start = 0;
   out.end = currentSchemaBytesLength;
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE)
+  public static class SessionId implements DrillSimpleFunc {
+@Output VarCharHolder out;
+@Inject ContextInformation contextInfo;
+@Inject DrillBuf buffer;
+@Workspace int sessionIdBytesLength;
+
+@Override
+public void setup() {
+final byte[] sessionIdBytes = 
contextInfo.getSessionId().getBytes();
+buffer = buffer.reallocIfNeeded(sessionIdBytes.length);
+sessionIdBytesLength = sessionIdBytes.length;
+buffer.setBytes(0, sessionIdBytes);
+}
+
+@Override
+public void eval() {
+out.start = 0;
+out.end = sessionIdBytesLength;
+out.buffer = buffer;
+}
+  }
 }
--- End diff --

Invocation of  `session_id()` without parenthesis is pending 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-17 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r92933806
  
--- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/partitionsender/TestPartitionSender.java
 ---
@@ -27,6 +27,7 @@
 import java.io.PrintWriter;
 import java.util.List;
 import java.util.Random;
+import java.util.UUID;
--- End diff --

Unused import needs to be removed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-17 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r92933786
  
--- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/TestLocalExchange.java
 ---
@@ -55,6 +55,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.UUID;
--- End diff --

Unused import needs to be removed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-17 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r92933707
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/ops/ContextInformation.java 
---
@@ -19,6 +19,8 @@
 
 import org.apache.drill.exec.proto.BitControl.QueryContextInformation;
 import org.apache.drill.exec.proto.UserBitShared.UserCredentials;
+import 
org.apache.drill.exec.proto.UserBitShared.UserSessionContextInformation;
--- End diff --

Unused imports need to be removed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-16 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy closed the pull request at:

https://github.com/apache/drill/pull/685


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-16 Thread nagarajanchinnasamy
GitHub user nagarajanchinnasamy reopened a pull request:

https://github.com/apache/drill/pull/685

Drill 5043: Function that returns a unique id per session/connection 
similar to MySQL's CONNECTION_ID()

Please check [DRILL-5043](https://issues.apache.org/jira/browse/DRILL-5043) 
for the details on changes made and other details.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/nagarajanchinnasamy/drill DRILL-5043

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/drill/pull/685.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #685


commit 3062d6052525524bacaad35765ff62b96ff31a42
Author: Nagarajan Chinnasamy 
Date:   2016-12-15T14:18:39Z

DRILL-5043: Function that returns a unique id per session/connection 
similar to MySQL's CONNECTION_ID() #685




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-15 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r92617289
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -77,4 +76,28 @@ public void eval() {
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE)
+  public static class SessionId implements DrillSimpleFunc {
+@Output VarCharHolder out;
+@Inject ContextInformation contextInfo;
+@Inject DrillBuf buffer;
+@Workspace int sessionIdBytesLength;
+
+public void setup() {
--- End diff --

Changes pushed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-14 Thread sudheeshkatkam
Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r92454190
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/ContextFunctions.java
 ---
@@ -77,4 +76,28 @@ public void eval() {
   out.buffer = buffer;
 }
   }
+
+  /**
+   * Implement "session_id" function. Returns the unique id of the current 
session.
+   */
+  @FunctionTemplate(name = "session_id", scope = 
FunctionTemplate.FunctionScope.SIMPLE)
+  public static class SessionId implements DrillSimpleFunc {
+@Output VarCharHolder out;
+@Inject ContextInformation contextInfo;
+@Inject DrillBuf buffer;
+@Workspace int sessionIdBytesLength;
+
+public void setup() {
--- End diff --

Annotate with `@Override`, here and below.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-12 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r91901654
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/util/Utilities.java ---
@@ -43,19 +43,21 @@ public static String 
getFileNameForQueryFragment(FragmentContext context, String
   }
 
   /**
-   * Create QueryContextInformation with given defaultSchemaName. 
Rest of the members of the
+   * Create QueryContextInformation with given defaultSchemaName 
and sessionId. Rest of the members of the
* QueryContextInformation is derived from the current state of the 
process.
*
* @param defaultSchemaName
+   * @param sessionId
* @return
*/
--- End diff --

Please add description for two @param and return, since you are changing 
method description.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-09 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r91826699
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserSession.java ---
@@ -115,6 +118,7 @@ public UserSession build() {
 
   private UserSession() {
 queryCount = new AtomicInteger(0);
+sessionId = nextSessionId.getAndIncrement();
   }
--- End diff --

Thanks Arina. Just realized you are the author of #666 :) Could you please 
tell me how I can merge your changes into my branch. Am new to this process. 
Thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-09 Thread nagarajanchinnasamy
Github user nagarajanchinnasamy commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r91685705
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserSession.java ---
@@ -115,6 +118,7 @@ public UserSession build() {
 
   private UserSession() {
 queryCount = new AtomicInteger(0);
+sessionId = nextSessionId.getAndIncrement();
   }
--- End diff --

Yes. This approach doesn't take distribution in consideration. Looking for 
inputs on what should be the approach for distributed environment. As suggested 
by @paul-rogers I will look into #666 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-08 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r91516244
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserSession.java ---
@@ -115,6 +118,7 @@ public UserSession build() {
 
   private UserSession() {
 queryCount = new AtomicInteger(0);
+sessionId = nextSessionId.getAndIncrement();
   }
--- End diff --

Sorry, I see it's static. But using this approach session id on different 
drillbits may overlap. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-08 Thread arina-ielchiieva
Github user arina-ielchiieva commented on a diff in the pull request:

https://github.com/apache/drill/pull/685#discussion_r91515498
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserSession.java ---
@@ -115,6 +118,7 @@ public UserSession build() {
 
   private UserSession() {
 queryCount = new AtomicInteger(0);
+sessionId = nextSessionId.getAndIncrement();
   }
--- End diff --

As far as I know, UserSession instance is created for each session, won't 
this mean that after your changes each session will have the same id? Actually 
CTTAS are going to add session id in its scope (it's represented as String and 
generated using UUID). You make take a look at those changes - 
https://github.com/apache/drill/pull/666


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...

2016-12-08 Thread nagarajanchinnasamy
GitHub user nagarajanchinnasamy opened a pull request:

https://github.com/apache/drill/pull/685

Drill 5043: Function that returns a unique id per session/connection 
similar to MySQL's CONNECTION_ID()

Please check [DRILL-5043](https://issues.apache.org/jira/browse/DRILL-5043) 
for the details on changes made and other details.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/nagarajanchinnasamy/drill DRILL-5043

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/drill/pull/685.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #685


commit a579e1beaa5ea65c30a08f55abe41a689d8d6ead
Author: Nagarajan Chinnasamy 
Date:   2016-11-19T15:23:34Z

[DRILL-5043] Added session_id() to ContextFunctions - Initial changes

commit a29269b7368de022eb7360b22315cf9471bf8f62
Author: Nagarajan Chinnasamy 
Date:   2016-11-19T15:38:46Z

Merge https://github.com/apache/drill




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---