Merge branch 'diego/hotfix/issue610'
diff --git a/asterix-app/data/adm-load/double_end_record_token.adm b/asterix-app/data/adm-load/double_end_record_token.adm
new file mode 100644
index 0000000..032901f
--- /dev/null
+++ b/asterix-app/data/adm-load/double_end_record_token.adm
@@ -0,0 +1,5 @@
+{
+ "id": 1,
+ "nest_rec": {
+ "id": 2
+}}
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ddl.aql
new file mode 100644
index 0000000..35e93559
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.ddl.aql
@@ -0,0 +1,21 @@
+/*
+ * Description : Load dataset with two consecutive end_record token and correctly recognize them.
+ * Expected Res : Success
+ * Date : 30 Oct 2013
+ */
+
+drop dataverse foo if exists;
+create dataverse foo;
+use dataverse foo;
+
+create type bartype as open {
+id: int32,
+nest_rec: {
+id: int32
+}
+}
+
+create dataset baz(bartype) primary key id;
+
+load dataset baz
+using localfs(("path"="nc1://data/double_end_record_token.adm"), ("format"="adm"));
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.adm b/asterix-app/src/test/resources/runtimets/results/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.adm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/load/issue610_adm_token_end_collection/issue610_adm_token_end_collection.1.adm
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index b80a5b2..1e60319 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -4365,6 +4365,11 @@
<expected-error>edu.uci.ics.hyracks.api.exceptions.HyracksException</expected-error>
</compilation-unit>
</test-case>
+ <test-case FilePath="load">
+ <compilation-unit name="issue610_adm_token_end_collection">
+ <output-dir compare="Text">issue610_adm_token_end_collection</output-dir>
+ </compilation-unit>
+ </test-case>
</test-group>
<test-group name="hints">
<test-case FilePath="hints">
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
index b8c8659..7e51ae6 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/operators/file/ADMDataParser.java
@@ -635,11 +635,16 @@
boolean first = true;
do {
token = nextToken();
- if (token == AdmLexer.TOKEN_END_UNORDERED_LIST) {
- if (expectingListItem) {
- throw new AsterixException("Found END_COLLECTION while expecting a list item.");
+ if (token == AdmLexer.TOKEN_END_RECORD) {
+ if (nextToken() == AdmLexer.TOKEN_END_RECORD) {
+ if (expectingListItem) {
+ throw new AsterixException("Found END_COLLECTION while expecting a list item.");
+ } else {
+ inList = false;
+ }
+ } else {
+ throw new AsterixException("Found END_RECORD while expecting a list item.");
}
- inList = false;
} else if (token == AdmLexer.TOKEN_COMMA) {
if (first) {
throw new AsterixException("Found COMMA before any list item.");
diff --git a/asterix-runtime/src/main/resources/adm.grammar b/asterix-runtime/src/main/resources/adm.grammar
index 80e2cd4..06614d0 100644
--- a/asterix-runtime/src/main/resources/adm.grammar
+++ b/asterix-runtime/src/main/resources/adm.grammar
@@ -45,7 +45,7 @@
START_ORDERED_LIST = char([)
END_ORDERED_LIST = char(])
START_UNORDERED_LIST = string({{)
-END_UNORDERED_LIST = string(}})
+# END_UNORDERED_LIST = }} is recognized as a double END_RECORD token
STRING_LITERAL = char("), anythingUntil(")