Skip to content

Commit

Permalink
[#3800]fix(trino-connector): EXPLAIN command can not show query optim…
Browse files Browse the repository at this point in the history
…ize details (#3801)

### What changes were proposed in this pull request?

The EXPLAIN command cannot display query optimization details when using
the Gravitino Trino connector

### Why are the changes needed?

Fix: #3800

### Does this PR introduce _any_ user-facing change?

NO

### How was this patch tested?

IT
  • Loading branch information
diqiu50 authored Jun 12, 2024
1 parent 204c05d commit 08a8193
Show file tree
Hide file tree
Showing 17 changed files with 305 additions and 261 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
CREATE SCHEMA

USE

CREATE TABLE

CREATE TABLE

INSERT: 1500 rows

INSERT: 15000 rows

"Trino version: %
%
└─ TableScan[table = gt_mysql:gt_db1.customer->gt_db1.customer gt_db1.customer limit=10 columns=[custkey:bigint:BIGINT]]
Layout: [custkey:bigint]
%
"

"Trino version: %
%
└─ ScanFilter[table = gt_mysql:gt_db1.customer->gt_db1.customer gt_db1.customer, filterPredicate = ""$like""(""phone"", ""$literal$""(from_base64('DgAAAFZBUklBQkxFX1dJRFRIAQAAAAEAAAALAAAAAAsAAAAGAAAAJTIzNDIlAA==')))]
Layout: [custkey:bigint, name:varchar(25), address:varchar(40), nationkey:bigint, phone:varchar(15), acctbal:decimal(12,2), mktsegment:varchar(10), comment:varchar(117)]
%
"

"Trino version: %
%
└─ TableScan[table = gt_mysql:gt_db1.orders->Query[SELECT sum(`totalprice`) AS `_pfgnrtd_0` FROM `gt_db1`.`orders`] columns=[_pfgnrtd_0:decimal(38,2):decimal]]
Layout: [_pfgnrtd:decimal(38,2)]
%
"

"Trino version: %
%
└─ TableScan[table = gt_mysql:gt_db1.orders->Query[SELECT `orderdate`, sum(`totalprice`) AS `_pfgnrtd_0` FROM `gt_db1`.`orders` GROUP BY `orderdate`] sortOrder=[orderdate:date:DATE ASC NULLS LAST] limit=10 columns=[orderdate:date:DATE, _pfgnrtd_0:decimal(38,2):decimal]]
Layout: [orderdate:date, _pfgnrtd:decimal(38,2)]
%
"

"Trino version: %
%
└─ TableScan[table = gt_mysql:gt_db1.%->Query[SELECT % INNER JOIN %] limit=10 columns=%]]
%
"

DROP TABLE

DROP TABLE

DROP SCHEMA

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
CREATE SCHEMA

USE

CREATE TABLE

CREATE TABLE

INSERT: 1500 rows

INSERT: 15000 rows

"Trino version: %
%
└─ TableScan[table = gt_postgresql:gt_db1.customer->gt_db1.customer gt_db1.customer limit=10 columns=[custkey:bigint:int8]]
Layout: [custkey:bigint]
%
"

"Trino version: %
%
└─ TableScan[table = gt_postgresql:gt_db1.customer->gt_db1.customer gt_db1.customer constraints=[ParameterizedExpression[expression=(""phone"") LIKE (?), parameters=[QueryParameter{jdbcType=Optional.empty, type=varchar(6), value=Optional[Slice{base=[B@%, baseOffset=0, length=6}]}]]] limit=10]
Layout: [custkey:bigint, name:varchar(25), address:varchar(40), nationkey:bigint, phone:varchar(15), acctbal:decimal(12,2), mktsegment:varchar(10), comment:varchar(117)]
%
"

"Trino version: %
%
└─ TableScan[table = gt_postgresql:gt_db1.orders->Query[SELECT sum(""totalprice"") AS ""_pfgnrtd_0"" FROM ""gt_db1"".""orders""] columns=[_pfgnrtd_0:decimal(38,2):decimal]]
Layout: [_pfgnrtd:decimal(38,2)]
%
"

"Trino version: %
%
└─ TableScan[table = gt_postgresql:gt_db1.%->Query[SELECT ""orderdate"", sum(""totalprice"") AS ""_pfgnrtd_0"" FROM ""gt_db1"".""orders"" GROUP BY ""orderdate""] sortOrder=[orderdate:date:date ASC NULLS LAST] limit=10 columns=[orderdate:date:date, _pfgnrtd_0:decimal(38,2):decimal]]
Layout: [orderdate:date, _pfgnrtd:decimal(38,2)]
%
"

"Trino version: %
%
TableScan[table = gt_postgresql:gt_db1.orders->Query[SELECT % INNER JOIN %] limit=10 columns=%]
%
"

DROP TABLE

DROP TABLE

DROP SCHEMA

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return columnName;
return columnName + "->" + getInternalHandle().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class GravitinoConnectorFactory implements ConnectorFactory {

private static final Logger LOG = LoggerFactory.getLogger(GravitinoConnectorFactory.class);
private static final String DEFAULT_CONNECTOR_NAME = "gravitino";
public static final String DEFAULT_CONNECTOR_NAME = "gravitino";

@SuppressWarnings("UnusedVariable")
private GravitinoSystemTableFactory gravitinoSystemTableFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package com.datastrato.gravitino.trino.connector;

import static com.datastrato.gravitino.trino.connector.GravitinoConnectorFactory.DEFAULT_CONNECTOR_NAME;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.trino.spi.HostAddress;
Expand Down Expand Up @@ -63,4 +65,9 @@ public SplitWeight getSplitWeight() {
public long getRetainedSizeInBytes() {
return handleWrapper.getHandle().getRetainedSizeInBytes();
}

@Override
public String toString() {
return DEFAULT_CONNECTOR_NAME + "->" + getInternalHandle().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return schemaName + ":" + tableName;
return String.format("%s.%s->%s", schemaName, tableName, getInternalHandle().toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package com.datastrato.gravitino.trino.connector;

import static com.datastrato.gravitino.trino.connector.GravitinoConnectorFactory.DEFAULT_CONNECTOR_NAME;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.trino.spi.connector.ConnectorTransactionHandle;
Expand Down Expand Up @@ -37,4 +39,9 @@ public String getHandleString() {
public ConnectorTransactionHandle getInternalHandle() {
return handleWrapper.getHandle();
}

@Override
public String toString() {
return DEFAULT_CONNECTOR_NAME + "->" + getInternalHandle().toString();
}
}
Loading

0 comments on commit 08a8193

Please sign in to comment.