[NO ISSUE][FAIL] matchClosedPart exception cleanup
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Introduce new error codes for closed part type mismatch.
- Moved exception messages to error properties file.
Change-Id: I7c58a0758887ff73f958b0b8f5f4ccea558ae189
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17705
Reviewed-by: Murtadha Al Hubail <mhubail@apache.org>
Reviewed-by: Peeyush Gupta <peeyush.gupta@couchbase.com>
Tested-by: Peeyush Gupta <peeyush.gupta@couchbase.com>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index c311681..16d5719 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4154,7 +4154,7 @@
<compilation-unit name="create-dataset-2">
<output-dir compare="Clean-JSON">create-dataset-2</output-dir>
<source-location>false</source-location>
- <expected-error>type mismatch: missing a required closed field my_id: string</expected-error>
+ <expected-error>Type mismatch: missing a required field my_id: string</expected-error>
</compilation-unit>
</test-case>
<test-case FilePath="ddl">
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
index 9101aab..ab2a978 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -87,6 +87,8 @@
PARQUET_CONTAINS_OVERFLOWED_BIGINT(57),
UNEXPECTED_ERROR_ENCOUNTERED(58),
INVALID_PARQUET_FILE(59),
+ TYPE_MISMATCH_EXTRA_FIELD(60),
+ TYPE_MISMATCH_MISSING_FIELD(61),
UNSUPPORTED_JRE(100),
diff --git a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
index 980fa0c..b51b09a 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -94,6 +94,8 @@
57 = Parquet file(s) contain unsigned integer that is larger than the '%1$s' range
58 = Error encountered: %1$s
59 = Invalid Parquet file: %1$s. Reason: %2$s
+60 = Type mismatch: including an extra field %1$s
+61 = Type mismatch: missing a required field %1$s: %2$s
100 = Unsupported JRE: %1$s
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
index 7354c1e..c6e1423 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
@@ -260,7 +260,7 @@
ps.print(typeTag);
//collect the output message and throw the exception
- throw new HyracksDataException("type mismatch: including an extra field " + fieldBos.toString());
+ throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH_EXTRA_FIELD, fieldBos.toString());
}
}
@@ -270,8 +270,8 @@
IAType t = cachedReqType.getFieldTypes()[i];
if (!NonTaggedFormatUtil.isOptional(t)) {
// no matched field in the input for a required closed field
- throw new HyracksDataException("type mismatch: missing a required closed field "
- + cachedReqType.getFieldNames()[i] + ": " + t.getTypeName());
+ throw new RuntimeDataException(ErrorCode.TYPE_MISMATCH_MISSING_FIELD,
+ cachedReqType.getFieldNames()[i], t.getTypeName());
}
}
}