asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject [1/3] asterixdb git commit: Cast Record Before Insert for Open Indexes
Date Sun, 24 Jul 2016 11:32:33 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 806f7d264 -> a3603ac97


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
index ed23195..5a857d1 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/QueryServiceServlet.java
@@ -47,6 +47,7 @@ import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.result.ResultReader;
 import org.apache.asterix.result.ResultUtils;
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.hyracks.algebricks.core.algebra.prettyprint.AlgebricksAppendable;
 import org.apache.hyracks.api.client.IHyracksClientConnection;
 import org.apache.hyracks.api.dataset.IHyracksDataset;
@@ -316,14 +317,18 @@ public class QueryServiceServlet extends HttpServlet {
     }
 
     private static void printError(PrintWriter pw, Throwable e) {
+        Throwable rootCause = ExceptionUtils.getRootCause(e);
+        if (rootCause == null) {
+            rootCause = e;
+        }
         final boolean addStack = false;
         pw.print("\t\"");
         pw.print(ResultFields.ERRORS.str());
         pw.print("\": [{ \n");
         printField(pw, ErrorField.CODE.str(), "1");
-        final String msg = e.getMessage();
-        printField(pw, ErrorField.MSG.str(), JSONUtil.escape(msg != null ? msg : e.getClass().getSimpleName()),
-                addStack);
+        final String msg = rootCause.getMessage();
+        printField(pw, ErrorField.MSG.str(),
+                JSONUtil.escape(rootCause.getClass().getName() + ": " + msg != null ? msg : ""), addStack);
         if (addStack) {
             StringWriter sw = new StringWriter();
             PrintWriter stackWriter = new PrintWriter(sw);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.ddl.aql
new file mode 100644
index 0000000..300f365
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.ddl.aql
@@ -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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+
+drop dataverse externallibtest if exists;
+create dataverse externallibtest;
+use dataverse externallibtest;
+
+create type Classad as open {
+GlobalJobId: string
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.2.lib.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.2.lib.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.2.lib.aql
new file mode 100644
index 0000000..d936e22
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.2.lib.aql
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+ /*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+install externallibtest testlib src/test/resources/externallib/testlib-zip-binary-assembly.zip
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.3.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.3.ddl.aql
new file mode 100644
index 0000000..16d3ba4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.3.ddl.aql
@@ -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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+use dataverse externallibtest;
+create dataset Condor(Classad) primary key GlobalJobId;
+create index BlockWritesIndex on Condor(BlockWrites:int64) enforced;
+
+create feed CondorFeed using push_localfs(
+("path"="asterix_nc1://data/external-parser/dropbox/jobads1.txt,asterix_nc1://data/external-parser/dropbox/jobads2.txt, asterix_nc1://data/external-parser/dropbox2/jobads3.txt"),
+("reader"="localfs"),
+("format"="semi-structured"),
+("parser"="testlib#org.apache.asterix.external.library.ClassAdParserFactory"),
+("type-name"="Classad"));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.4.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.4.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.4.update.aql
new file mode 100644
index 0000000..5105751
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.4.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+
+use dataverse externallibtest;
+
+set wait-for-completion-feed "true";
+
+connect feed CondorFeed to dataset Condor;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.5.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.5.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.5.query.aql
new file mode 100644
index 0000000..ca1e141
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.5.query.aql
@@ -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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+use dataverse externallibtest;
+
+count( for $x in dataset Condor
+order by $x.GlobalJobId
+return $x);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.6.lib.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.6.lib.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.6.lib.aql
new file mode 100644
index 0000000..335f375
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.6.lib.aql
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+ /*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+uninstall externallibtest testlib
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.7.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.7.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.7.ddl.aql
new file mode 100644
index 0000000..e68e48e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.7.ddl.aql
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+drop dataverse externallibtest if exists;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.ddl.aql
new file mode 100644
index 0000000..94d40c6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.ddl.aql
@@ -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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+
+drop dataverse externallibtest if exists;
+create dataverse externallibtest;
+use dataverse externallibtest;
+
+create type Classad as open {
+GlobalJobId: string
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.2.lib.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.2.lib.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.2.lib.aql
new file mode 100644
index 0000000..9244b81
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.2.lib.aql
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+ /*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+install externallibtest testlib src/test/resources/externallib/testlib-zip-binary-assembly.zip
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.3.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.3.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.3.ddl.aql
new file mode 100644
index 0000000..10a4117
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.3.ddl.aql
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+use dataverse externallibtest;
+create dataset Condor(Classad) primary key GlobalJobId;
+create index BlockWritesIndex on Condor(BlockWrites:int64) enforced;
+create index JobStartDateIndex on Condor(JobStartDate:int64) enforced;
+
+create feed CondorFeed using push_localfs(
+("path"="asterix_nc1://data/external-parser/dropbox/jobads1.txt,asterix_nc1://data/external-parser/dropbox/jobads2.txt, asterix_nc1://data/external-parser/dropbox2/jobads3.txt"),
+("reader"="localfs"),
+("format"="semi-structured"),
+("parser"="testlib#org.apache.asterix.external.library.ClassAdParserFactory"),
+("type-name"="Classad"));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.4.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.4.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.4.update.aql
new file mode 100644
index 0000000..a9e3435
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.4.update.aql
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+
+use dataverse externallibtest;
+
+set wait-for-completion-feed "true";
+
+connect feed CondorFeed to dataset Condor;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.5.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.5.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.5.query.aql
new file mode 100644
index 0000000..481980d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.5.query.aql
@@ -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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+use dataverse externallibtest;
+
+count( for $x in dataset Condor
+order by $x.GlobalJobId
+return $x);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.6.lib.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.6.lib.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.6.lib.aql
new file mode 100644
index 0000000..d972079
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.6.lib.aql
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+ /*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+uninstall externallibtest testlib
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.7.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.7.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.7.ddl.aql
new file mode 100644
index 0000000..e0b7532
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.7.ddl.aql
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Create a feed which uses an external parser to parse data from files
+ *                The files have duplicates and long records. Some records have incorrect types
+ *                for the open indexed field. The dataset has two open indexes.
+ * Expected Res : Success
+ * Date         : Jul, 13, 2016
+ */
+drop dataverse externallibtest if exists;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.adm
new file mode 100644
index 0000000..147ea53
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-open-index/feed-with-external-parser-with-open-index.1.adm
@@ -0,0 +1 @@
+158
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.adm
new file mode 100644
index 0000000..147ea53
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/feeds/feed-with-external-parser-with-two-open-indexes/feed-with-external-parser-with-two-open-indexes.1.adm
@@ -0,0 +1 @@
+158
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index ffa4346..1bb1367 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -150,6 +150,16 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="feeds">
+      <compilation-unit name="feed-with-external-parser-with-open-index">
+        <output-dir compare="Text">feed-with-external-parser-with-open-index</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="feeds">
+      <compilation-unit name="feed-with-external-parser-with-two-open-indexes">
+        <output-dir compare="Text">feed-with-external-parser-with-two-open-indexes</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="feeds">
       <compilation-unit name="feed-with-external-function">
         <output-dir compare="Text">feed-with-external-function</output-dir>
       </compilation-unit>
@@ -4543,7 +4553,7 @@
     <test-case FilePath="open-closed"><!-- Throws two exceptions. need to be checked. proposal: (fixed expected results) -->
       <compilation-unit name="query-issue410">
         <output-dir compare="Text">query-issue410</output-dir>
-        <expected-error>java.lang.IllegalStateException: type mismatch: missing a required closed field name:string</expected-error>
+        <expected-error>HyracksDataException: ASX0000: Field type DOUBLE can't be promoted to type STRING</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="open-closed">

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
----------------------------------------------------------------------
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 2d254da..e1d728d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -110,19 +110,19 @@
     <test-case FilePath="aggregate">
       <compilation-unit name="avg_mixed">
         <output-dir compare="Text">avg_mixed</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type</expected-error>
+        <expected-error>Unexpected type STRING in aggregation input stream. Expected type FLOAT</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
       <compilation-unit name="sum_mixed">
         <output-dir compare="Text">sum_mixed</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type</expected-error>
+        <expected-error>Unexpected type STRING in aggregation input stream. Expected type (or a promotable type to)FLOAT</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
       <compilation-unit name="min_mixed">
         <output-dir compare="Text">min_mixed</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type</expected-error>
+        <expected-error>Unexpected type STRING in aggregation input stream. Expected type FLOAT</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate">
@@ -546,19 +546,19 @@
     <test-case FilePath="aggregate-sql">
       <compilation-unit name="avg_mixed">
         <output-dir compare="Text">avg_mixed</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type STRING</expected-error>
+        <expected-error>Unexpected type STRING in aggregation input stream. Expected type FLOAT</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
       <compilation-unit name="sum_mixed">
         <output-dir compare="Text">sum_mixed</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type STRING</expected-error>
+        <expected-error>Unexpected type STRING in aggregation input stream. Expected type (or a promotable type to)FLOAT</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
       <compilation-unit name="min_mixed">
         <output-dir compare="Text">min_mixed</output-dir>
-        <expected-error>org.apache.hyracks.algebricks.common.exceptions.AlgebricksException: Unexpected type STRING</expected-error>
+        <expected-error>Unexpected type STRING in aggregation input stream. Expected type FLOAT</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="aggregate-sql">
@@ -4328,7 +4328,7 @@
     <test-case FilePath="open-closed">
       <compilation-unit name="query-issue410">
         <output-dir compare="Text">query-issue410</output-dir>
-        <expected-error>java.lang.IllegalStateException: type mismatch: missing a required closed field name:string</expected-error>
+        <expected-error>HyracksDataException: ASX0000: Field type DOUBLE can't be promoted to type STRING</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="open-closed">

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMInsertDeleteOperatorNodePushable.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMInsertDeleteOperatorNodePushable.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMInsertDeleteOperatorNodePushable.java
index cf66d30..fb12808 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMInsertDeleteOperatorNodePushable.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMInsertDeleteOperatorNodePushable.java
@@ -21,13 +21,13 @@ package org.apache.asterix.common.dataflow;
 import java.nio.ByteBuffer;
 
 import org.apache.asterix.common.api.IAsterixAppRuntimeContext;
-import org.apache.asterix.common.exceptions.FrameDataException;
 import org.apache.asterix.common.transactions.ILogMarkerCallback;
 import org.apache.asterix.common.transactions.PrimaryIndexLogMarkerCallback;
 import org.apache.hyracks.api.comm.VSizeFrame;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
 import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
 import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender;
@@ -136,14 +136,20 @@ public class AsterixLSMInsertDeleteOperatorNodePushable extends LSMIndexInsertUp
                         }
                         break;
                     default: {
-                        throw new HyracksDataException(
-                                "Unsupported operation " + op + " in tree index InsertDelete operator");
+                        throw new HyracksDataException("Unsupported operation %1$s in %2$s operator",
+                                ErrorCode.INVALID_OPERATOR_OPERATION, op.toString(),
+                                AsterixLSMInsertDeleteOperatorNodePushable.class.getSimpleName());
                     }
                 }
             }
