Fix session properties for query execution
Apply session properties only to control and test main queries.
Ignore query max run time session property.
@@ -41,6 +41,8 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.function.Consumer;
+import static com.facebook.presto.SystemSessionProperties.QUERY_MAX_EXECUTION_TIME;
+import static com.facebook.presto.SystemSessionProperties.QUERY_MAX_RUN_TIME;
import static com.facebook.presto.sql.SqlFormatter.formatSql;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
@@ -48,8 +50,6 @@ import static java.util.Objects.requireNonNull;
public class JdbcPrestoAction
implements PrestoAction
{
- private static final String QUERY_MAX_EXECUTION_TIME = "query_max_execution_time";
-
private final SqlExceptionClassifier exceptionClassifier;
private final QueryConfiguration queryConfiguration;
@@ -144,10 +144,17 @@ public class JdbcPrestoAction
// Do nothing
}
- Map<String, String> sessionProperties = new HashMap<>(queryConfiguration.getSessionProperties());
+ // configure session properties
+ Map<String, String> sessionProperties = queryStage.isMain()
+ ? new HashMap<>(queryConfiguration.getSessionProperties())
+ : new HashMap<>();
// Add or override query max execution time to enforce the timeout.
sessionProperties.put(QUERY_MAX_EXECUTION_TIME, getTimeout(queryStage).toString());
+
+ // Remove query max run time to respect execution time limit.
+ sessionProperties.remove(QUERY_MAX_RUN_TIME);
+
for (Entry<String, String> entry : sessionProperties.entrySet()) {
connection.setSessionProperty(entry.getKey(), entry.getValue());
}
