Skip to content

Commit

Permalink
Added query explain feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenstott committed Jul 28, 2024
1 parent 3d87c57 commit 1b4c78a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion adapters/jdbc/dev.local.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"type": "jdbc",
"name": "DEFAULT",
"jdbcUrl": "jdbc:redshift://default-workgroup.528956693660.us-east-2.redshift-serverless.amazonaws.com:5439/dev?user=redshiftdev&password=#Hasura2024!"
"jdbcUrl": "jdbc:redshift://default-workgroup.528956693660.us-east-2.redshift-serverless.amazonaws.com:5439/dev?user=redshiftdev&password=#Hasura2024!&currentSchema=crm"
}
]
},
Expand Down
17 changes: 15 additions & 2 deletions calcite-rs-jni/src/main/java/org/kenstott/CalciteQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,24 @@ private Map<String, ColumnMetadata> getTableColumnInfo(TableMetadata table) {
entry("TIMESTAMP(3) NOT NULL", "TIMESTAMP"),
entry("TIMESTAMP(3)", "TIMESTAMP"),
entry("TIMESTAMP NOT NULL", "TIMESTAMPTZ"),
entry("TIMESTAMP", "TIMESTAMPTZ")
entry("TIMESTAMP", "TIMESTAMPTZ"),
entry("DECIMAL(10,2)", "FLOAT"),
entry("DECIMAL(12,2)", "FLOAT")
);
String mappedType = remapTypes.get(dataTypeName);
if (mappedType == null) {
mappedType = "VARCHAR";
if (dataTypeName.toLowerCase().contains("varchar")) {
mappedType = "VARCHAR";
}
else if (dataTypeName.toLowerCase().contains("timestamp")) {
mappedType = "TIMESTAMP";
}
else if (dataTypeName.toLowerCase().contains("decimal")) {
mappedType = "FLOAT";
}
else {
mappedType = "VARCHAR";
}
}
if (dataTypeName.startsWith("VARCHAR(65536)") && sqliteFlag) {
if (columnName.toLowerCase().contains("date")) {
Expand Down
9 changes: 1 addition & 8 deletions calcite-rs-jni/src/main/java/org/kenstott/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ public static void main(String[] args) {
String x = query.getModels();
System.out.println(x);
String zz = query.queryPlanModels("""
SELECT COUNT(*) as "count", JSON_ARRAYAGG("TrackId") as "tracks", "c"."FirstName", "c"."LastName" FROM "TEST"."invoice_items"
JOIN "TEST"."invoices" as "i" USING("InvoiceId")
JOIN "TEST"."customers" as "c" USING("CustomerId")
GROUP BY "c"."FirstName", "c"."LastName", "i"."InvoiceId"
""");
System.out.println(zz);
String z1 = query.queryModels("""
SELECT COUNT(*) as "count", JSON_ARRAYAGG("TrackId") as "tracks", "c"."FirstName", "c"."LastName" FROM "TEST"."invoice_items"
JOIN "TEST"."invoices" as "i" USING("InvoiceId")
JOIN "TEST"."customers" as "c" USING("CustomerId")
GROUP BY "c"."FirstName", "c"."LastName", "i"."InvoiceId"
SELECT * from "DEFAULT"."orders" LIMIT 10
"""
);
Expand Down

0 comments on commit 1b4c78a

Please sign in to comment.