Forum

General topics applicable to all languages
Contributor
Offline
Posts: 183
Joined: Wed May 29, 2013 2:10 pm
Location: Bracknell

Using external scripts in Kognitio Console

by MikeAtkinson » Wed May 29, 2013 2:26 pm

External scripts in the new version 8 of the Kognitio Analytics Platform are amazingly powerful (you can download the latest preview release at http://www.kognitio.com/forums/viewtopi ... wnload#p16).

I've been using them to do directory listings as part of testing of a new Browse External Data Sources feature for Kognitio Console.

First create the script environment, this runs the scripts in 'sh'.

Code: Select all

create script environment sh_sev command '/bin/sh'; 
Then a scripts to perform a 'ls' on a directory path, each row returned will be one line in the directory listing.

Code: Select all

create external script sys.ls environment sys.sh_sev receives (args varchar(32000)) sends (res varchar(32000)) script 'xargs -r ls -al';
And another one to get the first 10 lines of a file as rows:

Code: Select all

create external script sys.head environment sys.sh_sev receives (args varchar(32000)) sends (res varchar(32000)) output 'format "%0c"\\n' script 'xargs -r head -10';
Now they can be queried just like any other table or view. e.g. do 'ls -al /'

Code: Select all

select * from (external script sys.ls from (select * from values ('/')))dt;
And show the first 10 lines of a file:

Code: Select all

select * from (external script sys.head from (select * from values ('/home/mike/mydata.xml')))dt

Together with a little Kognitio Console UI code, these allow a browser of the server side directories. For example these external scripts and tables may be used to create a general purpose data browser.

Image

Although this works, and works well, an even better way to access many data sources would be to use external tables. An admin would set up external tables to browse hadoop clusters, tables in other databases, etc. Then any user with privileges, may use them.
Reply with quote Top
Contributor
Offline
User avatar
Posts: 48
Joined: Tue May 28, 2013 1:44 pm

Re: Using external scripts in Kognitio Console

by anonymous2 » Fri Jun 14, 2013 12:53 pm

Thanks Mike, very helpful.
Reply with quote Top

Who is online

Users browsing this forum: No registered users and 1 guest

cron