You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2021/12/09 10:26:50 UTC
[GitHub] [kylin] fengpod opened a new pull request #1780: hive global dict replace with spark
fengpod opened a new pull request #1780:
URL: https://github.com/apache/kylin/pull/1780
use spark engine in build-hive-global-dict-replace-intermediate-table step
## Proposed changes
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
## Github Branch
As most of the development works are on Kylin 4, we need to switch it as main branch. Apache Kylin community changes the branch settings on Github since 2021-08-04 :
1. The original branch _kylin-on-parquet-v2_ for **Kylin 4.X** (Parquet Storage) has been renamed to branch **main**, and configured as the **default** branch;
2. The original branch _master_ for **Kylin 3.X** (HBase Storage) has been renamed to branch **kylin3** ;
Please check [Intro to Kylin 4 architecture](https://kylin.apache.org/blog/2021/07/02/Apache-Kylin4-A-new-storage-and-compute-architecture/) and [INFRA-22166](https://issues.apache.org/jira/browse/INFRA-22166) if you are interested.
## Types of changes
What types of changes does your code introduce to Kylin?
_Put an `x` in the boxes that apply_
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation Update (if none of the other choices apply)
## Checklist
_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
- [ ] I have create an issue on [Kylin's jira](https://issues.apache.org/jira/browse/KYLIN), and have described the bug/feature there in detail
- [ ] Commit messages in my PR start with the related jira ID, like "KYLIN-0000 Make Kylin project open-source"
- [ ] Compiling and unit tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation (if appropriate)
- [ ] Any dependent changes have been merged
## Further comments
If this is a relatively large or complex change, kick off the discussion at user@kylin or dev@kylin by explaining why you chose the solution you did and what alternatives you considered, etc...
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] zhangayqian commented on a change in pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
zhangayqian commented on a change in pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#discussion_r784476015
##########
File path: source-hive/src/main/java/org/apache/kylin/source/hive/SparkHiveDictReplaceStep.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.kylin.source.hive;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.AbstractApplication;
+import org.apache.kylin.common.util.OptionsHelper;
+import org.apache.kylin.cube.CubeInstance;
+import org.apache.kylin.cube.CubeManager;
+import org.apache.kylin.cube.CubeSegment;
+import org.apache.kylin.engine.EngineFactory;
+import org.apache.kylin.engine.mr.common.AbstractHadoopJob;
+import org.apache.kylin.engine.mr.common.BatchConstants;
+import org.apache.kylin.engine.mr.common.SerializableConfiguration;
+import org.apache.kylin.metadata.model.IJoinedFlatTableDesc;
+import org.apache.spark.sql.SparkSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Map;
+
+public class SparkHiveDictReplaceStep extends AbstractApplication implements Serializable {
+
+ private static final Logger logger = LoggerFactory.getLogger(SparkHiveDictReplaceStep.class);
+
+ public static final Option OPTION_CUBE_NAME = OptionBuilder.withArgName(BatchConstants.ARG_CUBE_NAME).hasArg().isRequired(true).withDescription("Cube Name").create(BatchConstants.ARG_CUBE_NAME);
+ public static final Option OPTION_META_URL = OptionBuilder.withArgName("metaUrl").hasArg().isRequired(true).withDescription("Meta Url").create("metaUrl");
+ public static final Option OPTION_SEGMENT_ID = OptionBuilder.withArgName("segmentId").hasArg().isRequired(true).withDescription("Segment Id").create("segmentId");
+ public static final Option OPTION_FLOW_JOB_ID = OptionBuilder.withArgName("flowJobId").hasArg().isRequired(true).withDescription("Flow Job Id").create("flowJobId");
+ public static final Option OPTION_WAREHOUSE_DIR = OptionBuilder.withArgName("wareHouseDir").hasArg().isRequired(true).withDescription("WareHouse Dir").create("wareHouseDir");
+ public static final Option OPTION_DICT_COLUMNS = OptionBuilder.withArgName("dictColumns").hasArg().isRequired(true).withDescription("Dict Columns").create("dictColumns");
+ public static final Option OPTION_GLOBAL_DICT_TABLE = OptionBuilder.withArgName("globalDictTable").hasArg().isRequired(true).withDescription("Global Dict Table").create("globalDictTable");
+ public static final Option OPTION_DICT_SUFFIX = OptionBuilder.withArgName("dictSuffix").hasArg().isRequired(true).withDescription("Dict Suffix").create("dictSuffix");
+
+ private String cubeName;
+ private String segmentId;
+ private String metaUrl;
+ private String wareHouseDir;
+ private String dictColumns;
+ private String globalDictTable;
+ private String dictSuffix;
+ private String flowJobId;
+
+ private Options options;
+
+ public SparkHiveDictReplaceStep() {
+ options = new Options();
+ options.addOption(OPTION_CUBE_NAME);
+ options.addOption(OPTION_DICT_COLUMNS);
+ options.addOption(OPTION_META_URL);
+ options.addOption(OPTION_SEGMENT_ID);
+ options.addOption(OPTION_FLOW_JOB_ID);
+ options.addOption(OPTION_WAREHOUSE_DIR);
+ options.addOption(OPTION_GLOBAL_DICT_TABLE);
+ options.addOption(OPTION_DICT_SUFFIX);
+ }
+
+ @Override
+ protected Options getOptions() {
+ return options;
+ }
+
+ @Override
+ protected void execute(OptionsHelper optionsHelper) throws Exception {
+ initParam(optionsHelper);
+
+ try {
+ SparkSession spark = SparkSession.builder().appName("Spark Hive Global Dict").master("yarn").config("spark.sql.warehouse.dir", wareHouseDir).enableHiveSupport().getOrCreate();
+
+ SerializableConfiguration sConf = new SerializableConfiguration(spark.sparkContext().hadoopConfiguration());
+ KylinConfig envConfig = AbstractHadoopJob.loadKylinConfigFromHdfs(sConf, metaUrl);
+
+ CubeInstance cubeInstance = CubeManager.getInstance(envConfig).getCube(cubeName);
+ CubeSegment seg = cubeInstance.getSegmentById(segmentId);
+ IJoinedFlatTableDesc flatDesc = EngineFactory.getJoinedFlatTableDesc(seg);
+
+ Map<String, String> dictRef = seg.getConfig().getMrHiveDictRefColumns();
+ for (String dictColumn : dictColumns.split(",")) {
+ dictRef.put(dictColumn, "");
+ }
+
+ Map<String, String> replaceSqlMap = MRHiveDictUtil.generateReplaceSql(flatDesc, dictRef, seg.getConfig().getHiveDatabaseForIntermediateTable(), seg.getConfig().getMrHiveDictDB(), globalDictTable, dictSuffix);
+ for (Map.Entry<String, String> entry : replaceSqlMap.entrySet()) {
+ logger.info("field:" + entry.getKey() + ":\n" + entry.getValue());
+ String replaceSql = entry.getValue();
+ replaceSql = replaceSql.substring(0, replaceSql.lastIndexOf(";"));
+ spark.sql(replaceSql);
+ }
+ } catch (Exception e) {
+ logger.error("", e);
Review comment:
Please improve this error reporting information.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] codecov-commenter commented on pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#issuecomment-989795370
# [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> :exclamation: No coverage uploaded for pull request base (`kylin3@a247fd9`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#section-missing-base-commit).
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## kylin3 #1780 +/- ##
=========================================
Coverage ? 25.11%
Complexity ? 6791
=========================================
Files ? 1520
Lines ? 95380
Branches ? 13317
=========================================
Hits ? 23953
Misses ? 69038
Partials ? 2389
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a247fd9...3b1dc92](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] codecov-commenter edited a comment on pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#issuecomment-989795370
# [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> :exclamation: No coverage uploaded for pull request base (`kylin3@a247fd9`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#section-missing-base-commit).
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## kylin3 #1780 +/- ##
=========================================
Coverage ? 25.12%
Complexity ? 6793
=========================================
Files ? 1520
Lines ? 95380
Branches ? 13317
=========================================
Hits ? 23965
Misses ? 69029
Partials ? 2386
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a247fd9...3b1dc92](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] codecov-commenter edited a comment on pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#issuecomment-989795370
# [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> :exclamation: No coverage uploaded for pull request base (`kylin3@694d94b`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#section-missing-base-commit).
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## kylin3 #1780 +/- ##
=========================================
Coverage ? 25.10%
Complexity ? 6790
=========================================
Files ? 1520
Lines ? 95399
Branches ? 13319
=========================================
Hits ? 23947
Misses ? 69060
Partials ? 2392
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [694d94b...7c32c0b](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] codecov-commenter edited a comment on pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#issuecomment-989795370
# [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> :exclamation: No coverage uploaded for pull request base (`kylin3@694d94b`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#section-missing-base-commit).
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## kylin3 #1780 +/- ##
=========================================
Coverage ? 25.11%
Complexity ? 6793
=========================================
Files ? 1520
Lines ? 95399
Branches ? 13319
=========================================
Hits ? 23963
Misses ? 69049
Partials ? 2387
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [694d94b...7c32c0b](https://codecov.io/gh/apache/kylin/pull/1780?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] zhangayqian commented on a change in pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
zhangayqian commented on a change in pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#discussion_r784476015
##########
File path: source-hive/src/main/java/org/apache/kylin/source/hive/SparkHiveDictReplaceStep.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.kylin.source.hive;
+
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.AbstractApplication;
+import org.apache.kylin.common.util.OptionsHelper;
+import org.apache.kylin.cube.CubeInstance;
+import org.apache.kylin.cube.CubeManager;
+import org.apache.kylin.cube.CubeSegment;
+import org.apache.kylin.engine.EngineFactory;
+import org.apache.kylin.engine.mr.common.AbstractHadoopJob;
+import org.apache.kylin.engine.mr.common.BatchConstants;
+import org.apache.kylin.engine.mr.common.SerializableConfiguration;
+import org.apache.kylin.metadata.model.IJoinedFlatTableDesc;
+import org.apache.spark.sql.SparkSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.Map;
+
+public class SparkHiveDictReplaceStep extends AbstractApplication implements Serializable {
+
+ private static final Logger logger = LoggerFactory.getLogger(SparkHiveDictReplaceStep.class);
+
+ public static final Option OPTION_CUBE_NAME = OptionBuilder.withArgName(BatchConstants.ARG_CUBE_NAME).hasArg().isRequired(true).withDescription("Cube Name").create(BatchConstants.ARG_CUBE_NAME);
+ public static final Option OPTION_META_URL = OptionBuilder.withArgName("metaUrl").hasArg().isRequired(true).withDescription("Meta Url").create("metaUrl");
+ public static final Option OPTION_SEGMENT_ID = OptionBuilder.withArgName("segmentId").hasArg().isRequired(true).withDescription("Segment Id").create("segmentId");
+ public static final Option OPTION_FLOW_JOB_ID = OptionBuilder.withArgName("flowJobId").hasArg().isRequired(true).withDescription("Flow Job Id").create("flowJobId");
+ public static final Option OPTION_WAREHOUSE_DIR = OptionBuilder.withArgName("wareHouseDir").hasArg().isRequired(true).withDescription("WareHouse Dir").create("wareHouseDir");
+ public static final Option OPTION_DICT_COLUMNS = OptionBuilder.withArgName("dictColumns").hasArg().isRequired(true).withDescription("Dict Columns").create("dictColumns");
+ public static final Option OPTION_GLOBAL_DICT_TABLE = OptionBuilder.withArgName("globalDictTable").hasArg().isRequired(true).withDescription("Global Dict Table").create("globalDictTable");
+ public static final Option OPTION_DICT_SUFFIX = OptionBuilder.withArgName("dictSuffix").hasArg().isRequired(true).withDescription("Dict Suffix").create("dictSuffix");
+
+ private String cubeName;
+ private String segmentId;
+ private String metaUrl;
+ private String wareHouseDir;
+ private String dictColumns;
+ private String globalDictTable;
+ private String dictSuffix;
+ private String flowJobId;
+
+ private Options options;
+
+ public SparkHiveDictReplaceStep() {
+ options = new Options();
+ options.addOption(OPTION_CUBE_NAME);
+ options.addOption(OPTION_DICT_COLUMNS);
+ options.addOption(OPTION_META_URL);
+ options.addOption(OPTION_SEGMENT_ID);
+ options.addOption(OPTION_FLOW_JOB_ID);
+ options.addOption(OPTION_WAREHOUSE_DIR);
+ options.addOption(OPTION_GLOBAL_DICT_TABLE);
+ options.addOption(OPTION_DICT_SUFFIX);
+ }
+
+ @Override
+ protected Options getOptions() {
+ return options;
+ }
+
+ @Override
+ protected void execute(OptionsHelper optionsHelper) throws Exception {
+ initParam(optionsHelper);
+
+ try {
+ SparkSession spark = SparkSession.builder().appName("Spark Hive Global Dict").master("yarn").config("spark.sql.warehouse.dir", wareHouseDir).enableHiveSupport().getOrCreate();
+
+ SerializableConfiguration sConf = new SerializableConfiguration(spark.sparkContext().hadoopConfiguration());
+ KylinConfig envConfig = AbstractHadoopJob.loadKylinConfigFromHdfs(sConf, metaUrl);
+
+ CubeInstance cubeInstance = CubeManager.getInstance(envConfig).getCube(cubeName);
+ CubeSegment seg = cubeInstance.getSegmentById(segmentId);
+ IJoinedFlatTableDesc flatDesc = EngineFactory.getJoinedFlatTableDesc(seg);
+
+ Map<String, String> dictRef = seg.getConfig().getMrHiveDictRefColumns();
+ for (String dictColumn : dictColumns.split(",")) {
+ dictRef.put(dictColumn, "");
+ }
+
+ Map<String, String> replaceSqlMap = MRHiveDictUtil.generateReplaceSql(flatDesc, dictRef, seg.getConfig().getHiveDatabaseForIntermediateTable(), seg.getConfig().getMrHiveDictDB(), globalDictTable, dictSuffix);
+ for (Map.Entry<String, String> entry : replaceSqlMap.entrySet()) {
+ logger.info("field:" + entry.getKey() + ":\n" + entry.getValue());
+ String replaceSql = entry.getValue();
+ replaceSql = replaceSql.substring(0, replaceSql.lastIndexOf(";"));
+ spark.sql(replaceSql);
+ }
+ } catch (Exception e) {
+ logger.error("", e);
Review comment:
Please improve this error reporting information.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kylin] zhangayqian commented on pull request #1780: KYLIN-5141 hive global dict replace with spark
Posted by GitBox <gi...@apache.org>.
zhangayqian commented on pull request #1780:
URL: https://github.com/apache/kylin/pull/1780#issuecomment-1012796343
Hi @fengpod
Similar to https://github.com/apache/kylin/pull/1778, after building a global dictionary, the dictionary lock is not purged, resulting in the failure to obtain the lock when building the next segment of the same cube.

--
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.
To unsubscribe, e-mail: issues-unsubscribe@kylin.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org