[CARBONDATA-3119] Fixing the getOrCreateCarbonSession method parameter to an empty string
Fixing the getOrCreateCarbonSession method parameter to an empty string causes the select table data to be empty
problem: When create carbonSession in this way: [val carbon = SparkSession.builder().config(sc.getConf).getOrCreateCarbonSession("")],The prompt can be created successfully, with no exceptions thrown during the process, but ultimately [carbon.sql("SELECT * FROM TABLE").show()] is empty.
cause: [carbon.sql("SELECT * FROM TABLE").show()] is empty.
solution: Increases the null or empty judgment of getOrCreateCarbonSession method parameters[storePath,metaStorePath]
This closes #2961
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/CarbonSession.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/CarbonSession.scala
index 8e40bf7..af7f3f6 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/CarbonSession.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/CarbonSession.scala
@@ -21,6 +21,7 @@
import scala.collection.JavaConverters._
+import org.apache.commons.lang.StringUtils
import org.apache.hadoop.conf.Configuration
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SparkSession.Builder
@@ -180,7 +181,7 @@
val userSuppliedContext: Option[SparkContext] =
getValue("userSuppliedContext", builder).asInstanceOf[Option[SparkContext]]
- if (metaStorePath != null) {
+ if (StringUtils.isNotBlank(metaStorePath)) {
val hadoopConf = new Configuration()
val configFile = Utils.getContextOrSparkClassLoader.getResource("hive-site.xml")
if (configFile != null) {
@@ -248,7 +249,7 @@
session = new CarbonSession(sparkContext, None, !enableInMemCatlog)
val carbonProperties = CarbonProperties.getInstance()
- if (storePath != null) {
+ if (StringUtils.isNotBlank(storePath)) {
carbonProperties.addProperty(CarbonCommonConstants.STORE_LOCATION, storePath)
// In case if it is in carbon.properties for backward compatible
} else if (carbonProperties.getProperty(CarbonCommonConstants.STORE_LOCATION) == null) {