You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2015/03/17 19:55:37 UTC
phoenix git commit: PHOENIX-1739 Ensure RuntimeException nests
SQLException so that proper exception gets thrown
Repository: phoenix
Updated Branches:
refs/heads/master e14fd32f8 -> 86ed11004
PHOENIX-1739 Ensure RuntimeException nests SQLException so that proper exception gets thrown
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/86ed1100
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/86ed1100
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/86ed1100
Branch: refs/heads/master
Commit: 86ed110045a180e2683d5e9e351a48d984366df0
Parents: e14fd32
Author: James Taylor <jt...@salesforce.com>
Authored: Tue Mar 17 11:54:40 2015 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Tue Mar 17 11:54:40 2015 -0700
----------------------------------------------------------------------
.../end2end/ConvertTimezoneFunctionIT.java | 22 +++++++----
.../phoenix/end2end/EncodeFunctionIT.java | 12 +++---
.../end2end/TimezoneOffsetFunctionIT.java | 12 +++---
.../phoenix/end2end/VariableLengthPKIT.java | 4 +-
.../UngroupedAggregateRegionObserver.java | 4 +-
.../exception/DataExceedsCapacityException.java | 40 ++++++++++++++++++++
.../phoenix/exception/SQLExceptionCode.java | 3 +-
.../ValueTypeIncompatibleException.java | 36 ------------------
.../expression/DecimalAddExpression.java | 4 +-
.../expression/DecimalDivideExpression.java | 4 +-
.../expression/DecimalMultiplyExpression.java | 4 +-
.../expression/DecimalSubtractExpression.java | 4 +-
.../schema/ConstraintViolationException.java | 2 +-
.../org/apache/phoenix/schema/PTableImpl.java | 5 ++-
.../apache/phoenix/schema/types/PBinary.java | 4 +-
.../org/apache/phoenix/schema/types/PChar.java | 4 +-
.../expression/ArithmeticOperationTest.java | 16 ++++----
17 files changed, 94 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java
index e390548..d89a03b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java
@@ -17,12 +17,14 @@ package org.apache.phoenix.end2end;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
+import java.sql.SQLException;
-import org.apache.phoenix.schema.IllegalDataException;
+import org.apache.phoenix.exception.SQLExceptionCode;
import org.junit.Test;
/**
@@ -115,7 +117,7 @@ public class ConvertTimezoneFunctionIT extends BaseHBaseManagedTimeIT {
assertTrue(rs.wasNull());
}
- @Test(expected=IllegalDataException.class)
+ @Test
public void unknownTimezone() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
String ddl = "CREATE TABLE IF NOT EXISTS TIMEZONE_OFFSET_TEST (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))";
@@ -124,11 +126,15 @@ public class ConvertTimezoneFunctionIT extends BaseHBaseManagedTimeIT {
conn.createStatement().execute(dml);
conn.commit();
- ResultSet rs = conn.createStatement().executeQuery(
- "SELECT k1, dates, CONVERT_TZ(dates, 'UNKNOWN_TIMEZONE', 'America/Adak') FROM TIMEZONE_OFFSET_TEST");
-
- rs.next();
-
- rs.getDate(3).getTime();
+ try {
+ ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT k1, dates, CONVERT_TZ(dates, 'UNKNOWN_TIMEZONE', 'America/Adak') FROM TIMEZONE_OFFSET_TEST");
+
+ rs.next();
+ rs.getDate(3).getTime();
+ fail();
+ } catch (SQLException e) {
+ assertEquals(SQLExceptionCode.ILLEGAL_DATA.getErrorCode(), e.getErrorCode());
+ }
}
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
index 6907d2d..489ebfd 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java
@@ -29,8 +29,7 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
-import org.apache.phoenix.expression.function.EncodeFunction;
-import org.apache.phoenix.schema.IllegalDataException;
+import org.apache.phoenix.exception.SQLExceptionCode;
import org.apache.phoenix.util.TestUtil;
import org.junit.Test;
@@ -120,8 +119,8 @@ public class EncodeFunctionIT extends BaseHBaseManagedTimeIT {
try {
conn.createStatement().executeQuery("SELECT * FROM TEST_TABLE WHERE pk = ENCODE(1, NULL)");
fail();
- } catch (IllegalDataException e) {
- assertEquals("Unexpected exception message", e.getMessage(), EncodeFunction.getMissingEncodeFormatMsg());
+ } catch (SQLException e) {
+ assertEquals(SQLExceptionCode.ILLEGAL_DATA.getErrorCode(), e.getErrorCode());
}
}
@@ -134,9 +133,8 @@ public class EncodeFunctionIT extends BaseHBaseManagedTimeIT {
try {
conn.createStatement().executeQuery("SELECT * FROM TEST_TABLE WHERE pk = ENCODE(1, 'HEX')");
fail();
- } catch (IllegalDataException e) {
- assertEquals("Unexpected exception message", e.getMessage(),
- EncodeFunction.getUnsupportedEncodeFormatMsg("HEX"));
+ } catch (SQLException e) {
+ assertEquals(SQLExceptionCode.ILLEGAL_DATA.getErrorCode(), e.getErrorCode());
}
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java
index 6ff6357..324c494 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java
@@ -25,11 +25,12 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.TimeZone;
-import org.apache.phoenix.schema.IllegalDataException;
+import org.apache.phoenix.exception.SQLExceptionCode;
import org.junit.Test;
@@ -74,12 +75,9 @@ public class TimezoneOffsetFunctionIT extends BaseHBaseManagedTimeIT {
rs.next();
assertEquals(0, rs.getInt(3));
fail();
- } catch (IllegalDataException e) {
- assertTrue(true);
- return;
- }
- fail();
-
+ } catch (SQLException e) {
+ assertEquals(SQLExceptionCode.ILLEGAL_DATA.getErrorCode(), e.getErrorCode());
+ }
}
@Test
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java
index 417d147..b7bc7cc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java
@@ -884,8 +884,8 @@ public class VariableLengthPKIT extends BaseClientManagedTimeIT {
try {
stmt.execute("upsert into PTSDB(INST,HOST,VAL) VALUES ('abc', 'abc-def-ghi', 0.5)");
fail();
- } catch (ConstraintViolationException e) {
- assertTrue(e.getMessage().contains("may not be null"));
+ } catch (SQLException e) {
+ assertEquals(SQLExceptionCode.CONSTRAINT_VIOLATION.getErrorCode(), e.getErrorCode());
} finally {
conn.close();
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index 72a0a64..fc37a84 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -56,7 +56,7 @@ import org.apache.hadoop.hbase.regionserver.Store;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.WritableUtils;
import org.apache.phoenix.coprocessor.generated.PTableProtos;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.execute.TupleProjector;
import org.apache.phoenix.expression.Expression;
import org.apache.phoenix.expression.ExpressionType;
@@ -322,7 +322,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver{
column.getDataType(), expression.getMaxLength(),
expression.getScale(), column.getMaxLength(),
column.getScale())) {
- throw new ValueTypeIncompatibleException(
+ throw new DataExceedsCapacityException(
column.getDataType(), column.getMaxLength(),
column.getScale());
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/exception/DataExceedsCapacityException.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/DataExceedsCapacityException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/DataExceedsCapacityException.java
new file mode 100644
index 0000000..0ee81a0
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/DataExceedsCapacityException.java
@@ -0,0 +1,40 @@
+/*
+ * 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.phoenix.exception;
+
+import org.apache.phoenix.schema.IllegalDataException;
+import org.apache.phoenix.schema.types.PDataType;
+
+
+public class DataExceedsCapacityException extends IllegalDataException {
+ private static final long serialVersionUID = 1L;
+
+ public DataExceedsCapacityException(String message) {
+ super(new SQLExceptionInfo.Builder(
+ SQLExceptionCode.DATA_EXCEEDS_MAX_CAPACITY).setMessage(message).build().buildException());
+ }
+
+ public DataExceedsCapacityException(PDataType type, Integer precision, Integer scale) {
+ super(new SQLExceptionInfo.Builder(SQLExceptionCode.DATA_EXCEEDS_MAX_CAPACITY).setMessage(getTypeDisplayString(type, precision, scale))
+ .build().buildException());
+ }
+
+ private static String getTypeDisplayString(PDataType type, Integer precision, Integer scale) {
+ return type.toString() + "(" + precision + (scale == null ? "" : ("," + scale + ")"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index f4b4f98..2eea53b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -82,6 +82,7 @@ public enum SQLExceptionCode {
SINGLE_ROW_SUBQUERY_RETURNS_MULTIPLE_ROWS(215, "22015", "Single-row sub-query returns more than one row."),
SUBQUERY_RETURNS_DIFFERENT_NUMBER_OF_FIELDS(216, "22016", "Sub-query must return the same number of fields as the left-hand-side expression of 'IN'."),
AMBIGUOUS_JOIN_CONDITION(217, "22017", "Amibiguous or non-equi join condition specified. Consider using table list with where clause."),
+ CONSTRAINT_VIOLATION(218, "22018", "Constraint violatioin."),
/**
* Constraint Violation (errorcode 03, sqlstate 23)
@@ -313,7 +314,7 @@ public enum SQLExceptionCode {
return new SQLTimeoutException(OPERATION_TIMED_OUT.getMessage(),
OPERATION_TIMED_OUT.getSQLState(), OPERATION_TIMED_OUT.getErrorCode());
}
- })
+ }),
;
private final int errorCode;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
deleted file mode 100644
index f8be85d..0000000
--- a/phoenix-core/src/main/java/org/apache/phoenix/exception/ValueTypeIncompatibleException.java
+++ /dev/null
@@ -1,36 +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.phoenix.exception;
-
-import org.apache.phoenix.schema.IllegalDataException;
-import org.apache.phoenix.schema.types.PDataType;
-
-
-public class ValueTypeIncompatibleException extends IllegalDataException {
- private static final long serialVersionUID = 1L;
- private static SQLExceptionCode code = SQLExceptionCode.DATA_EXCEEDS_MAX_CAPACITY;
-
- public ValueTypeIncompatibleException(PDataType type, Integer precision, Integer scale) {
- super(new SQLExceptionInfo.Builder(code).setMessage(getTypeDisplayString(type, precision, scale))
- .build().buildException());
- }
-
- private static String getTypeDisplayString(PDataType type, Integer precision, Integer scale) {
- return type.toString() + "(" + precision + (scale == null ? "" : ("," + scale + ")"));
- }
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalAddExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalAddExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalAddExpression.java
index fac9ae6..44c1590 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalAddExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalAddExpression.java
@@ -21,7 +21,7 @@ import java.math.BigDecimal;
import java.util.List;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.schema.types.PDataType;
@@ -74,7 +74,7 @@ public class DecimalAddExpression extends AddExpression {
result = NumberUtil.setDecimalWidthAndScale(result, maxLength, scale);
}
if (result == null) {
- throw new ValueTypeIncompatibleException(PDecimal.INSTANCE, maxLength, scale);
+ throw new DataExceedsCapacityException(PDecimal.INSTANCE, maxLength, scale);
}
ptr.set(PDecimal.INSTANCE.toBytes(result));
return true;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalDivideExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalDivideExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalDivideExpression.java
index a740f5a..4d09f0f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalDivideExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalDivideExpression.java
@@ -21,7 +21,7 @@ import java.math.BigDecimal;
import java.util.List;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.schema.types.PDataType;
@@ -64,7 +64,7 @@ public class DecimalDivideExpression extends DivideExpression {
result = NumberUtil.setDecimalWidthAndScale(result, getMaxLength(), getScale());
}
if (result == null) {
- throw new ValueTypeIncompatibleException(PDecimal.INSTANCE, getMaxLength(), getScale());
+ throw new DataExceedsCapacityException(PDecimal.INSTANCE, getMaxLength(), getScale());
}
ptr.set(PDecimal.INSTANCE.toBytes(result));
return true;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalMultiplyExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalMultiplyExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalMultiplyExpression.java
index fe224b3..813a0e1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalMultiplyExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalMultiplyExpression.java
@@ -21,7 +21,7 @@ import java.math.BigDecimal;
import java.util.List;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.schema.types.PDataType;
@@ -64,7 +64,7 @@ public class DecimalMultiplyExpression extends MultiplyExpression {
result = NumberUtil.setDecimalWidthAndScale(result, getMaxLength(), getScale());
}
if (result == null) {
- throw new ValueTypeIncompatibleException(PDecimal.INSTANCE, getMaxLength(), getScale());
+ throw new DataExceedsCapacityException(PDecimal.INSTANCE, getMaxLength(), getScale());
}
ptr.set(PDecimal.INSTANCE.toBytes(result));
return true;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalSubtractExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalSubtractExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalSubtractExpression.java
index c6eb485..9dc8816 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalSubtractExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/DecimalSubtractExpression.java
@@ -21,7 +21,7 @@ import java.math.BigDecimal;
import java.util.List;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.schema.types.PDataType;
@@ -92,7 +92,7 @@ public class DecimalSubtractExpression extends SubtractExpression {
result = NumberUtil.setDecimalWidthAndScale(result, maxLength, scale);
}
if (result == null) {
- throw new ValueTypeIncompatibleException(PDecimal.INSTANCE, maxLength, scale);
+ throw new DataExceedsCapacityException(PDecimal.INSTANCE, maxLength, scale);
}
ptr.set(PDecimal.INSTANCE.toBytes(result));
return true;
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java
index 465c050..a86b16a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/ConstraintViolationException.java
@@ -37,7 +37,7 @@ public class ConstraintViolationException extends RuntimeException {
public ConstraintViolationException(String message) {
super(new SQLExceptionInfo.Builder(
- SQLExceptionCode.DATA_EXCEEDS_MAX_CAPACITY).setMessage(message).build().buildException());
+ SQLExceptionCode.CONSTRAINT_VIOLATION).setMessage(message).build().buildException());
}
public ConstraintViolationException(Throwable cause) {
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
index 658ff23..8ce4183 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
@@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.coprocessor.generated.PGuidePostsProtos;
import org.apache.phoenix.coprocessor.generated.PGuidePostsProtos.PGuidePosts;
import org.apache.phoenix.coprocessor.generated.PTableProtos;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
import org.apache.phoenix.hbase.index.util.KeyValueBuilder;
import org.apache.phoenix.index.IndexMaintainer;
@@ -521,7 +522,7 @@ public class PTableImpl implements PTable {
if (maxLength != null && type.isFixedWidth() && byteValue.length <= maxLength) {
byteValue = StringUtil.padChar(byteValue, maxLength);
} else if (maxLength != null && byteValue.length > maxLength) {
- throw new ConstraintViolationException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + SchemaUtil.toString(type, byteValue) + ")");
+ throw new DataExceedsCapacityException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + SchemaUtil.toString(type, byteValue) + ")");
}
os.write(byteValue, 0, byteValue.length);
}
@@ -704,7 +705,7 @@ public class PTableImpl implements PTable {
if (ptr.getLength() <= maxLength) {
type.pad(ptr, maxLength);
} else if (ptr.getLength() > maxLength) {
- throw new ConstraintViolationException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + type.toObject(byteValue) + ")");
+ throw new DataExceedsCapacityException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + type.toObject(byteValue) + ")");
}
}
removeIfPresent(unsetValues, family, qualifier);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
index 69d3796..25604a3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PBinary.java
@@ -23,7 +23,7 @@ import java.text.Format;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Base64;
import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.schema.SortOrder;
public class PBinary extends PDataType<byte[]> {
@@ -54,7 +54,7 @@ public class PBinary extends PDataType<byte[]> {
return object;
}
if (b.length > maxLength) {
- throw new ValueTypeIncompatibleException(this, maxLength, null);
+ throw new DataExceedsCapacityException(this, maxLength, null);
}
byte[] newBytes = new byte[maxLength];
System.arraycopy(b, 0, newBytes, 0, b.length);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
index aaee1ba..48d47d3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PChar.java
@@ -23,7 +23,7 @@ import java.util.Arrays;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.schema.SortOrder;
import org.apache.phoenix.util.StringUtil;
@@ -61,7 +61,7 @@ public class PChar extends PDataType<String> {
return object;
}
if (s.length() > maxLength) {
- throw new ValueTypeIncompatibleException(this,maxLength,null);
+ throw new DataExceedsCapacityException(this,maxLength,null);
}
return Strings.padEnd(s, maxLength, ' ');
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/86ed1100/phoenix-core/src/test/java/org/apache/phoenix/expression/ArithmeticOperationTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/expression/ArithmeticOperationTest.java b/phoenix-core/src/test/java/org/apache/phoenix/expression/ArithmeticOperationTest.java
index 028e49a..1b830f2 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/expression/ArithmeticOperationTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/expression/ArithmeticOperationTest.java
@@ -28,7 +28,7 @@ import java.util.Arrays;
import java.util.List;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.phoenix.exception.ValueTypeIncompatibleException;
+import org.apache.phoenix.exception.DataExceedsCapacityException;
import org.apache.phoenix.expression.function.RandomFunction;
import org.apache.phoenix.expression.visitor.CloneExpressionVisitor;
import org.apache.phoenix.schema.types.PDataType;
@@ -68,7 +68,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Pass since we roll out imposing precisioin and scale.
@@ -87,7 +87,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Decimal with no precision and scale.
@@ -141,7 +141,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Pass since we roll up precision and scale imposing.
@@ -160,7 +160,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Decimal with no precision and scale.
@@ -194,7 +194,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Values exceeds scale.
@@ -205,7 +205,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Decimal with no precision and scale.
@@ -243,7 +243,7 @@ public class ArithmeticOperationTest {
try {
e.evaluate(null, new ImmutableBytesWritable());
fail("Evaluation should have failed");
- } catch (ValueTypeIncompatibleException ex) {
+ } catch (DataExceedsCapacityException ex) {
}
// Decimal with no precision and scale.