You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by lijiang2 <gi...@git.apache.org> on 2018/11/04 03:10:29 UTC
[GitHub] carbondata pull request #2810: [CARBONDATA-3071] Add CarbonSession Java Exam...
Github user lijiang2 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2810#discussion_r230574283
--- Diff: examples/spark2/src/main/java/org/apache/carbondata/examples/sql/CarbonSessionExample.java ---
@@ -0,0 +1,137 @@
+/*
+ * 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.carbondata.examples.sql;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.core.util.CarbonProperties;
+import org.apache.carbondata.examples.util.ExampleUtils;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.spark.sql.SparkSession;
+
+import java.io.File;
+import java.io.IOException;
+
+public class CarbonSessionExample {
+
+ public static void main(String[] args) {
+ File file = new File(CarbonSessionExample.class.getResource("/").getPath() + "../..");
+ try {
+ String rootPath = file.getCanonicalPath();
+ System.setProperty("path.target", rootPath + "/examples/spark2/target");
+ PropertyConfigurator.configure(rootPath + "/examples/spark2/src/main/resources/log4j.properties");
+ CarbonProperties.getInstance().addProperty(CarbonCommonConstants.ENABLE_QUERY_STATISTICS, "true");
+ SparkSession spark = ExampleUtils.createCarbonSession("JavaCarbonSessionExample", 1);
--- End diff --
Thank you for the suggestion. I updated the variable name. And I think I will start the DataFrame example in another pr.
---