Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

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


+
Sree V 2013-07-30, 17:18
+
Ted Dunning 2013-07-30, 18:24
+
Sree V 2013-07-30, 19:20
+
Sree V 2013-07-30, 06:14
+
Ted Dunning 2013-07-30, 07:11
+
Sree V 2013-07-30, 15:41
+
Julian Hyde 2013-07-30, 21:21
+
Sree V 2013-07-30, 23:33
+
Sree V 2013-07-30, 23:37
+
Ted Dunning 2013-07-31, 06:54
+
Julian Hyde 2013-07-31, 07:31
+
Ted Dunning 2013-07-31, 07:57
Copy link to this message
-
Re: [jira] [Commented] (DRILL-159) 1.sql
Sree V 2013-07-31, 19:17
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"
        + "}";
V
________________________________
 From: Julian Hyde <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: Sree V <[EMAIL PROTECTED]>
Sent: Wednesday, July 31, 2013 12:31 AM
Subject: Re: [jira] [Commented] (DRILL-159) 1.sql
 

Ah, I just remembered that we don't have a schema! Therefore the table just has one column, called _MAP. (Run "!columns" and you'll find out.)

I usually create an Optiq schema with a table and a view for each "table". The view creates columns on the fly using the [...] and CAST operators, then assigns them names using AS.

For example,

{
  version: '1.0',
   schemas: [
     {
       name: 'HR',
       tables: [
         {
           name: 'EMPLOYEES',
           type: 'custom',
           factory: 'org.apache.drill.jdbc.DrillTable.Factory'
         },
         {
           name: 'DEPARTMENTS',
           type: 'custom',
           factory: 'org.apache.drill.jdbc.DrillTable.Factory'
         },
         {
           name: 'EMP',
           type: 'view',
           sql: 'select _MAP[\\'deptId\\'] as deptid, cast(_MAP[\\'lastName\\'] as varchar) as lastName from employees'
         },
         {
           name: 'DEPT',
           type: 'view',
           sql: 'select _MAP[\\'deptId\\'] as deptid, _MAP[\\'name\\'] as name from departments'
         }
       ]
     }
   ]
}
If there's a more elegant way to provide schema, someone please holler!

Julian
+
Julian Hyde 2013-07-31, 19:45
+
Ted Dunning 2013-07-31, 23:55
+
Julian Hyde 2013-08-01, 00:22
+
Ted Dunning 2013-08-01, 01:38