Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.hadoop.hive.cli;

import org.apache.hadoop.hive.cli.control.CliAdapter;
import org.apache.hadoop.hive.cli.control.CliConfigs;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.io.File;
import java.util.List;

@RunWith(Parameterized.class)
public class TestExplainCBOFormattedCliDriver {

static CliAdapter adapter = new CliConfigs.TPCDSFormattedCBOConfig().getCliAdapter();

@Parameters(name = "{0}")
public static List<Object[]> getParameters() throws Exception {
return adapter.getParameters();
}

@ClassRule
public static TestRule cliClassRule = adapter.buildClassRule();

@Rule
public TestRule cliTestRule = adapter.buildTestRule();

private final String name;
private final File qfile;

public TestExplainCBOFormattedCliDriver(String name, File qfile) {
this.name = name;
this.qfile = qfile;
}

@Test
public void testCliDriver() throws Exception {
adapter.runTest(name, qfile);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;

import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.QTestMiniClusters;
import org.apache.hadoop.hive.ql.QTestMiniClusters.MiniClusterType;
import org.apache.hadoop.hive.ql.hooks.ExplainFormattedCBOHook;
import org.apache.hadoop.hive.ql.parse.CoreParseNegative;

public class CliConfigs {
Expand Down Expand Up @@ -355,6 +357,25 @@ public TPCDSCteCliConfig() {
}
}

public static class TPCDSFormattedCBOConfig extends AbstractCliConfig {
public TPCDSFormattedCBOConfig() {
super(CorePerfCliDriver.class);
setQueryDir("ql/src/test/queries/clientpositive/perf");
setLogDir("itests/qtest/target/qfile-results/clientpositive/perf/tpcds30tb/json");
setResultsDir("ql/src/test/results/clientpositive/perf/tpcds30tb/json");
setHiveConfDir("data/conf/perf/tpcds30tb/tez");
Map<HiveConf.ConfVars, String> conf = new EnumMap<>(HiveConf.ConfVars.class);
conf.put(HiveConf.ConfVars.HIVE_EXPLAIN_FORMATTED_INDENT, "true");
conf.put(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK, ExplainFormattedCBOHook.class.getCanonicalName());
setCustomConfigValueMap(conf);
setClusterType(MiniClusterType.LLAP_LOCAL);
setMetastoreType("postgres.tpcds");
for (int i = 1; i < 100; i++) {
includeQuery("query" + i + ".q");
}
}
}

public static class NegativeLlapLocalCliConfig extends AbstractCliConfig {
public NegativeLlapLocalCliConfig() {
super(CoreNegativeCliDriver.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public void beforeClass() throws Exception {

qt = new QTestUtil(QTestArguments.QTestArgumentsBuilder.instance().withOutDir(cliConfig.getResultsDir())
.withLogDir(cliConfig.getLogDir()).withClusterType(miniMR).withConfDir(hiveConfDir).withInitScript(initScript)
.withCleanupScript(cleanupScript).withLlapIo(false).build());
.withCleanupScript(cleanupScript).withLlapIo(false)
.withCustomConfigValueMap(cliConfig.getCustomConfigValueMap())
.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.hadoop.hive.ql.hooks;

import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTBuilder;
import org.apache.hadoop.hive.ql.parse.ASTNode;
import org.apache.hadoop.hive.ql.parse.AbstractSemanticAnalyzerHook;
import org.apache.hadoop.hive.ql.parse.HiveParser;
import org.apache.hadoop.hive.ql.parse.HiveSemanticAnalyzerHookContext;

/**
* An analyzer hook for transforming plain EXPLAIN statements to EXPLAIN FORMATTED CBO.
*/
public class ExplainFormattedCBOHook extends AbstractSemanticAnalyzerHook {
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast) {
if (ast.getType() == HiveParser.TOK_EXPLAIN) {
ast.addChild(ASTBuilder.createAST(HiveParser.KW_FORMATTED, "formatted"));
ast.addChild(ASTBuilder.createAST(HiveParser.KW_CBO, "cbo"));
}
return ast;
}
}
Loading