Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> Re: [jira] [Commented] (DRILL-159) 1.sql


Copy link to this message
-
Re: [jira] [Commented] (DRILL-159) 1.sql

On Jul 31, 2013, at 12:17 PM, Sree V <[EMAIL PROTECTED]> wrote:

> You mean this, Julian.
>
>     private static final String MODEL_LINEITEM >           "{\n"
>         + "  version: '1.0',\n"
>         + "   schemas: [\n"
>         + "     {\n"
>         + "       name: 'LINEITEM',\n"
>         + "       tables: [\n"
>         + "         {\n"
>         + "           name: 'LINEITEM',\n"
>         + "           type: 'custom',\n"
>         + "           factory: '" + DrillTable.Factory.class.getName() + "',\n"
>         + "           operand: {\n"
>         + "             path: '/lineitem.tbl.1.json'\n"
>         + "           }\n"
>         + "         }\n"
>         + "       ]\n"
>         + "     }\n"
>         + "   ]\n"
>         + "}";

Yes, something like that. That's the table definition. You also need to include a view in the schema that selects from the table and produces named fields.

On Jul 31, 2013, at 12:57 AM, Ted Dunning <[EMAIL PROTECTED]> wrote:

> How should such a schema definition file be accessed?

The simplest thing is to reference the schema definition in the Optiq JDBC connect string. From sqlline:

sqlline> !connect jdbc:optiq:model=path/to/model.json

(See more examples and background at https://github.com/julianhyde/optiq-csv/blob/master/TUTORIAL.md.)

> Is there a good dynamic way to attach tables to files?
Do you mean, how can I access a file as a table if I haven't previously defined columns for it? You need to define an Optiq schema so that you can access the raw table (the one with the _MAP column). Then instead of defining a view on that table, you can just execute a SQL statement.

Suppose you have the LINEITEM table as in Sree's schema above. Then you can write

sqlline> select cast(_MAP['ORDERKEY'] AS INTEGER) as ORDERKEY from LINEITEM;

and so forth.

Julian
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB