You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2015/07/20 13:43:56 UTC
[7/8] tajo git commit: TAJO-1670: Refactor client errors and
exceptions.
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicatePartitionException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicatePartitionException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicatePartitionException.java
new file mode 100644
index 0000000..bdec4fc
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicatePartitionException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.tajo.catalog.exception;
+
+import org.apache.tajo.error.Errors;
+
+public class DuplicatePartitionException extends CatalogException {
+ private static final long serialVersionUID = 277182608283894930L;
+
+ public DuplicatePartitionException(String partitionName) {
+ super(Errors.ResultCode.DUPLICATE_PARTITION, partitionName);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTableException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTableException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTableException.java
new file mode 100644
index 0000000..74fa39f
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTableException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.tajo.catalog.exception;
+
+
+import org.apache.tajo.error.Errors;
+
+public class DuplicateTableException extends CatalogException {
+ private static final long serialVersionUID = -641623770742392865L;
+
+ public DuplicateTableException(String relName) {
+ super(Errors.ResultCode.DUPLICATE_TABLE, relName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTablespaceException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTablespaceException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTablespaceException.java
new file mode 100644
index 0000000..2e03e3c
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/DuplicateTablespaceException.java
@@ -0,0 +1,28 @@
+/**
+ * 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.tajo.catalog.exception;
+
+
+import org.apache.tajo.error.Errors;
+
+public class DuplicateTablespaceException extends CatalogException {
+ public DuplicateTablespaceException(String spaceName) {
+ super(Errors.ResultCode.DUPLICATE_TABLESPACE, spaceName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/InvalidNameException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/InvalidNameException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/InvalidNameException.java
new file mode 100644
index 0000000..1692777
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/InvalidNameException.java
@@ -0,0 +1,29 @@
+/*
+ * Lisensed 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.tajo.catalog.exception;
+
+
+import org.apache.tajo.error.Errors;
+
+public class InvalidNameException extends CatalogException {
+
+ public InvalidNameException(String databaseName) {
+ super(Errors.ResultCode.INVALID_NAME, databaseName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/MetadataConnectionException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/MetadataConnectionException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/MetadataConnectionException.java
new file mode 100644
index 0000000..e155bf1
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/MetadataConnectionException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.tajo.catalog.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.exception.TajoError;
+
+/**
+ * Tajo Metadata Connector's connection error
+ */
+public class MetadataConnectionException extends TajoError {
+
+ public MetadataConnectionException(String uri, Throwable t) {
+ super(ResultCode.CAT_CANNOT_CONNECT, t, uri, t.getMessage());
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoPartitionedTableException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoPartitionedTableException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoPartitionedTableException.java
index eded789..e81f526 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoPartitionedTableException.java
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoPartitionedTableException.java
@@ -20,8 +20,6 @@ package org.apache.tajo.catalog.exception;
public class NoPartitionedTableException extends Exception {
- public NoPartitionedTableException() {}
-
public NoPartitionedTableException(String databaseName, String relName) {
super(String.format("ERROR: table \"%s.%s\" is not a partitioned table", databaseName, relName));
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchColumnException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchColumnException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchColumnException.java
deleted file mode 100644
index 4af3f70..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchColumnException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.tajo.catalog.exception;
-
-
-public class NoSuchColumnException extends CatalogException {
- private static final long serialVersionUID = 277182608283894937L;
-
- public NoSuchColumnException() {}
-
- public NoSuchColumnException(String databaseName, String relName, String columnName) {
- super(String.format("ERROR: column \" %s.%s \" in %s does not exist", relName, columnName, databaseName));
- }
-
- public NoSuchColumnException(String columnName) {
- super("ERROR: column \"" + columnName + "\" does not exist");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchDatabaseException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchDatabaseException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchDatabaseException.java
deleted file mode 100644
index 757cad5..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchDatabaseException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.tajo.catalog.exception;
-
-
-public class NoSuchDatabaseException extends CatalogException {
- private static final long serialVersionUID = 277182608283894937L;
-
- public NoSuchDatabaseException() {}
-
- public NoSuchDatabaseException(String databaseName) {
- super("ERROR: database \"" + databaseName + "\" does not exist");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchFunctionException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchFunctionException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchFunctionException.java
deleted file mode 100644
index e91e41d..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchFunctionException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.tajo.catalog.exception;
-
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.function.FunctionUtil;
-
-import java.util.Collection;
-
-public class NoSuchFunctionException extends RuntimeException {
- private static final long serialVersionUID = 5062193018697228028L;
-
- public NoSuchFunctionException(String message) {
- super(message);
- }
-
- public NoSuchFunctionException(String funcName, TajoDataTypes.DataType [] parameters) {
- super("function " + FunctionUtil.buildSimpleFunctionSignature(funcName, parameters) + " does not exist");
- }
-
- public NoSuchFunctionException(String funcName, Collection<TajoDataTypes.DataType> parameters) {
- super("function " + FunctionUtil.buildSimpleFunctionSignature(funcName, parameters) + " does not exist");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchIndexException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchIndexException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchIndexException.java
deleted file mode 100644
index 0bb7e32..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchIndexException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.tajo.catalog.exception;
-
-public class NoSuchIndexException extends CatalogException {
- private static final long serialVersionUID = 3705839985189534673L;
-
- public NoSuchIndexException() {
- }
-
- public NoSuchIndexException(String databaseName, String columnName) {
- super(String.format("ERROR: index \" %s \" in %s does not exist", columnName, databaseName));
- }
-
- public NoSuchIndexException(String indexName) {
- super("ERROR: index \"" + indexName + "\" does not exist");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTableException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTableException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTableException.java
deleted file mode 100644
index cc11444..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTableException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.tajo.catalog.exception;
-
-
-public class NoSuchTableException extends CatalogException {
- private static final long serialVersionUID = 277182608283894937L;
-
- public NoSuchTableException() {}
-
- public NoSuchTableException(String databaseName, String relName) {
- super(String.format("ERROR: relation \" %s \" in %s does not exist", relName, databaseName));
- }
-
- public NoSuchTableException(String relName) {
- super("ERROR: relation \"" + relName + "\" does not exist");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTablespaceException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTablespaceException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTablespaceException.java
deleted file mode 100644
index 8b7d80b..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/NoSuchTablespaceException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.tajo.catalog.exception;
-
-public class NoSuchTablespaceException extends CatalogException {
- private static final long serialVersionUID = 277182608283894937L;
-
- public NoSuchTablespaceException() {}
-
- public NoSuchTablespaceException(String spaceName) {
- super("ERROR: tablespace \"" + spaceName + "\" does not exist");
- }
-}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedColumnException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedColumnException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedColumnException.java
new file mode 100644
index 0000000..43b7410
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedColumnException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.tajo.catalog.exception;
+
+
+import org.apache.tajo.error.Errors.ResultCode;
+
+public class UndefinedColumnException extends CatalogException {
+ private static final long serialVersionUID = 277182608283894937L;
+
+ public UndefinedColumnException(String columnName) {
+ super(ResultCode.UNDEFINED_COLUMN, columnName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedDatabaseException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedDatabaseException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedDatabaseException.java
new file mode 100644
index 0000000..8294add
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedDatabaseException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.tajo.catalog.exception;
+
+
+import org.apache.tajo.error.Errors;
+
+public class UndefinedDatabaseException extends CatalogException {
+ private static final long serialVersionUID = 277182608283894937L;
+
+ public UndefinedDatabaseException(String dbName) {
+ super(Errors.ResultCode.UNDEFINED_DATABASE, dbName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedFunctionException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedFunctionException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedFunctionException.java
new file mode 100644
index 0000000..175b597
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedFunctionException.java
@@ -0,0 +1,44 @@
+/**
+ * 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.tajo.catalog.exception;
+
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.error.Errors;
+import org.apache.tajo.error.Errors.ResultCode;
+import org.apache.tajo.exception.TajoException;
+import org.apache.tajo.exception.TajoRuntimeException;
+import org.apache.tajo.function.FunctionUtil;
+
+import java.util.Collection;
+
+public class UndefinedFunctionException extends CatalogException {
+ private static final long serialVersionUID = 5062193018697228028L;
+
+ public UndefinedFunctionException(String signature) {
+ super(ResultCode.UNDEFINED_FUNCTION, signature);
+ }
+
+ public UndefinedFunctionException(String funcName, TajoDataTypes.DataType[] parameters) {
+ super(ResultCode.UNDEFINED_FUNCTION, FunctionUtil.buildSimpleFunctionSignature(funcName, parameters));
+ }
+
+ public UndefinedFunctionException(String funcName, Collection<TajoDataTypes.DataType> parameters) {
+ super(ResultCode.UNDEFINED_FUNCTION, FunctionUtil.buildSimpleFunctionSignature(funcName, parameters));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedIndexException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedIndexException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedIndexException.java
new file mode 100644
index 0000000..d228a40
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedIndexException.java
@@ -0,0 +1,33 @@
+/**
+ * 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.tajo.catalog.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+
+public class UndefinedIndexException extends CatalogException {
+ private static final long serialVersionUID = 3705839985189534673L;
+
+ public UndefinedIndexException(String tableName, String columnName) {
+ super(ResultCode.UNDEFINED_INDEX, tableName, columnName);
+ }
+
+ public UndefinedIndexException(String indexName) {
+ super(ResultCode.UNDEFINED_INDEX_NAME, indexName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedPartitionException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedPartitionException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedPartitionException.java
new file mode 100644
index 0000000..282f0a2
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedPartitionException.java
@@ -0,0 +1,30 @@
+/**
+ * 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.tajo.catalog.exception;
+
+import org.apache.tajo.error.Errors.ResultCode;
+
+public class UndefinedPartitionException extends CatalogException {
+
+ private static final long serialVersionUID = 277182608283894938L;
+
+ public UndefinedPartitionException(String partitionName) {
+ super(ResultCode.UNDEFINED_PARTITION, partitionName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTableException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTableException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTableException.java
new file mode 100644
index 0000000..2513783
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTableException.java
@@ -0,0 +1,35 @@
+/**
+ * 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.tajo.catalog.exception;
+
+
+import org.apache.tajo.catalog.CatalogUtil;
+import org.apache.tajo.error.Errors.ResultCode;
+
+public class UndefinedTableException extends CatalogException {
+ private static final long serialVersionUID = 277182608283894937L;
+
+ public UndefinedTableException(String dbName, String tbName) {
+ super(ResultCode.UNDEFINED_TABLE, CatalogUtil.buildFQName(dbName, tbName));
+ }
+
+ public UndefinedTableException(String relName) {
+ super(ResultCode.UNDEFINED_TABLE, relName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTablespaceException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTablespaceException.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTablespaceException.java
new file mode 100644
index 0000000..ffe5789
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/exception/UndefinedTablespaceException.java
@@ -0,0 +1,29 @@
+/**
+ * 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.tajo.catalog.exception;
+
+import org.apache.tajo.error.Errors;
+
+public class UndefinedTablespaceException extends CatalogException {
+ private static final long serialVersionUID = 277182608283894937L;
+
+ public UndefinedTablespaceException(String spaceName) {
+ super(Errors.ResultCode.UNDEFINED_TABLESPACE, spaceName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto b/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
index b213916..d0cf238 100644
--- a/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
+++ b/tajo-catalog/tajo-catalog-common/src/main/proto/CatalogProtos.proto
@@ -133,42 +133,10 @@ enum IndexMethod {
BITMAP_IDX = 3;
}
-message GetAllTableNamesResponse {
- repeated string tableName = 1;
-}
-
-message GetTablespacesProto {
- repeated TablespaceProto tablespace = 1;
-}
-
-message GetDatabasesProto {
- repeated DatabaseProto database = 1;
-}
-
-message GetTablesProto {
- repeated TableDescriptorProto table = 1;
-}
-
-message GetColumnsProto {
- repeated ColumnProto column = 1;
-}
-
message GetIndexesProto {
repeated IndexProto index = 1;
}
-message GetTableOptionsProto {
- repeated TableOptionProto tableOption = 1;
-}
-
-message GetTableStatsProto {
- repeated TableStatsProto stat = 1;
-}
-
-message GetTablePartitionsProto {
- repeated TablePartitionProto part = 1;
-}
-
message IndexProto {
required int32 dbId = 1;
required int32 tId = 2;
@@ -281,11 +249,6 @@ message SortSpecProto {
optional bool nullFirst = 3 [default = false];
}
-
-message PartitionsProto {
- repeated PartitionDescProto partition = 1;
-}
-
message PartitionMethodProto {
required TableIdentifierProto tableIdentifier = 1;
required PartitionType partitionType = 2;
@@ -304,7 +267,6 @@ message PartitionKeyProto {
required string partitionValue = 2;
}
-
message PartitionIdentifierProto {
required string databaseName = 1;
required string tableName = 2;
@@ -319,9 +281,9 @@ message TablespaceProto {
}
message DatabaseProto {
- required int32 spaceId = 1;
- required int32 id = 2;
- required string name = 3;
+ required int32 spaceId = 1;
+ required int32 id = 2;
+ required string name = 3;
}
message TableDescriptorProto {
@@ -430,3 +392,18 @@ message PythonInvocationDescProto {
required string filePath = 2;
required bool isScalarFunction = 3;
}
+
+message TableResponse {
+ required ReturnState state = 1;
+ optional TableDescProto table = 2;
+}
+
+message FunctionResponse {
+ required ReturnState state = 1;
+ optional FunctionDescProto function = 2;
+}
+
+message FunctionListResponse {
+ required ReturnState state = 1;
+ repeated FunctionDescProto function = 2;
+}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
index edd0f3e..cf1a24a 100644
--- a/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
+++ b/tajo-catalog/tajo-catalog-common/src/test/java/org/apache/tajo/catalog/TestSchema.java
@@ -18,7 +18,7 @@
package org.apache.tajo.catalog;
-import org.apache.tajo.catalog.exception.AlreadyExistsFieldException;
+import org.apache.tajo.catalog.exception.DuplicateColumnException;
import org.apache.tajo.catalog.json.CatalogGsonHelper;
import org.apache.tajo.catalog.proto.CatalogProtos.SchemaProto;
import org.apache.tajo.common.TajoDataTypes.Type;
@@ -191,7 +191,7 @@ public class TestSchema {
assertEquals(schema.size(), schema3.size());
}
- @Test(expected = AlreadyExistsFieldException.class)
+ @Test(expected = DuplicateColumnException.class)
public final void testAddExistColumn() {
Schema schema = new Schema();
schema.addColumn("abc", Type.FLOAT8);
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java b/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
index 8f23db4..daba8ba 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogStore.java
@@ -49,9 +49,10 @@ import org.apache.tajo.catalog.proto.CatalogProtos.TableStatsProto;
import org.apache.tajo.catalog.proto.CatalogProtos.TablespaceProto;
import org.apache.tajo.catalog.statistics.TableStats;
import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.common.exception.NotImplementedException;
import org.apache.tajo.conf.TajoConf;
import org.apache.tajo.exception.InternalException;
+import org.apache.tajo.exception.TajoInternalError;
+import org.apache.tajo.exception.UnsupportedException;
import org.apache.tajo.storage.StorageConstants;
import org.apache.tajo.util.KeyValueSet;
import org.apache.thrift.TException;
@@ -73,7 +74,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
public HiveCatalogStore(final Configuration conf) throws InternalException {
if (!(conf instanceof TajoConf)) {
- throw new CatalogException("Invalid Configuration Type:" + conf.getClass().getSimpleName());
+ throw new TajoInternalError("Invalid Configuration Type:" + conf.getClass().getSimpleName());
}
this.conf = conf;
this.defaultTableSpaceUri = TajoConf.getWarehouseDir((TajoConf) conf).toString();
@@ -96,7 +97,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
} catch (NoSuchObjectException nsoe) {
exist = false;
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -127,9 +128,9 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
table = HiveCatalogUtil.getTable(client.getHiveClient(), databaseName, tableName);
path = table.getPath();
} catch (NoSuchObjectException nsoe) {
- throw new CatalogException("Table not found. - tableName:" + tableName, nsoe);
+ throw new UndefinedTableException(tableName);
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
}
// convert HiveCatalogStore field schema into tajo field schema.
@@ -221,7 +222,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
totalSize = fs.getContentSummary(path).getLength();
}
} catch (IOException ioe) {
- throw new CatalogException("Fail to get path. - path:" + path.toString(), ioe);
+ throw new TajoInternalError(ioe);
}
}
stats.setNumBytes(totalSize);
@@ -288,7 +289,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
client = clientPool.getClient();
return client.getHiveClient().getAllTables(databaseName);
} catch (TException e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if(client != null) client.release();
}
@@ -323,7 +324,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
builder.setUri(defaultTableSpaceUri);
return builder.build();
} else {
- throw new CatalogException("tablespace concept is not supported in HiveCatalogStore");
+ throw new UnsupportedException("Tablespace in HiveMeta");
}
}
@@ -335,7 +336,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
@Override
public void alterTablespace(CatalogProtos.AlterTablespaceProto alterProto) throws CatalogException {
- throw new CatalogException("tablespace concept is not supported in HiveCatalogStore");
+ throw new UnsupportedException("Tablespace in HiveMeta");
}
@Override
@@ -351,9 +352,9 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
client = clientPool.getClient();
client.getHiveClient().createDatabase(database);
} catch (AlreadyExistsException e) {
- throw new AlreadyExistsDatabaseException(databaseName);
+ throw new DuplicateDatabaseException(databaseName);
} catch (Throwable t) {
- throw new CatalogException(t);
+ throw new TajoInternalError(t);
} finally {
if (client != null) {
client.release();
@@ -370,7 +371,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
List<String> databaseNames = client.getHiveClient().getAllDatabases();
return databaseNames.contains(databaseName);
} catch (Throwable t) {
- throw new CatalogException(t);
+ throw new TajoInternalError(t);
} finally {
if (client != null) {
client.release();
@@ -386,9 +387,9 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
client = clientPool.getClient();
client.getHiveClient().dropDatabase(databaseName);
} catch (NoSuchObjectException e) {
- throw new NoSuchDatabaseException(databaseName);
+ throw new UndefinedDatabaseException(databaseName);
} catch (Throwable t) {
- throw new CatalogException(databaseName);
+ throw new TajoInternalError(t);
} finally {
if (client != null) {
client.release();
@@ -404,7 +405,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
client = clientPool.getClient();
return client.getHiveClient().getAllDatabases();
} catch (TException e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -549,7 +550,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
sd.setOutputFormat(parquet.hive.DeprecatedParquetOutputFormat.class.getName());
sd.getSerdeInfo().setSerializationLib(parquet.hive.serde.ParquetHiveSerDe.class.getName());
} else {
- throw new CatalogException(new NotImplementedException(tableDesc.getMeta().getStoreType()));
+ throw new UnsupportedException(tableDesc.getMeta().getStoreType() + " in HivecatalogStore");
}
}
@@ -557,10 +558,8 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
table.setSd(sd);
client.getHiveClient().createTable(table);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new CatalogException(e);
+ } catch (Throwable t) {
+ throw new TajoInternalError(t);
} finally {
if(client != null) client.release();
}
@@ -575,7 +574,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
client.getHiveClient().dropTable(databaseName, tableName, false, false);
} catch (NoSuchObjectException nsoe) {
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -601,19 +600,19 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
switch (alterTableDescProto.getAlterTableType()) {
case RENAME_TABLE:
if (existTable(databaseName,alterTableDescProto.getNewTableName().toLowerCase())) {
- throw new AlreadyExistsTableException(alterTableDescProto.getNewTableName());
+ throw new DuplicateTableException(alterTableDescProto.getNewTableName());
}
renameTable(databaseName, tableName, alterTableDescProto.getNewTableName().toLowerCase());
break;
case RENAME_COLUMN:
if (existColumn(databaseName,tableName, alterTableDescProto.getAlterColumnName().getNewColumnName())) {
- throw new ColumnNameAlreadyExistException(alterTableDescProto.getAlterColumnName().getNewColumnName());
+ throw new DuplicateColumnException(alterTableDescProto.getAlterColumnName().getNewColumnName());
}
renameColumn(databaseName, tableName, alterTableDescProto.getAlterColumnName());
break;
case ADD_COLUMN:
if (existColumn(databaseName,tableName, alterTableDescProto.getAddColumn().getName())) {
- throw new ColumnNameAlreadyExistException(alterTableDescProto.getAddColumn().getName());
+ throw new DuplicateColumnException(alterTableDescProto.getAddColumn().getName());
}
addNewColumn(databaseName, tableName, alterTableDescProto.getAddColumn());
break;
@@ -621,7 +620,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
partitionName = alterTableDescProto.getPartitionDesc().getPartitionName();
partitionDesc = getPartition(databaseName, tableName, partitionName);
if(partitionDesc != null) {
- throw new AlreadyExistsPartitionException(databaseName, tableName, partitionName);
+ throw new DuplicatePartitionException(partitionName);
}
addPartition(databaseName, tableName, alterTableDescProto.getPartitionDesc());
break;
@@ -629,7 +628,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
partitionName = alterTableDescProto.getPartitionDesc().getPartitionName();
partitionDesc = getPartition(databaseName, tableName, partitionName);
if(partitionDesc == null) {
- throw new NoSuchPartitionException(databaseName, tableName, partitionName);
+ throw new UndefinedPartitionException(partitionName);
}
dropPartition(databaseName, tableName, partitionDesc);
break;
@@ -652,7 +651,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
} catch (NoSuchObjectException nsoe) {
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -677,7 +676,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
} catch (NoSuchObjectException nsoe) {
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -700,7 +699,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
} catch (NoSuchObjectException nsoe) {
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -732,7 +731,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
client.getHiveClient().add_partition(partition);
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -753,7 +752,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
}
client.getHiveClient().dropPartition(databaseName, tableName, values, true);
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -817,7 +816,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
} catch (NoSuchObjectException e) {
return null;
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -912,7 +911,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
} catch (NoSuchObjectException nsoe) {
} catch (Exception e) {
- throw new CatalogException(e);
+ throw new TajoInternalError(e);
} finally {
if (client != null) {
client.release();
@@ -943,7 +942,7 @@ public class HiveCatalogStore extends CatalogConstants implements CatalogStore {
}
@Override
- public List<TableOptionProto> getAllTableOptions() throws CatalogException {
+ public List<TableOptionProto> getAllTableProperties() throws CatalogException {
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/5d62c409/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogUtil.java b/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogUtil.java
index 59910b8..ef7d4bd 100644
--- a/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogUtil.java
+++ b/tajo-catalog/tajo-catalog-drivers/tajo-hive/src/main/java/org/apache/tajo/catalog/store/HiveCatalogUtil.java
@@ -29,47 +29,51 @@ import org.apache.tajo.catalog.exception.CatalogException;
import org.apache.tajo.catalog.proto.CatalogProtos;
import org.apache.tajo.catalog.CatalogUtil;
import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.exception.ExceptionUtil;
import org.apache.thrift.TException;
import parquet.hadoop.mapred.DeprecatedParquetOutputFormat;
+import static org.apache.tajo.catalog.exception.CatalogExceptionUtil.makeMDCNoMatchedDataType;
+import static org.apache.tajo.exception.ExceptionUtil.makeNotSupported;
+
public class HiveCatalogUtil {
public static void validateSchema(Table tblSchema) throws CatalogException {
for (FieldSchema fieldSchema : tblSchema.getCols()) {
String fieldType = fieldSchema.getType();
if (fieldType.equalsIgnoreCase("ARRAY") || fieldType.equalsIgnoreCase("STRUCT")
|| fieldType.equalsIgnoreCase("MAP")) {
- throw new CatalogException("Unsupported field type :" + fieldType.toUpperCase());
+ throw makeNotSupported(fieldType.toUpperCase());
}
}
}
- public static TajoDataTypes.Type getTajoFieldType(String fieldType) {
- Preconditions.checkNotNull(fieldType);
+ public static TajoDataTypes.Type getTajoFieldType(String dataType) {
+ Preconditions.checkNotNull(dataType);
- if(fieldType.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) {
+ if(dataType.equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) {
return TajoDataTypes.Type.INT4;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) {
return TajoDataTypes.Type.INT1;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.SMALLINT_TYPE_NAME)) {
return TajoDataTypes.Type.INT2;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) {
return TajoDataTypes.Type.INT8;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) {
return TajoDataTypes.Type.BOOLEAN;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) {
return TajoDataTypes.Type.FLOAT4;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) {
return TajoDataTypes.Type.FLOAT8;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.STRING_TYPE_NAME)) {
return TajoDataTypes.Type.TEXT;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.BINARY_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.BINARY_TYPE_NAME)) {
return TajoDataTypes.Type.BLOB;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.TIMESTAMP_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.TIMESTAMP_TYPE_NAME)) {
return TajoDataTypes.Type.TIMESTAMP;
- } else if(fieldType.equalsIgnoreCase(serdeConstants.DATE_TYPE_NAME)) {
+ } else if(dataType.equalsIgnoreCase(serdeConstants.DATE_TYPE_NAME)) {
return TajoDataTypes.Type.DATE;
} else {
- throw new CatalogException("Cannot find a matched type against from '" + fieldType + "'");
+ throw makeMDCNoMatchedDataType(dataType);
}
}
@@ -95,7 +99,7 @@ public class HiveCatalogUtil {
case DATE: return serdeConstants.DATE_TYPE_NAME;
case TIMESTAMP: return serdeConstants.TIMESTAMP_TYPE_NAME;
default:
- throw new CatalogException(dataType + " is not supported.");
+ throw ExceptionUtil.makeInvalidDataType(dataType);
}
}
@@ -104,7 +108,7 @@ public class HiveCatalogUtil {
String[] fileFormatArrary = fileFormat.split("\\.");
if(fileFormatArrary.length < 1) {
- throw new CatalogException("Hive file output format is wrong. - file output format:" + fileFormat);
+ throw makeNotSupported(fileFormat);
}
String outputFormatClass = fileFormatArrary[fileFormatArrary.length-1];
@@ -117,7 +121,7 @@ public class HiveCatalogUtil {
} else if(outputFormatClass.equals(DeprecatedParquetOutputFormat.class.getSimpleName())) {
return CatalogProtos.StoreType.PARQUET.name();
} else {
- throw new CatalogException("Not supported file output format. - file output format:" + fileFormat);
+ throw makeNotSupported(fileFormat);
}
}