-        } catch (Throwable th) {
-            FrameDataException fde = new FrameDataException(i, th);
-            throw fde;
+        } catch (HyracksDataException e) {
+            if (e.getErrorCode() == ErrorCode.INVALID_OPERATOR_OPERATION) {
+                throw e;
+            } else {
+                throw new HyracksDataException(e, ErrorCode.ERROR_PROCESSING_TUPLE, i);
+            }
+        } catch (Exception e) {
+            throw new HyracksDataException(e, ErrorCode.ERROR_PROCESSING_TUPLE, i);
         }
 
         writeBuffer.ensureFrameSize(buffer.capacity());

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..66a01e0
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/ErrorCode.java
@@ -0,0 +1,27 @@
+/*
+ * 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.asterix.common.exceptions;
+
+public class ErrorCode {
+    public static final String ASTERIX = "ASX";
+    public static final int ERROR_CASTING_FIELD = 0;
+
+    private ErrorCode() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/FrameDataException.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/FrameDataException.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/FrameDataException.java
deleted file mode 100644
index 18b5264..0000000
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/FrameDataException.java
+++ /dev/null
@@ -1,38 +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.asterix.common.exceptions;
-
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-
-public class FrameDataException extends HyracksDataException {
-
-    private static final long serialVersionUID = 1L;
-
-    private final int tupleIndex;
-
-    public FrameDataException(int tupleIndex, Throwable cause) {
-        super(cause);
-        this.tupleIndex = tupleIndex;
-    }
-
-    public int getTupleIndex() {
-        return tupleIndex;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
index b98f123..304eb0c 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/feed/dataflow/FeedExceptionHandler.java
@@ -23,10 +23,10 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.common.exceptions.FrameDataException;
 import org.apache.asterix.common.exceptions.IExceptionHandler;
 import org.apache.asterix.external.util.FeedFrameUtil;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
 
@@ -51,10 +51,10 @@ public class FeedExceptionHandler implements IExceptionHandler {
     @Override
     public ByteBuffer handle(HyracksDataException th, ByteBuffer frame) {
         try {
-            if (th instanceof FrameDataException) {
+            if (th.getErrorCode() == ErrorCode.ERROR_PROCESSING_TUPLE) {
+                // TODO(amoudi): add check for cause. cause should be either cast or duplicate key
                 fta.reset(frame);
-                FrameDataException fde = (FrameDataException) th;
-                int tupleIndex = fde.getTupleIndex();
+                int tupleIndex = (int) (th.getParams()[0]);
                 try {
                     logExceptionCausingTuple(tupleIndex, th);
                 } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
----------------------------------------------------------------------
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 d213046..0293fcf 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
@@ -29,6 +29,7 @@ import java.util.List;
 
 import org.apache.asterix.builders.RecordBuilder;
 import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.om.pointables.ARecordVisitablePointable;
 import org.apache.asterix.om.pointables.PointableAllocator;
 import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
@@ -73,15 +74,15 @@ class ARecordCaster {
     private final IVisitablePointable nullTypeTag = allocator.allocateEmpty();
     private final IVisitablePointable missingTypeTag = allocator.allocateEmpty();
 
-    private final IBinaryComparator fieldNameComparator = PointableBinaryComparatorFactory
-            .of(UTF8StringPointable.FACTORY).createBinaryComparator();
+    private final IBinaryComparator fieldNameComparator =
+            PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY).createBinaryComparator();
 
     private final ByteArrayAccessibleOutputStream outputBos = new ByteArrayAccessibleOutputStream();
     private final DataOutputStream outputDos = new DataOutputStream(outputBos);
 
     private final IVisitablePointable fieldTempReference = allocator.allocateEmpty();
-    private final Triple<IVisitablePointable, IAType, Boolean> nestedVisitorArg = new Triple<>(fieldTempReference, null,
-            null);
+    private final Triple<IVisitablePointable, IAType, Boolean> nestedVisitorArg =
+            new Triple<>(fieldTempReference, null, null);
 
     private int numInputFields = 0;
 
@@ -130,7 +131,7 @@ class ARecordCaster {
 
             // clear the previous states
             reset();
-            matchClosedPart(fieldNames, fieldTypeTags, fieldValues);
+            matchClosedPart(fieldNames, fieldTypeTags);
             writeOutput(fieldNames, fieldTypeTags, fieldValues, outputDos, visitor);
             resultAccessor.set(outputBos.getByteArray(), 0, outputBos.size());
         } catch (AsterixException e) {
@@ -201,8 +202,8 @@ class ARecordCaster {
         quickSort(reqFieldNamesSortedIndex, reqFieldNames, 0, reqFieldNamesSortedIndex.length - 1);
     }
 
-    private void matchClosedPart(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags,
-            List<IVisitablePointable> fieldValues) throws AsterixException, HyracksDataException {
+    private void matchClosedPart(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags)
+            throws AsterixException, HyracksDataException {
         // sort-merge based match
         quickSort(fieldNamesSortedIndex, fieldNames, 0, numInputFields - 1);
         int fnStart = 0;
@@ -231,6 +232,9 @@ class ARecordCaster {
                             || ATypeHierarchy.canDemote(inputTypeTag, requiredTypeTag)) {
                         fieldPermutation[reqFnPos] = fnPos;
                         openFields[fnPos] = false;
+                    } else {
+                        throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.ERROR_CASTING_FIELD,
+                                "Field type %1$s can't be promoted to type %2$s", inputTypeTag, requiredTypeTag);
                     }
                 }
                 fnStart++;

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
index e7cf912..b4ade4c 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/InlineVariablesRule.java
@@ -69,14 +69,12 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
 
     // Map of variables that could be replaced by their producing expression.
     // Populated during the top-down sweep of the plan.
-    protected Map<LogicalVariable, ILogicalExpression> varAssignRhs = new HashMap<LogicalVariable, ILogicalExpression>();
-
+    protected Map<LogicalVariable, ILogicalExpression> varAssignRhs = new HashMap<>();
     // Visitor for replacing variable reference expressions with their originating expression.
     protected InlineVariablesVisitor inlineVisitor = new InlineVariablesVisitor(varAssignRhs);
-
     // Set of FunctionIdentifiers that we should not inline.
-    protected Set<FunctionIdentifier> doNotInlineFuncs = new HashSet<FunctionIdentifier>();
-
+    protected Set<FunctionIdentifier> doNotInlineFuncs = new HashSet<>();
+    // Indicates whether the rule has been run
     protected boolean hasRun = false;
 
     @Override
@@ -120,19 +118,23 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
         return false;
     }
 
-    /* An expression will be constant at runtime if it has:
+    /**
+     * An expression will be constant at runtime if it has:
      * 1. A type
      * 2. No free variables
+     *
+     * @param op
+     * @param funcExpr
+     * @param context
+     * @return whether a function is constant
+     * @throws AlgebricksException
      */
