Fixed the issue when feeds are created on non-existent field, and added a test case. Removed obselete code.
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index 374cb0c..a216242 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -431,6 +431,12 @@
}
List<String> partitioningExprs = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
.getPartitioningExprs();
+ for (String s : partitioningExprs) {
+ ARecordType aRecordType = (ARecordType) itemType;
+ if (!aRecordType.doesFieldExist(s)) {
+ throw new AlgebricksException("A field with this name " + s + " could not be found.");
+ }
+ }
String ngName = ((FeedDetailsDecl) dd.getDatasetDetailsDecl()).getNodegroupName().getValue();
String adapter = ((FeedDetailsDecl) dd.getDatasetDetailsDecl()).getAdapterFactoryClassname();
Map<String, String> configuration = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
index d4c8c34..b9b9524 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
@@ -148,17 +148,6 @@
throw new AsterixException("Could not find dataset " + datasetName + " in datavetse " + dataverseName);
}
ARecordType itemType = (ARecordType) metadata.findType(dataverseName, dataset.getItemTypeName());
- for (String keyField : DatasetUtils.getPartitioningKeys(dataset)) {
- try {
- if (!itemType.isClosedField(keyField)) {
- throw new AsterixException("Cannot partition dataset \"" + dataset.getDatasetName()
- + "\" by key \"" + keyField + "\" since it is not a valid field of \""
- + itemType.getTypeName() + "\"");
- }
- } catch (IOException e) {
- throw new AsterixException(e);
- }
- }
JobSpecification spec = new JobSpecification();
IBinaryComparatorFactory[] comparatorFactories = DatasetUtils.computeKeysBinaryComparatorFactories(dataset,
itemType, format.getBinaryComparatorFactoryProvider());
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_feed_error/issue_255_create_feed_error.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_feed_error/issue_255_create_feed_error.1.ddl.aql
new file mode 100644
index 0000000..647b93a
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_feed_error/issue_255_create_feed_error.1.ddl.aql
@@ -0,0 +1,23 @@
+/*
+ * Description : create a dataset partitioned on non-existent field
+ * Expected Res : Failure
+ * Date : 14 April 2013
+ * Issue : 272
+ */
+
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+ id: string,
+ username : string,
+ location : string,
+ text : string,
+ timestamp : string
+}
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("output-type-name"="TweetType"),("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("tuple-interval"="10"))
+primary key name;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/testsuite.xml b/asterix-app/src/test/resources/metadata/testsuite.xml
index 74480d4..2a4eaa8 100644
--- a/asterix-app/src/test/resources/metadata/testsuite.xml
+++ b/asterix-app/src/test/resources/metadata/testsuite.xml
@@ -215,7 +215,13 @@
<test-case FilePath="exception">
<compilation-unit name="issue_255_create_dataset_error">
<output-dir compare="Text">none</output-dir>
- <expected-error>AlgebricksException</expected-error>
+ <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="exception">
+ <compilation-unit name="issue_255_create_feed_error">
+ <output-dir compare="Text">none</output-dir>
+ <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
</compilation-unit>
</test-case>
</test-group>