Skip to content

Commit

Permalink
Updated CLI Plugin to execute within a container.
Browse files Browse the repository at this point in the history
Added CLI Plugin to data connector image.
  • Loading branch information
kenstott committed Aug 24, 2024
1 parent 09a572f commit 1d40b43
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 233 deletions.
271 changes: 54 additions & 217 deletions adapters/file/dev.local.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,299 +6,136 @@
"defaultSchema": "sales",
"schemas": [
{
"type": "custom",
"name": "sales",
"factory": "org.apache.calcite.adapter.file.FileSchemaFactory",
"operand": {
"directory": "/Users/kennethstott/Documents/GitHub/ndc-calcite/adapters/file/resources/test/bug"
}
"tables": [
{
"name": "EMPS",
"type": "custom",
"factory": "org.apache.calcite.adapter.file.CsvTableFactory",
"operand": {}
},
{
"name": "female_emps",
"type": "view",
"sql": "select * from \"EMPS\" where \"GENDER\" = 'F'",
"modifiable": false
}
]
}
]
},
"model_file_path": "./model.json",
"fixes": true,
"metadata": {
"ARCHERS": {
"EMPS": {
"schema": "sales",
"name": "ARCHERS",
"name": "EMPS",
"columns": {
"f": {
"name": "f",
"scalarType": "VARCHAR",
"nullable": true
},
"d": {
"name": "d",
"scalarType": "LIST",
"nullable": true
},
"c": {
"name": "c",
"scalarType": "VARCHAR",
"nullable": true
},
"e": {
"name": "e",
"scalarType": "VARCHAR",
"nullable": true
},
"b": {
"name": "b",
"scalarType": "VARCHAR",
"nullable": true
},
"object": {
"name": "object",
"scalarType": "VARCHAR",
"nullable": true
},
"id": {
"name": "id",
"scalarType": "INTEGER",
"nullable": true
},
"a": {
"name": "a",
"CITY": {
"name": "CITY",
"scalarType": "VARCHAR",
"nullable": true
},
"g": {
"name": "g",
"scalarType": "LIST",
"nullable": true
}
},
"primaryKeys": [],
"exportedKeys": []
},
"test": {
"schema": "sales",
"name": "test",
"columns": {
"id": {
"name": "id",
"DEPTNO": {
"name": "DEPTNO",
"scalarType": "INTEGER",
"nullable": true
},
"d": {
"name": "d",
"scalarType": "LIST",
"nullable": true
},
"b": {
"name": "b",
"scalarType": "VARCHAR",
"nullable": true
},
"object": {
"name": "object",
"scalarType": "VARCHAR",
"nullable": true
},
"f": {
"name": "f",
"scalarType": "VARCHAR",
"nullable": true
},
"c": {
"name": "c",
"scalarType": "VARCHAR",
"nullable": true
},
"g": {
"name": "g",
"scalarType": "LIST",
"nullable": true
},
"a": {
"name": "a",
"scalarType": "VARCHAR",
"JOINEDAT": {
"name": "JOINEDAT",
"scalarType": "DATE",
"nullable": true
},
"e": {
"name": "e",
"scalarType": "VARCHAR",
"nullable": true
}
},
"primaryKeys": [],
"exportedKeys": []
},
"LONG_EMPS": {
"schema": "sales",
"name": "LONG_EMPS",
"columns": {
"EMPID": {
"name": "EMPID",
"scalarType": "INTEGER",
"nullable": true
},
"CITY": {
"name": "CITY",
"scalarType": "VARCHAR",
"nullable": true
},
"SLACKER": {
"name": "SLACKER",
"scalarType": "BOOLEAN",
"nullable": true
},
"EMPNO": {
"name": "EMPNO",
"scalarType": "INTEGER",
"nullable": true
},
"DEPTNO": {
"name": "DEPTNO",
"scalarType": "INTEGER",
"nullable": true
},
"AGE": {
"name": "AGE",
"scalarType": "INTEGER",
"MANAGER": {
"name": "MANAGER",
"scalarType": "BOOLEAN",
"nullable": true
},
"GENDER": {
"name": "GENDER",
"scalarType": "VARCHAR",
"nullable": true
},
"MANAGER": {
"name": "MANAGER",
"scalarType": "BOOLEAN",
"NAME": {
"name": "NAME",
"scalarType": "VARCHAR",
"nullable": true
},
"JOINEDAT": {
"name": "JOINEDAT",
"scalarType": "DATE",
"EMPNO": {
"name": "EMPNO",
"scalarType": "INTEGER",
"nullable": true
},
"NAME": {
"name": "NAME",
"scalarType": "VARCHAR",
"AGE": {
"name": "AGE",
"scalarType": "INTEGER",
"nullable": true
}
},
"primaryKeys": [],
"exportedKeys": []
},
"WACKY_COLUMN_NAMES": {
"female_emps": {
"schema": "sales",
"name": "WACKY_COLUMN_NAMES",
"name": "female_emps",
"columns": {
"CITY": {
"name": "CITY",
"NAME": {
"name": "NAME",
"scalarType": "VARCHAR",
"nullable": true
},
"SLACKER": {
"name": "SLACKER",
"scalarType": "BOOLEAN",
"GENDER": {
"name": "GENDER",
"scalarType": "VARCHAR",
"nullable": true
},
"EMPNO": {
"name": "EMPNO",
"DEPTNO": {
"name": "DEPTNO",
"scalarType": "INTEGER",
"nullable": true
},
"2gender": {
"name": "2gender",
"scalarType": "VARCHAR",
"nullable": true
},
"AGE": {
"name": "AGE",
"scalarType": "INTEGER",
"nullable": true
},
"naME": {
"name": "naME",
"CITY": {
"name": "CITY",
"scalarType": "VARCHAR",
"nullable": true
},
"EMPID": {
"name": "EMPID",
"scalarType": "INTEGER",
"nullable": true
},
"MANAGER": {
"name": "MANAGER",
"scalarType": "BOOLEAN",
"nullable": true
},
"DEPTNO": {
"name": "DEPTNO",
"scalarType": "VARCHAR",
"nullable": true
},
"joined at": {
"name": "joined at",
"scalarType": "DATE",
"nullable": true
}
},
"primaryKeys": [],
"exportedKeys": []
},
"configuration": {
"schema": "sales",
"name": "configuration",
"columns": {
"metadata": {
"name": "metadata",
"scalarType": "MAP",
"nullable": true
},
"fixes": {
"name": "fixes",
"scalarType": "VARCHAR",
"nullable": true
},
"$schema": {
"name": "$schema",
"scalarType": "VARCHAR",
"nullable": true
},
"model": {
"name": "model",
"scalarType": "MAP",
"nullable": true
},
"model_file_path": {
"name": "model_file_path",
"scalarType": "VARCHAR",
"EMPNO": {
"name": "EMPNO",
"scalarType": "INTEGER",
"nullable": true
},
"version": {
"name": "version",
"scalarType": "VARCHAR",
"nullable": true
}
},
"primaryKeys": [],
"exportedKeys": []
},
"DATES": {
"schema": "sales",
"name": "DATES",
"columns": {
"JOINTIMES": {
"name": "JOINTIMES",
"scalarType": "TIMESTAMP",
"SLACKER": {
"name": "SLACKER",
"scalarType": "BOOLEAN",
"nullable": true
},
"JOINEDAT": {
"name": "JOINEDAT",
"scalarType": "DATE",
"nullable": true
},
"JOINTIME": {
"name": "JOINTIME",
"scalarType": "TIME",
"nullable": true
},
"EMPNO": {
"name": "EMPNO",
"EMPID": {
"name": "EMPID",
"scalarType": "INTEGER",
"nullable": true
}
Expand Down
2 changes: 1 addition & 1 deletion adapters/file/resources/test/bug/DATES.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EMPNO:int,JOINEDAT:date,JOINTIME:time,JOINTIMES:timestamp
EMPNO:int,JOINEDAT:date,JOINTIME:string,JOINTIMES:timestamp
100,"1996-08-03","00:01:02","1996-08-03 00:01:02"
110,"2001-01-01","00:00:00","2001-01-01 00:00:00"
110,"2002-05-03","00:00:00","2002-05-03 00:00:00"
Expand Down
2 changes: 1 addition & 1 deletion adapters/file/resources/test/bug/WACKY_COLUMN_NAMES.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EMPNO:int,naME:string,DEPTNO:Integer,2gender:string,CITY:string,EMPID:int,AGE:int,SLACKER:boolean,MANAGER:boolean,joined at:date
EMPNO:int,naME:string,DEPTNO:int,2gender:string,CITY:string,EMPID:int,AGE:int,SLACKER:boolean,MANAGER:boolean,joined at:date
100,"Fred",10,,,30,25,true,false,"1996-08-03"
110,"Eric",20,"M","San Francisco",3,80,,false,"2001-01-01"
110,"John",40,"M","Vancouver",2,,false,true,"2002-05-03"
Expand Down
2 changes: 1 addition & 1 deletion calcite-rs-jni/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.16.1.1</version>
<version>10.17.1.0</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
Expand Down
3 changes: 2 additions & 1 deletion calcite-rs-jni/src/main/java/org/kenstott/CalciteQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ public Connection createCalciteConnection(String modelPath) {
Properties info = new Properties();
info.setProperty("model", modelPath);
try {
Class.forName("org.apache.calcite.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:calcite:", info);
rootSchema = connection.unwrap(CalciteConnection.class).getRootSchema().unwrap(CalciteSchema.class);
} catch (SQLException e) {
} catch (SQLException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
span.end();
Expand Down
2 changes: 1 addition & 1 deletion calcite-rs-jni/src/main/java/org/kenstott/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void main(String[] args) {
// """);
// System.out.println(zz);
String z1 = query.queryModels("""
SELECT COUNT("a") AS "a_count", COUNT(DISTINCT "a") AS "a_distinct_count", COUNT("b") AS "b_count", COUNT(DISTINCT "b") AS "b_distinct_count", COUNT("c") AS "c_count", COUNT(DISTINCT "c") AS "c_distinct_count", COUNT("d") AS "d_count", COUNT(DISTINCT "d") AS "d_distinct_count", COUNT("e") AS "e_count", COUNT(DISTINCT "e") AS "e_distinct_count", COUNT("f") AS "f_count", COUNT(DISTINCT "f") AS "f_distinct_count", COUNT("g") AS "g_count", COUNT(DISTINCT "g") AS "g_distinct_count", COUNT("id") AS "id_count", COUNT(DISTINCT "id") AS "id_distinct_count", COUNT("object") AS "object_count", COUNT(DISTINCT "object") AS "object_distinct_count" FROM "sales"."ARCHERS" LIMIT 10
SELECT * from "sales"."female_emps"
"""
);
System.out.println(z1);
Expand Down
Loading

0 comments on commit 1d40b43

Please sign in to comment.