Skip to content

Commit

Permalink
[CARBONDATA-3119] Fixing the getOrCreateCarbonSession method paramete…
Browse files Browse the repository at this point in the history
…r 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
  • Loading branch information
zygitup authored and zzcclp committed Nov 30, 2018
1 parent 4554d19 commit 382ce43
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.util.concurrent.atomic.AtomicLong

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
Expand Down Expand Up @@ -180,7 +181,7 @@ object CarbonSession {
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) {
Expand Down Expand Up @@ -248,7 +249,7 @@ object CarbonSession {

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) {
Expand Down

0 comments on commit 382ce43

Please sign in to comment.