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.
---

Reply via email to