-    public static boolean functionIsConstantAtRuntime(AbstractLogicalOperator op,
-            AbstractFunctionCallExpression funcExpr, IOptimizationContext context) throws AlgebricksException {
+    public static boolean functionIsConstantAtRuntime(AbstractFunctionCallExpression funcExpr)
+            throws AlgebricksException {
         //make sure that there are no variables in the expression
-        Set<LogicalVariable> usedVariables = new HashSet<LogicalVariable>();
+        Set<LogicalVariable> usedVariables = new HashSet<>();
         funcExpr.getUsedVariables(usedVariables);
-        if (usedVariables.size() > 0) {
-            return false;
-        }
-        return true;
+        return usedVariables.isEmpty();
     }
 
     protected boolean inlineVariables(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
@@ -149,8 +151,8 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
                 // Ignore functions that are either in the doNotInline set or are non-functional
                 if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
                     AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
-                    if (doNotInlineFuncs.contains(funcExpr.getFunctionIdentifier())
-                            || (!funcExpr.isFunctional() && !functionIsConstantAtRuntime(op, funcExpr, context))) {
+                    if (doNotInlineFuncs.contains(funcExpr.getFunctionIdentifier()) || (!funcExpr.isFunctional()
+                            && !InlineVariablesRule.functionIsConstantAtRuntime(funcExpr))) {
                         continue;
                     }
                 }
@@ -176,7 +178,7 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
                     }
                     // Variables produced by a nested subplan cannot be inlined
                     // in operators above the subplan.
-                    Set<LogicalVariable> producedVars = new HashSet<LogicalVariable>();
+                    Set<LogicalVariable> producedVars = new HashSet<>();
                     VariableUtilities.getProducedVariables(root.getValue(), producedVars);
                     varAssignRhs.keySet().removeAll(producedVars);
                 }
