Skip to content

Commit ca2955b

Browse files
wakunGitHub Enterprise
authored andcommitted
[CARMEL-7531][CARMEL-5095] Add limitation of user sql size (apache#204)
1 parent 1df3358 commit ca2955b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4827,6 +4827,12 @@ object SQLConf {
48274827
.booleanConf
48284828
.createWithDefault(false)
48294829

4830+
val THRIFTSERVER_SQLSIZE_LIMIT =
4831+
buildConf("spark.sql.thriftserver.sqlSize.limit")
4832+
.doc("limitation of thrift server sql size")
4833+
.longConf
4834+
.createWithDefault(Long.MaxValue)
4835+
48304836
val CONTAINS_JOIN_ENABLED = buildConf("spark.sql.planner.containsJoin.enabled")
48314837
.internal()
48324838
.doc(s"When true and '${ADAPTIVE_EXECUTION_ENABLED.key}' is true, " +

sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/server/SparkSQLOperationManager.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.apache.spark.internal.Logging
3030
import org.apache.spark.sql.SQLContext
3131
import org.apache.spark.sql.hive.HiveUtils
3232
import org.apache.spark.sql.hive.thriftserver._
33+
import org.apache.spark.sql.internal.SQLConf
3334

3435
/**
3536
* Executes queries using Spark SQL, and maintains a list of handles to active queries.
@@ -55,6 +56,10 @@ private[thriftserver] class SparkSQLOperationManager()
5556
sqlContext.sparkContext.setLocalProperty(SparkHadoopUtil.HIVE_SESSION_ID,
5657
parentSession.getSessionHandle.getHandleIdentifier.toString)
5758
val conf = sqlContext.sessionState.conf
59+
val sqlSizeLimit = conf.getConf(SQLConf.THRIFTSERVER_SQLSIZE_LIMIT)
60+
require(statement.length < sqlSizeLimit,
61+
s"User query size ${statement.length} exceeds threshold $sqlSizeLimit")
62+
5863
val runInBackground = async && conf.getConf(HiveUtils.HIVE_THRIFT_SERVER_ASYNC)
5964
val operation = new SparkExecuteStatementOperation(
6065
sqlContext, parentSession, statement, confOverlay, runInBackground, queryTimeout)

0 commit comments

Comments
 (0)