diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java index c81c5749b6..3dc6bf56f2 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/DDLUtils.java @@ -33,13 +33,17 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.conf.HiveConf.ConfVars; import org.apache.hadoop.hive.ql.exec.Utilities; import org.apache.hadoop.hive.ql.hooks.WriteEntity; +import org.apache.hadoop.hive.ql.hooks.Entity.Type; import org.apache.hadoop.hive.ql.metadata.Hive; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.metadata.Partition; import org.apache.hadoop.hive.ql.metadata.Table; import org.apache.hadoop.hive.ql.parse.ReplicationSpec; +import org.apache.hadoop.hive.ql.parse.SemanticException; +import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.hive.serde2.Deserializer; import org.apache.hive.common.util.HiveStringUtils; import org.apache.hive.common.util.ReflectionUtil; @@ -198,4 +202,21 @@ public static void appendNonNull(StringBuilder builder, Object value, boolean fi builder.append(value); } } + + public static void addServiceOutput(HiveConf conf, Set outputs) throws SemanticException { + String hs2Hostname = getHS2Host(conf); + if (hs2Hostname != null) { + outputs.add(new WriteEntity(hs2Hostname, Type.SERVICE_NAME)); + } + } + + private static String getHS2Host(HiveConf conf) throws SemanticException { + if (SessionState.get().isHiveServerQuery()) { + return SessionState.get().getHiveServer2Host(); + } else if (conf.getBoolVar(ConfVars.HIVE_TEST_AUTHORIZATION_SQLSTD_HS2_MODE)) { + return "dummyHostnameForTest"; + } + + throw new SemanticException("Kill query is only supported in HiveServer2 (not hive cli)"); + } } diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsAnalyzer.java new file mode 100644 index 0000000000..21116a8f2b --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsAnalyzer.java @@ -0,0 +1,53 @@ +/* + * 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.ddl.process.abort; + +import java.util.ArrayList; +import java.util.List; + +import org.antlr.runtime.tree.Tree; +import org.apache.hadoop.hive.ql.QueryState; +import org.apache.hadoop.hive.ql.ddl.DDLWork; +import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType; +import org.apache.hadoop.hive.ql.exec.TaskFactory; +import org.apache.hadoop.hive.ql.lib.Node; +import org.apache.hadoop.hive.ql.parse.ASTNode; +import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; +import org.apache.hadoop.hive.ql.parse.HiveParser; +import org.apache.hadoop.hive.ql.parse.SemanticException; + +/** + * Analyzer for abort transactions commands. + */ +@DDLType(type=HiveParser.TOK_ABORT_TRANSACTIONS) +public class AbortTransactionsAnalyzer extends BaseSemanticAnalyzer { + public AbortTransactionsAnalyzer(QueryState queryState) throws SemanticException { + super(queryState); + } + + @Override + public void analyzeInternal(ASTNode root) throws SemanticException { + List transactionIds = new ArrayList(); + for (Node child : root.getChildren()) { + transactionIds.add(Long.parseLong(((Tree)child).getText())); + } + AbortTransactionsDesc desc = new AbortTransactionsDesc(transactionIds); + rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc))); + } +} diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/AbortTransactionsDesc.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsDesc.java similarity index 96% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/AbortTransactionsDesc.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsDesc.java index 12584b9851..20180da745 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/AbortTransactionsDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsDesc.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.abort; import java.io.Serializable; import java.util.List; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/AbortTransactionsOperation.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsOperation.java similarity index 96% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/AbortTransactionsOperation.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsOperation.java index e8815168a2..8a02ba367c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/AbortTransactionsOperation.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/AbortTransactionsOperation.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.abort; import org.apache.hadoop.hive.ql.ddl.DDLOperation; import org.apache.hadoop.hive.ql.ddl.DDLOperationContext; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/package-info.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/package-info.java new file mode 100644 index 0000000000..dc78d2cacf --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/abort/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** Abort Transactions DDL operation. */ +package org.apache.hadoop.hive.ql.ddl.process.abort; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesAnalyzer.java new file mode 100644 index 0000000000..71b1e0478b --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesAnalyzer.java @@ -0,0 +1,57 @@ +/* + * 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.ddl.process.kill; + +import java.util.ArrayList; +import java.util.List; + +import org.antlr.runtime.tree.Tree; +import org.apache.hadoop.hive.ql.QueryState; +import org.apache.hadoop.hive.ql.ddl.DDLUtils; +import org.apache.hadoop.hive.ql.ddl.DDLWork; +import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType; +import org.apache.hadoop.hive.ql.exec.TaskFactory; +import org.apache.hadoop.hive.ql.lib.Node; +import org.apache.hadoop.hive.ql.parse.ASTNode; +import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; +import org.apache.hadoop.hive.ql.parse.HiveParser; +import org.apache.hadoop.hive.ql.parse.SemanticException; + +/** + * Analyzer for kill query commands. + */ +@DDLType(type=HiveParser.TOK_KILL_QUERY) +public class KillQueriesAnalyzer extends BaseSemanticAnalyzer { + public KillQueriesAnalyzer(QueryState queryState) throws SemanticException { + super(queryState); + } + + @Override + public void analyzeInternal(ASTNode root) throws SemanticException { + List queryIds = new ArrayList(); + for (Node child : root.getChildren()) { + queryIds.add(stripQuotes(((Tree)child).getText())); + } + + KillQueriesDesc desc = new KillQueriesDesc(queryIds); + rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc))); + + DDLUtils.addServiceOutput(conf, outputs); + } +} diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/KillQueriesDesc.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesDesc.java similarity index 96% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/KillQueriesDesc.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesDesc.java index 5c6c840ea1..a39e58597f 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/KillQueriesDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesDesc.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.kill; import java.io.Serializable; import java.util.List; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/KillQueriesOperation.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesOperation.java similarity index 96% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/KillQueriesOperation.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesOperation.java index 54d0e292ed..afde1a4762 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/KillQueriesOperation.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/KillQueriesOperation.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.kill; import org.apache.hadoop.hive.ql.ddl.DDLOperation; import org.apache.hadoop.hive.ql.ddl.DDLOperationContext; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/package-info.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/package-info.java new file mode 100644 index 0000000000..3b4d443280 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/kill/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** Kill Queries DDL operation. */ +package org.apache.hadoop.hive.ql.ddl.process.kill; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsAnalyzer.java new file mode 100644 index 0000000000..99b9f5d5b3 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsAnalyzer.java @@ -0,0 +1,50 @@ +/* + * 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.ddl.process.show.compactions; + +import org.apache.hadoop.hive.ql.QueryState; +import org.apache.hadoop.hive.ql.ddl.DDLWork; +import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType; +import org.apache.hadoop.hive.ql.exec.Task; +import org.apache.hadoop.hive.ql.exec.TaskFactory; +import org.apache.hadoop.hive.ql.parse.ASTNode; +import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; +import org.apache.hadoop.hive.ql.parse.HiveParser; +import org.apache.hadoop.hive.ql.parse.SemanticException; + +/** + * Analyzer for show compactions commands. + */ +@DDLType(type=HiveParser.TOK_SHOW_COMPACTIONS) +public class ShowCompactionsAnalyzer extends BaseSemanticAnalyzer { + public ShowCompactionsAnalyzer(QueryState queryState) throws SemanticException { + super(queryState); + } + + @Override + public void analyzeInternal(ASTNode root) throws SemanticException { + ctx.setResFile(ctx.getLocalTmpPath()); + ShowCompactionsDesc desc = new ShowCompactionsDesc(ctx.getResFile()); + Task task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)); + rootTasks.add(task); + + task.setFetchSource(true); + setFetchTask(createFetchTask(ShowCompactionsDesc.SCHEMA)); + } +} diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsDesc.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsDesc.java similarity index 96% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsDesc.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsDesc.java index c8a443095c..9348efc5a1 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsDesc.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.show.compactions; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.ql.ddl.DDLDesc; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsOperation.java similarity index 98% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsOperation.java index b04404d76b..517d88237c 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowCompactionsOperation.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/ShowCompactionsOperation.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.show.compactions; import java.io.DataOutputStream; import java.io.IOException; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/package-info.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/package-info.java new file mode 100644 index 0000000000..0255f77f3a --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/compactions/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** Show Compactions DDL operation. */ +package org.apache.hadoop.hive.ql.ddl.process.show.compactions; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsAnalyzer.java new file mode 100644 index 0000000000..5bb259597f --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsAnalyzer.java @@ -0,0 +1,50 @@ +/* + * 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.ddl.process.show.transactions; + +import org.apache.hadoop.hive.ql.QueryState; +import org.apache.hadoop.hive.ql.ddl.DDLWork; +import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType; +import org.apache.hadoop.hive.ql.exec.Task; +import org.apache.hadoop.hive.ql.exec.TaskFactory; +import org.apache.hadoop.hive.ql.parse.ASTNode; +import org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer; +import org.apache.hadoop.hive.ql.parse.HiveParser; +import org.apache.hadoop.hive.ql.parse.SemanticException; + +/** + * Analyzer for show transactions commands. + */ +@DDLType(type=HiveParser.TOK_SHOW_TRANSACTIONS) +public class ShowTransactionsAnalyzer extends BaseSemanticAnalyzer { + public ShowTransactionsAnalyzer(QueryState queryState) throws SemanticException { + super(queryState); + } + + @Override + public void analyzeInternal(ASTNode root) throws SemanticException { + ctx.setResFile(ctx.getLocalTmpPath()); + ShowTransactionsDesc desc = new ShowTransactionsDesc(ctx.getResFile()); + Task task = TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc)); + rootTasks.add(task); + + task.setFetchSource(true); + setFetchTask(createFetchTask(ShowTransactionsDesc.SCHEMA)); + } +} diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowTransactionsDesc.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsDesc.java similarity index 96% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowTransactionsDesc.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsDesc.java index 486e3cf463..7081ec0d1a 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowTransactionsDesc.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsDesc.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.show.transactions; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hive.ql.ddl.DDLDesc; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowTransactionsOperation.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsOperation.java similarity index 98% rename from ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowTransactionsOperation.java rename to ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsOperation.java index 6f28855fd5..a2468d1452 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/process/ShowTransactionsOperation.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/ShowTransactionsOperation.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.hive.ql.ddl.process; +package org.apache.hadoop.hive.ql.ddl.process.show.transactions; import org.apache.hadoop.hive.ql.ddl.DDLOperationContext; import org.apache.hadoop.hive.ql.ddl.DDLUtils; diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/package-info.java ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/package-info.java new file mode 100644 index 0000000000..27151e8859 --- /dev/null +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/process/show/transactions/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** Show Transactions DDL operation. */ +package org.apache.hadoop.hive.ql.ddl.process.show.transactions; diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java index 2b8a2ba214..80c8032c3b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/DDLSemanticAnalyzer.java @@ -72,10 +72,10 @@ import org.apache.hadoop.hive.ql.ddl.misc.MsckDesc; import org.apache.hadoop.hive.ql.ddl.misc.ShowConfDesc; import org.apache.hadoop.hive.ql.ddl.privilege.PrincipalDesc; -import org.apache.hadoop.hive.ql.ddl.process.AbortTransactionsDesc; -import org.apache.hadoop.hive.ql.ddl.process.KillQueriesDesc; -import org.apache.hadoop.hive.ql.ddl.process.ShowCompactionsDesc; -import org.apache.hadoop.hive.ql.ddl.process.ShowTransactionsDesc; +import org.apache.hadoop.hive.ql.ddl.process.abort.AbortTransactionsDesc; +import org.apache.hadoop.hive.ql.ddl.process.kill.KillQueriesDesc; +import org.apache.hadoop.hive.ql.ddl.process.show.compactions.ShowCompactionsDesc; +import org.apache.hadoop.hive.ql.ddl.process.show.transactions.ShowTransactionsDesc; import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableDesc; import org.apache.hadoop.hive.ql.ddl.table.AlterTableType; import org.apache.hadoop.hive.ql.ddl.table.column.AlterTableAddColumnsDesc; @@ -413,20 +413,6 @@ public void analyzeInternal(ASTNode input) throws SemanticException { ctx.setResFile(ctx.getLocalTmpPath()); analyzeShowDbLocks(ast); break; - case HiveParser.TOK_SHOW_COMPACTIONS: - ctx.setResFile(ctx.getLocalTmpPath()); - analyzeShowCompactions(ast); - break; - case HiveParser.TOK_SHOW_TRANSACTIONS: - ctx.setResFile(ctx.getLocalTmpPath()); - analyzeShowTxns(ast); - break; - case HiveParser.TOK_ABORT_TRANSACTIONS: - analyzeAbortTxns(ast); - break; - case HiveParser.TOK_KILL_QUERY: - analyzeKillQuery(ast); - break; case HiveParser.TOK_SHOWCONF: ctx.setResFile(ctx.getLocalTmpPath()); analyzeShowConf(ast); @@ -2584,59 +2570,6 @@ private void analyzeLockTable(ASTNode ast) ctx.setNeedLockMgr(true); } - /** - * Add a task to execute "SHOW COMPACTIONS" - * @param ast The parsed command tree. - * @throws SemanticException Parsing failed. - */ - private void analyzeShowCompactions(ASTNode ast) throws SemanticException { - ShowCompactionsDesc desc = new ShowCompactionsDesc(ctx.getResFile()); - rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc))); - setFetchTask(createFetchTask(ShowCompactionsDesc.SCHEMA)); - } - - /** - * Add a task to execute "SHOW COMPACTIONS" - * @param ast The parsed command tree. - * @throws SemanticException Parsing failed. - */ - private void analyzeShowTxns(ASTNode ast) throws SemanticException { - ShowTransactionsDesc desc = new ShowTransactionsDesc(ctx.getResFile()); - rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc))); - setFetchTask(createFetchTask(ShowTransactionsDesc.SCHEMA)); - } - - /** - * Add a task to execute "ABORT TRANSACTIONS" - * @param ast The parsed command tree - * @throws SemanticException Parsing failed - */ - private void analyzeAbortTxns(ASTNode ast) throws SemanticException { - List txnids = new ArrayList(); - int numChildren = ast.getChildCount(); - for (int i = 0; i < numChildren; i++) { - txnids.add(Long.parseLong(ast.getChild(i).getText())); - } - AbortTransactionsDesc desc = new AbortTransactionsDesc(txnids); - rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc))); - } - - /** - * Add a task to execute "Kill query" - * @param ast The parsed command tree - * @throws SemanticException Parsing failed - */ - private void analyzeKillQuery(ASTNode ast) throws SemanticException { - List queryIds = new ArrayList(); - int numChildren = ast.getChildCount(); - for (int i = 0; i < numChildren; i++) { - queryIds.add(stripQuotes(ast.getChild(i).getText())); - } - addServiceOutput(); - KillQueriesDesc desc = new KillQueriesDesc(queryIds); - rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), desc))); - } - private void addServiceOutput() throws SemanticException { String hs2Hostname = getHS2Host(); if (hs2Hostname != null) { diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java index f20e49c2d3..4f95c51b55 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzerFactory.java @@ -134,9 +134,6 @@ private static BaseSemanticAnalyzer getInternal(QueryState queryState, ASTNode t case HiveParser.TOK_SHOWPARTITIONS: case HiveParser.TOK_SHOWLOCKS: case HiveParser.TOK_SHOWDBLOCKS: - case HiveParser.TOK_SHOW_COMPACTIONS: - case HiveParser.TOK_SHOW_TRANSACTIONS: - case HiveParser.TOK_ABORT_TRANSACTIONS: case HiveParser.TOK_SHOWCONF: case HiveParser.TOK_SHOWVIEWS: case HiveParser.TOK_SHOWMATERIALIZEDVIEWS: @@ -144,7 +141,6 @@ private static BaseSemanticAnalyzer getInternal(QueryState queryState, ASTNode t case HiveParser.TOK_UNLOCKTABLE: case HiveParser.TOK_TRUNCATETABLE: case HiveParser.TOK_CACHE_METADATA: - case HiveParser.TOK_KILL_QUERY: case HiveParser.TOK_CREATE_RP: case HiveParser.TOK_SHOW_RP: case HiveParser.TOK_ALTER_RP: