From 8bb38a04a5e4e895236b6e93b60faedb9bf3556d Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Thu, 25 Jul 2024 03:33:33 +0000 Subject: [PATCH] fix FIMXE --- .../org/apache/druid/sql/avatica/MSQDruidMeta.java | 2 +- .../org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq | 10 +++++----- .../main/java/org/apache/druid/sql/SqlQueryPlus.java | 7 +++++++ .../druid/sql/avatica/AbstractDruidJdbcStatement.java | 7 +++++++ .../apache/druid/sql/avatica/DruidJdbcStatement.java | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java index 0473d1b8e48..92b0ab4b915 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java @@ -117,7 +117,7 @@ public class MSQDruidMeta extends DruidMeta RelDataType rowType = RowSignatures.toRelDataType(sig, DruidTypeSystem.TYPE_FACTORY); return Meta.Signature.create( AbstractDruidJdbcStatement.createColumnMetaData(rowType), - "FIXME some query?", + druidStatement.getSqlQuery().sql(), Collections.emptyList(), Meta.CursorFactory.ARRAY, Meta.StatementType.SELECT diff --git a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq index 959f5dea406..73c8ea0a263 100644 --- a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq +++ b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq1.iq @@ -94,7 +94,7 @@ order by 1; "finalize" : true, "maxParseExceptions" : 0, "plannerStrategy" : "DECOUPLED", - "sqlQueryId" : "86f85662-42c2-462f-8d1f-a692c33ebe99", + "sqlQueryId" : "959637f0-a795-41f2-9cf0-f12e29361401", "sqlStringifyArrays" : false } } @@ -127,8 +127,8 @@ order by 1; "partitionCount" : 1, "shuffle" : "globalSort", "output" : "localStorage", - "startTime" : "2024-07-24T17:24:33.755Z", - "duration" : 657, + "startTime" : "2024-07-25T03:33:28.256Z", + "duration" : 754, "sort" : true }, { "stageNumber" : 1, @@ -200,7 +200,7 @@ order by 1; "finalize" : true, "maxParseExceptions" : 0, "plannerStrategy" : "DECOUPLED", - "sqlQueryId" : "86f85662-42c2-462f-8d1f-a692c33ebe99", + "sqlQueryId" : "959637f0-a795-41f2-9cf0-f12e29361401", "sqlStringifyArrays" : false } } @@ -221,7 +221,7 @@ order by 1; "workerCount" : 1, "partitionCount" : 1, "output" : "localStorage", - "startTime" : "2024-07-24T17:24:34.412Z", + "startTime" : "2024-07-25T03:33:29.010Z", "duration" : 2 } ] !msqPlan diff --git a/sql/src/main/java/org/apache/druid/sql/SqlQueryPlus.java b/sql/src/main/java/org/apache/druid/sql/SqlQueryPlus.java index 2aadecda767..8d06a65fa35 100644 --- a/sql/src/main/java/org/apache/druid/sql/SqlQueryPlus.java +++ b/sql/src/main/java/org/apache/druid/sql/SqlQueryPlus.java @@ -116,6 +116,13 @@ public class SqlQueryPlus return new SqlQueryPlus(sql, queryContext, parameters, authResult); } + @Override + public String toString() + { + return "SqlQueryPlus {queryContext=" + queryContext + ", parameters=" + parameters + + ", authResult=" + authResult + ", sql=" + sql + " }"; + } + public static class Builder { private String sql; diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/AbstractDruidJdbcStatement.java b/sql/src/main/java/org/apache/druid/sql/avatica/AbstractDruidJdbcStatement.java index 6e3afcdcc37..79be8811c74 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/AbstractDruidJdbcStatement.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/AbstractDruidJdbcStatement.java @@ -27,6 +27,7 @@ import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.rel.type.RelDataTypeField; import org.apache.calcite.sql.type.SqlTypeName; import org.apache.druid.java.util.common.ISE; +import org.apache.druid.sql.SqlQueryPlus; import org.apache.druid.sql.avatica.DruidJdbcResultSet.ResultFetcherFactory; import org.apache.druid.sql.calcite.planner.Calcites; import org.apache.druid.sql.calcite.planner.PrepareResult; @@ -59,6 +60,7 @@ public abstract class AbstractDruidJdbcStatement implements Closeable protected final ResultFetcherFactory fetcherFactory; protected Throwable throwable; protected DruidJdbcResultSet resultSet; + protected SqlQueryPlus sqlQuery; public AbstractDruidJdbcStatement( final String connectionId, @@ -246,4 +248,9 @@ public abstract class AbstractDruidJdbcStatement implements Closeable { return statementId; } + + public SqlQueryPlus getSqlQuery() + { + return sqlQuery; + } } diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/DruidJdbcStatement.java b/sql/src/main/java/org/apache/druid/sql/avatica/DruidJdbcStatement.java index 4c342a46fef..006a46a8f8e 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/DruidJdbcStatement.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/DruidJdbcStatement.java @@ -57,8 +57,8 @@ public class DruidJdbcStatement extends AbstractDruidJdbcStatement public synchronized void execute(SqlQueryPlus queryPlus, long maxRowCount) { closeResultSet(); - queryPlus = queryPlus.withContext(queryContext); - DirectStatement stmt = lifecycleFactory.directStatement(queryPlus); + this.sqlQuery = queryPlus.withContext(queryContext); + DirectStatement stmt = lifecycleFactory.directStatement(this.sqlQuery); resultSet = new DruidJdbcResultSet(this, stmt, Long.MAX_VALUE, fetcherFactory); try { resultSet.execute();