Skip to content

Commit

Permalink
Flag for sql logging in VoidRelationalResult - used for temp table (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishoya-gs authored Sep 23, 2023
1 parent ed8db6a commit fe4700f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public Result execute(RelationalExecutionNode node, MutableList<CommonProfile> p
}
else if (node.isResultVoid())
{
return new VoidRelationalResult(executionState.activities, connectionManagerConnection, profiles);
return new VoidRelationalResult(executionState.activities, node, connectionManagerConnection, profiles, executionState.logSQLWithParamValues());
}
else
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -241,7 +241,7 @@ public Result execute(SQLExecutionNode node, MutableList<CommonProfile> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -35,7 +38,13 @@ public class VoidRelationalResult extends Result
private Connection connection;
private Statement statement;

@Deprecated
public VoidRelationalResult(MutableList<ExecutionActivity> activities, Connection connection, MutableList<CommonProfile> profiles)
{
this(activities, null, connection, profiles, true);
}

public VoidRelationalResult(MutableList<ExecutionActivity> activities, ExecutionNode node, Connection connection, MutableList<CommonProfile> profiles, boolean logSQLWithParamValues)
{
super("VOID");

Expand All @@ -45,7 +54,17 @@ public VoidRelationalResult(MutableList<ExecutionActivity> 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());
}
Expand Down

0 comments on commit fe4700f

Please sign in to comment.