From fe4700f2c781550e986e42153b86bd5582c7e405 Mon Sep 17 00:00:00 2001 From: Abhishoya Lunavat <87463332+abhishoya-gs@users.noreply.github.com> Date: Sat, 23 Sep 2023 10:15:57 +0530 Subject: [PATCH] Flag for sql logging in VoidRelationalResult - used for temp table (#2285) --- .../stores/relational/RelationalExecutor.java | 6 +++--- .../result/VoidRelationalResult.java | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/RelationalExecutor.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/RelationalExecutor.java index 1d82643aac0..1267e4bdcc2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/RelationalExecutor.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/RelationalExecutor.java @@ -146,7 +146,7 @@ public Result execute(RelationalExecutionNode node, MutableList p } else if (node.isResultVoid()) { - return new VoidRelationalResult(executionState.activities, connectionManagerConnection, profiles); + return new VoidRelationalResult(executionState.activities, node, connectionManagerConnection, profiles, executionState.logSQLWithParamValues()); } else { @@ -202,7 +202,7 @@ else if (ExecutionNodeClassResultHelper.isClassResult(node) && rowValueMaps.size } else if (node.isResultVoid()) { - return new VoidRelationalResult(executionState.activities, connectionManagerConnection, profiles); + return new VoidRelationalResult(executionState.activities, node, connectionManagerConnection, profiles, executionState.logSQLWithParamValues()); } else { @@ -241,7 +241,7 @@ public Result execute(SQLExecutionNode node, MutableList profiles if (node.isResultVoid()) { - return new VoidRelationalResult(executionState.activities, connectionManagerConnection, profiles); + return new VoidRelationalResult(executionState.activities, node, connectionManagerConnection, profiles, executionState.logSQLWithParamValues()); } return new SQLExecutionResult(executionState.activities, node, databaseType, databaseTimeZone, connectionManagerConnection, profiles, tempTableList, executionState.topSpan, executionState.getRequestContext(), executionState.logSQLWithParamValues()); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/VoidRelationalResult.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/VoidRelationalResult.java index d3a3e6560f8..70513b47129 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/VoidRelationalResult.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/VoidRelationalResult.java @@ -19,6 +19,9 @@ import org.finos.legend.engine.plan.execution.result.Result; import org.finos.legend.engine.plan.execution.result.ResultVisitor; import org.finos.legend.engine.plan.execution.stores.relational.activity.RelationalExecutionActivity; +import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.nodes.RelationalExecutionNode; +import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.nodes.SQLExecutionNode; +import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.nodes.ExecutionNode; import org.finos.legend.engine.shared.core.operational.logs.LogInfo; import org.finos.legend.engine.shared.core.operational.logs.LoggingEventType; import org.pac4j.core.profile.CommonProfile; @@ -35,7 +38,13 @@ public class VoidRelationalResult extends Result private Connection connection; private Statement statement; + @Deprecated public VoidRelationalResult(MutableList activities, Connection connection, MutableList profiles) + { + this(activities, null, connection, profiles, true); + } + + public VoidRelationalResult(MutableList activities, ExecutionNode node, Connection connection, MutableList profiles, boolean logSQLWithParamValues) { super("VOID"); @@ -45,7 +54,17 @@ public VoidRelationalResult(MutableList activities, Connectio this.connection = connection; this.statement = connection.createStatement(); long start = System.currentTimeMillis(); - LOGGER.info(new LogInfo(profiles, LoggingEventType.EXECUTION_RELATIONAL_START, sql).toString()); + String nodeSql = ""; + if (node instanceof RelationalExecutionNode) + { + nodeSql = ((RelationalExecutionNode) node).sqlQuery; + } + else if (node instanceof SQLExecutionNode) + { + nodeSql = ((SQLExecutionNode) node).sqlQuery; + } + String logMessage = logSQLWithParamValues ? sql : nodeSql; + LOGGER.info(new LogInfo(profiles, LoggingEventType.EXECUTION_RELATIONAL_START, logMessage).toString()); this.statement.execute(sql); LOGGER.info(new LogInfo(profiles, LoggingEventType.EXECUTION_RELATIONAL_STOP, (double) System.currentTimeMillis() - start).toString()); }