GitHub user sanjaydasgupta opened a pull request:

    https://github.com/apache/zeppelin/pull/2834

    [ZEPPELIN-1967] Passing Z variables to Shell and SQL Interpreters

    ### What is this PR for?
    
    The code in this PR enables embedding/interpolating Z variables into 
command strings passed to Spark's SQL and Shell interpreters. It implements the 
functionality described in issue 
[ZEPPELIN-1967](https://issues.apache.org/jira/browse/ZEPPELIN-1967)
    
    This PR resumes a fresh effort while taking into consideration all of the 
discussion in the context of the earlier 
[PR-2502](https://github.com/apache/zeppelin/pull/2502). The earlier PR-2502 
was closed due to a corruption in my repo that could not be corrected.
    
    The code in this PR resolves all of the discussion and suggestions in the 
body of the earlier [PR-2502](https://github.com/apache/zeppelin/pull/2502). 
The following description is a summary of the current implementation:
    
    Patterns of the form `{var-name}` within commands will be interpolated only 
if a predefined object of the specified name exists in `z`. Additionally, all 
such patterns within the command line should also be translatable for any 
interpolation to occur. Partial translation of a command line (where only some 
of the patterns are translated, and others are not) is never performed.
    
    Patterns of the form `{{any-text}}` are translated into `{any-text}`. This 
feature is an escaping mechanism that allows `{` and `}` characters to be 
passed into a command without invoking the interpolation mechanism.
    
    The translations described above are performed only when all occurrences of 
`{`, `}`, `{{`, and `}}` in any command string conform to one of the two forms 
described above. A command that contains `{` and/or `}` characters used in any 
other way (than `{var-name}` and `{{any-text}}` as described above) will be 
used as-is without attempting any translations whatsoever -- even if the 
command also contains legal, translate-able and/or escape-able, constructs of 
the above two forms.
    
    No error is flagged in any case. This behavior is identical to the 
implementation of a similar feature in
    Jupyter's shell invocation using the ! magic command.
    
    At present only the SQL and Shell interpreters support object interpolation.
    
    ### What type of PR is it?
    [Improvement]
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    
    https://issues.apache.org/jira/browse/ZEPPELIN-1967
    
    ### How should this be tested?
    
    A new unit-test class ZeppCtxtVariableTest.java (see below) has been added. 
The attached screenshots below also show tests of the functionality.
    
    ### Screenshots (if appropriate)
    
    
![figure-1](https://user-images.githubusercontent.com/477015/36956999-5f8cca92-2057-11e8-8b76-f4ccd2a21d50.png)
    
![figure-2](https://user-images.githubusercontent.com/477015/36957001-650f271c-2057-11e8-8e94-4805fd24e796.png)
    
![figure-3](https://user-images.githubusercontent.com/477015/36957005-6a747dec-2057-11e8-9c72-4ebef17b52db.png)
    
![figure-4](https://user-images.githubusercontent.com/477015/36957006-6df95ad2-2057-11e8-8585-3eb679e3a146.png)
    
![figure-5](https://user-images.githubusercontent.com/477015/36957011-7284be02-2057-11e8-9204-3774121397e6.png)
    
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? Yes, and detailed documentation has been 
added to the part describing ZeppelinContext variables (see file spark.md 
below).


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

    $ git pull https://github.com/sanjaydasgupta/zeppelin ZEPPELIN-1967

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

    https://github.com/apache/zeppelin/pull/2834.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 #2834
    
----
commit 28688256f3b11e696c08ed10875e0596db8c0463
Author: Sanjay Dasgupta <sanjay.dasgupta@...>
Date:   2018-03-04T07:36:48Z

    ZEPPELIN-1967: Initial updates

commit b461c82569e86436239c9d14a8ae38230bc4f357
Author: Sanjay Dasgupta <sanjay.dasgupta@...>
Date:   2018-03-05T02:00:10Z

    Merge branch 'master' of https://github.com/apache/zeppelin into 
ZEPPELIN-1967

----


---

Reply via email to