[
https://issues.apache.org/jira/browse/KYLIN-4829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17245838#comment-17245838
]
ASF GitHub Bot commented on KYLIN-4829:
---------------------------------------
hit-lacus commented on a change in pull request #1495:
URL: https://github.com/apache/kylin/pull/1495#discussion_r538274411
##########
File path:
kylin-spark-project/kylin-spark-query/src/test/java/org/apache/spark/sql/SparderContextFacadeTest.java
##########
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql;
+
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.engine.spark.LocalWithSparkSessionTest;
+import org.apache.kylin.job.exception.SchedulerException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SparderContextFacadeTest extends LocalWithSparkSessionTest {
+
+ private static final Logger logger =
LoggerFactory.getLogger(SparderContextFacadeTest.class);
+ private static final Integer TEST_SIZE = 16 * 1024 * 1024;
+
+ @Override
+ @Before
+ public void setup() throws SchedulerException {
+ super.setup();
+ KylinConfig conf = KylinConfig.getInstanceFromEnv();
+ // the default value of kylin.query.spark-conf.spark.master is yarn,
+ // which will read from kylin-defaults.properties
+ conf.setProperty("kylin.query.spark-conf.spark.master", "local");
+ // Init Sparder
+ SparderContext.getOriginalSparkSession();
+ }
+
+ @After
+ public void after() {
+ SparderContext.stopSpark();
+ KylinConfig.getInstanceFromEnv()
+ .setProperty("kylin.query.spark-conf.spark.master", "yarn");
+ super.after();
+ }
+
+ @Test
+ public void testThreadSparkSession() throws InterruptedException,
ExecutionException {
+ ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 1,
+ TimeUnit.DAYS, new LinkedBlockingQueue<>(5));
+
+ // test the thread local SparkSession
+ CompletionService<Throwable> service =
runThreadSparkSessionTest(executor, false);
+
+ for (int i = 1; i <= 5; i++) {
+ Assert.assertNull(service.take().get());
+ }
+
+ // test the original SparkSession, it must throw errors.
+ service = runThreadSparkSessionTest(executor, true);
+ boolean hasError = false;
+ for (int i = 1; i <= 5; i++) {
+ if (service.take().get() != null) {
+ hasError = true;
+ }
+ }
+ Assert.assertTrue(hasError);
+
+ executor.shutdown();
+ }
+
+ protected CompletionService<Throwable>
runThreadSparkSessionTest(ThreadPoolExecutor executor,
Review comment:
Looks like `isOriginal` is always `false` ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Support to use thread-level SparkSession to execute query
> ----------------------------------------------------------
>
> Key: KYLIN-4829
> URL: https://issues.apache.org/jira/browse/KYLIN-4829
> Project: Kylin
> Issue Type: Improvement
> Components: Query Engine, Spark Engine
> Reporter: Zhichao Zhang
> Assignee: Zhichao Zhang
> Priority: Minor
> Fix For: v4.0.0-beta
>
>
> Currently, when executing a query, it is impossible to configure proper
> parameters for each query according to the data will be scanned, such as
> spark.sql.shuffle.partitions, this will impact the performance of querying.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)