@@ -186,7 +188,7 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
         // References to variables generated in the right branch of a left-outer-join cannot be inlined
         // in operators above the left-outer-join.
         if (op.getOperatorTag() == LogicalOperatorTag.LEFTOUTERJOIN) {
-            Set<LogicalVariable> rightLiveVars = new HashSet<LogicalVariable>();
+            Set<LogicalVariable> rightLiveVars = new HashSet<>();
             VariableUtilities.getLiveVariables(op.getInputs().get(1).getValue(), rightLiveVars);
             varAssignRhs.keySet().removeAll(rightLiveVars);
         }
@@ -208,8 +210,8 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
     protected class InlineVariablesVisitor implements ILogicalExpressionReferenceTransform {
 
         private final Map<LogicalVariable, ILogicalExpression> varAssignRhs;
-        private final Set<LogicalVariable> liveVars = new HashSet<LogicalVariable>();
-        private final List<LogicalVariable> rhsUsedVars = new ArrayList<LogicalVariable>();
+        private final Set<LogicalVariable> liveVars = new HashSet<>();
+        private final List<LogicalVariable> rhsUsedVars = new ArrayList<>();
         private ILogicalOperator op;
         private IOptimizationContext context;
         // If set, only replace this variable reference.
@@ -236,54 +238,59 @@ public class InlineVariablesRule implements IAlgebraicRewriteRule {
         public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException {
             ILogicalExpression e = exprRef.getValue();
             switch (((AbstractLogicalExpression) e).getExpressionTag()) {
-                case VARIABLE: {
-                    LogicalVariable var = ((VariableReferenceExpression) e).getVariableReference();
-                    // Restrict replacement to targetVar if it has been set.
-                    if (targetVar != null && var != targetVar) {
-                        return false;
-                    }
+                case VARIABLE:
+                    return transformVariableReferenceExpression(exprRef,
+                            ((VariableReferenceExpression) e).getVariableReference());
+                case FUNCTION_CALL:
+                    return transformFunctionCallExpression((AbstractFunctionCallExpression) e);
+                default:
+                    return false;
+            }
+        }
 
-                    // Make sure has not been excluded from inlining.
-                    if (context.shouldNotBeInlined(var)) {
-                        return false;
-                    }
+        private boolean transformFunctionCallExpression(AbstractFunctionCallExpression fce) throws AlgebricksException {
+            boolean modified = false;
+            for (Mutable<ILogicalExpression> arg : fce.getArguments()) {
+                if (transform(arg)) {
+                    modified = true;
+                }
+            }
+            return modified;
+        }
 
-                    ILogicalExpression rhs = varAssignRhs.get(var);
-                    if (rhs == null) {
-                        // Variable was not produced by an assign.
-                        return false;
-                    }
+        private boolean transformVariableReferenceExpression(Mutable<ILogicalExpression> exprRef, LogicalVariable var)
+                throws AlgebricksException {
+            // Restrict replacement to targetVar if it has been set.
+            if (targetVar != null && var != targetVar) {
+                return false;
+            }
 
-                    // Make sure used variables from rhs are live.
-                    if (liveVars.isEmpty()) {
-                        VariableUtilities.getLiveVariables(op, liveVars);
-                    }
-                    rhsUsedVars.clear();
-                    rhs.getUsedVariables(rhsUsedVars);
-                    for (LogicalVariable rhsUsedVar : rhsUsedVars) {
-                        if (!liveVars.contains(rhsUsedVar)) {
-                            return false;
-                        }
-                    }
+            // Make sure has not been excluded from inlining.
+            if (context.shouldNotBeInlined(var)) {
+                return false;
+            }
 
-                    // Replace variable reference with a clone of the rhs expr.
-                    exprRef.setValue(rhs.cloneExpression());
-                    return true;
-                }
-                case FUNCTION_CALL: {
-                    AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) e;
-                    boolean modified = false;
-                    for (Mutable<ILogicalExpression> arg : fce.getArguments()) {
-                        if (transform(arg)) {
-                            modified = true;
-                        }
-                    }
-                    return modified;
-                }
-                default: {
+            ILogicalExpression rhs = varAssignRhs.get(var);
+            if (rhs == null) {
+                // Variable was not produced by an assign.
+                return false;
+            }
+
+            // Make sure used variables from rhs are live.
+            if (liveVars.isEmpty()) {
+                VariableUtilities.getLiveVariables(op, liveVars);
+            }
+            rhsUsedVars.clear();
+            rhs.getUsedVariables(rhsUsedVars);
+            for (LogicalVariable rhsUsedVar : rhsUsedVars) {
+                if (!liveVars.contains(rhsUsedVar)) {
                     return false;
                 }
             }
+
+            // Replace variable reference with a clone of the rhs expr.
+            exprRef.setValue(rhs.cloneExpression());
+            return true;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/AssignRuntimeFactory.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/AssignRuntimeFactory.java b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/AssignRuntimeFactory.java
index 55ce3a3..88a2f24 100644
--- a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/AssignRuntimeFactory.java
+++ b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/AssignRuntimeFactory.java
@@ -18,6 +18,7 @@
  */
 package org.apache.hyracks.algebricks.runtime.operators.std;
 
+import java.io.Serializable;
 import java.nio.ByteBuffer;
 import java.util.Arrays;
 
@@ -28,6 +29,7 @@ import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneO
 import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputRuntimeFactory;
 import org.apache.hyracks.api.comm.IFrameTupleAccessor;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -97,6 +99,7 @@ public class AssignRuntimeFactory extends AbstractOneInputOneOutputRuntimeFactor
             private ArrayTupleBuilder tupleBuilder = new ArrayTupleBuilder(projectionList.length);
             private boolean first = true;
             private boolean isOpen = false;
+            private int tupleIndex = 0;
 
             @Override
             public void open() throws HyracksDataException {
@@ -128,7 +131,6 @@ public class AssignRuntimeFactory extends AbstractOneInputOneOutputRuntimeFactor
                 // what if nTuple is 0?
                 tAccess.reset(buffer);
                 int nTuple = tAccess.getTupleCount();
-                int t = 0;
                 if (nTuple < 1) {
                     if (nTuple < 0) {
                         throw new HyracksDataException("Negative number of tuples in the frame: " + nTuple);
@@ -136,40 +138,49 @@ public class AssignRuntimeFactory extends AbstractOneInputOneOutputRuntimeFactor
                     appender.flush(writer);
                 } else {
                     if (nTuple > 1) {
-                        for (; t < nTuple - 1; t++) {
-                            tRef.reset(tAccess, t);
-                            produceTuple(tupleBuilder, tAccess, t, tRef);
+                        for (; tupleIndex < nTuple - 1; tupleIndex++) {
+                            tRef.reset(tAccess, tupleIndex);
+                            produceTuple(tupleBuilder, tAccess, tupleIndex, tRef);
                             appendToFrameFromTupleBuilder(tupleBuilder);
                         }
                     }
 
-                    tRef.reset(tAccess, t);
-                    produceTuple(tupleBuilder, tAccess, t, tRef);
-                    if (flushFramesRapidly) {
-                        // Whenever all the tuples in the incoming frame have been consumed, the assign operator
-                        // will push its frame to the next operator; i.e., it won't wait until the frame gets full.
-                        appendToFrameFromTupleBuilder(tupleBuilder, true);
+                    if (tupleIndex < nTuple) {
+                        tRef.reset(tAccess, tupleIndex);
+                        produceTuple(tupleBuilder, tAccess, tupleIndex, tRef);
+                        if (flushFramesRapidly) {
+                            // Whenever all the tuples in the incoming frame have been consumed, the assign operator
+                            // will push its frame to the next operator; i.e., it won't wait until the frame gets full.
+                            appendToFrameFromTupleBuilder(tupleBuilder, true);
+                        } else {
+                            appendToFrameFromTupleBuilder(tupleBuilder);
+                        }
                     } else {
-                        appendToFrameFromTupleBuilder(tupleBuilder);
+                        if (flushFramesRapidly) {
+                            flushAndReset();
+                        }
                     }
                 }
+                tupleIndex = 0;
             }
 
             private void produceTuple(ArrayTupleBuilder tb, IFrameTupleAccessor accessor, int tIndex,
                     FrameTupleReference tupleRef) throws HyracksDataException {
-                tb.reset();
-                for (int f = 0; f < projectionList.length; f++) {
-                    int k = projectionToOutColumns[f];
-                    if (k >= 0) {
-                        try {
+                try {
+                    tb.reset();
+                    for (int f = 0; f < projectionList.length; f++) {
+                        int k = projectionToOutColumns[f];
+                        if (k >= 0) {
                             eval[k].evaluate(tupleRef, result);
-                        } catch (AlgebricksException e) {
-                            throw new HyracksDataException(e);
+                            tb.addField(result.getByteArray(), result.getStartOffset(), result.getLength());
+                        } else {
+                            tb.addField(accessor, tIndex, projectionList[f]);
                         }
-                        tb.addField(result.getByteArray(), result.getStartOffset(), result.getLength());
-                    } else {
-                        tb.addField(accessor, tIndex, projectionList[f]);
                     }
+                } catch (HyracksDataException | AlgebricksException e) {
+                    throw new HyracksDataException(ErrorCode.HYRACKS, ErrorCode.ERROR_PROCESSING_TUPLE,
+                            "Error evaluating tuple %1$s in AssignRuntime", (Throwable) e,
+                            new Serializable[] { tupleIndex });
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
index 1a883b5..e4385bf 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/ErrorCode.java
@@ -18,6 +18,15 @@
  */
 package org.apache.hyracks.api.exceptions;
 
-public class ErrorCode extends HyracksException {
-    public static final int UNKNOWN = 0;
+/**
+ * A registry of runtime error codes
+ */
+public class ErrorCode {
+    public static final String HYRACKS = "HYR";
+    public static final int ERROR_PROCESSING_TUPLE = 0;
+    public static final int INVALID_OPERATOR_OPERATION = 1;
+    public static final int FAILURE_ON_NODE = 2;
+
+    private ErrorCode() {
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
index 73f921f..d17af4c 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
@@ -21,61 +21,73 @@ package org.apache.hyracks.api.exceptions;
 import java.io.Serializable;
 import java.util.Formatter;
 
+/**
+ * The main execution time exception type for runtime errors in a hyracks environment
+ */
 public class HyracksDataException extends HyracksException {
     private static final long serialVersionUID = 1L;
 
     public static final String NONE = "";
-    public static final String HYRACKS = "HYR";
+    public static final int UNKNOWN = 0;
 
     private final String component;
     private final int errorCode;
     private final Serializable[] params;
-    private String nodeId;
+    private final String nodeId;
+    private transient volatile String msgCache;
 
-    private volatile transient String msgCache;
+    public HyracksDataException(String component, int errorCode, String message, Throwable cause, String nodeId,
+            Serializable... params) {
+        super(message, cause);
+        this.component = component;
+        this.errorCode = errorCode;
+        this.nodeId = nodeId;
+        this.params = params;
+    }
 
     public HyracksDataException() {
-        this(NONE, ErrorCode.UNKNOWN, new Object[0]);
+        this(NONE, UNKNOWN, null, null, null, new Serializable[0]);
     }
 
     public HyracksDataException(String message) {
-        this(NONE, ErrorCode.UNKNOWN, message);
+        this(NONE, UNKNOWN, message, (Throwable) null, (String) null);
     }
 
     public HyracksDataException(Throwable cause) {
-        this(NONE, ErrorCode.UNKNOWN, cause);
+        this(NONE, UNKNOWN, cause.getMessage(), cause, (String) null);
+    }
+
+    public HyracksDataException(Throwable cause, String nodeId) {
+        this(NONE, UNKNOWN, cause.getMessage(), cause, nodeId);
+    }
+
+    public HyracksDataException(String message, Throwable cause, String nodeId) {
+        this(NONE, UNKNOWN, message, cause, nodeId);
     }
 
     public HyracksDataException(String message, Throwable cause) {
-        this(NONE, ErrorCode.UNKNOWN, message, cause);
+        this(NONE, UNKNOWN, message, cause, (String) null);
     }
 
     public HyracksDataException(String component, int errorCode, Serializable... params) {
-        this.component = component;
-        this.errorCode = errorCode;
-        this.params = params;
+        this(component, errorCode, null, null, null, params);
+    }
+
+    public HyracksDataException(Throwable cause, int errorCode, Serializable... params) {
+        this(NONE, errorCode, cause.getMessage(), cause, null, params);
     }
 
     public HyracksDataException(String component, int errorCode, String message, Serializable... params) {
-        super(message);
-        this.component = component;
-        this.errorCode = errorCode;
-        this.params = params;
+        this(component, errorCode, message, null, null, params);
     }
 
     public HyracksDataException(String component, int errorCode, Throwable cause, Serializable... params) {
-        super(cause);
-        this.component = component;
-        this.errorCode = errorCode;
-        this.params = params;
+        this(component, errorCode, cause.getMessage(), cause, null, params);
     }
 
     public HyracksDataException(String component, int errorCode, String message, Throwable cause,
             Serializable... params) {
-        super(message, cause);
-        this.component = component;
-        this.errorCode = errorCode;
-        this.params = params;
+        this(component, errorCode, message, cause, null, params);
     }
 
     public String getComponent() {
@@ -90,10 +102,6 @@ public class HyracksDataException extends HyracksException {
         return params;
     }
 
-    public void setNodeId(String nodeId) {
-        this.nodeId = nodeId;
-    }
-
     public String getNodeId() {
         return nodeId;
     }
@@ -111,18 +119,22 @@ public class HyracksDataException extends HyracksException {
      * Example:
      * formatMessage(HYRACKS, ErrorCode.UNKNOWN, "%1$s -- %2$s", "one", "two") returns "HYR0000: one -- two"
      *
-     * @param component the software component in which the error originated
-     * @param errorCode the error code itself
-     * @param message   the user provided error message (a format string as specified in {@link java.util.Formatter})
-     * @param params    an array of objects taht will be provided to the {@link java.util.Formatter}
+     * @param component
+     *            the software component in which the error originated
+     * @param errorCode
+     *            the error code itself
+     * @param message
+     *            the user provided error message (a format string as specified in {@link java.util.Formatter})
+     * @param params
+     *            an array of objects taht will be provided to the {@link java.util.Formatter}
      * @return the formatted string
      */
     public static String formatMessage(String component, int errorCode, String message, Serializable... params) {
         try (Formatter fmt = new Formatter()) {
-            if (! NONE.equals(component)) {
+            if (!NONE.equals(component)) {
                 fmt.format("%1$s%2$04d: ", component, errorCode);
             }
-            fmt.format(message, (Object[]) params);
+            fmt.format(message == null ? "null" : message, (Object[]) params);
             return fmt.out().toString();
         }
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a3603ac9/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/ExceptionUtils.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/ExceptionUtils.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/ExceptionUtils.java
index 5389382b..73c680f 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/ExceptionUtils.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/utils/ExceptionUtils.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.hyracks.api.exceptions.ErrorCode;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
@@ -29,8 +30,17 @@ import org.apache.hyracks.api.exceptions.HyracksDataException;
  */
 public class ExceptionUtils {
 
+    private ExceptionUtils() {
+    }
+
+    /**
+     * get a list of possible root causes from a list of all exceptions
+     *
+     * @param allExceptions
+     * @return List of possible root causes
+     */
     public static List<Exception> getActualExceptions(List<Exception> allExceptions) {
-        List<Exception> exceptions = new ArrayList<Exception>();
+        List<Exception> exceptions = new ArrayList<>();
         for (Exception exception : allExceptions) {
             if (possibleRootCause(exception)) {
                 exceptions.add(exception);
@@ -39,12 +49,17 @@ public class ExceptionUtils {
         return exceptions;
     }
 
+    /**
+     * Associate a node with a list of exceptions
+     *
+     * @param exceptions
+     * @param nodeId
+     */
     public static void setNodeIds(Collection<Exception> exceptions, String nodeId) {
-        List<Exception> newExceptions = new ArrayList<Exception>();
+        List<Exception> newExceptions = new ArrayList<>();
         for (Exception e : exceptions) {
-            HyracksDataException newException = new HyracksDataException(e);
-            newException.setNodeId(nodeId);
-            newExceptions.add(newException);
+            newExceptions.add(
+                    new HyracksDataException(ErrorCode.HYRACKS, ErrorCode.FAILURE_ON_NODE, e.getMessage(), e, nodeId));
         }
         exceptions.clear();
         exceptions.addAll(newExceptions);


Mime
View raw message