drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arina-ielchiieva <...@git.apache.org>
Subject [GitHub] drill pull request #685: Drill 5043: Function that returns a unique id per s...
Date Fri, 27 Jan 2017 11:34:28 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message