Merge commit '594e7eca21' from 'gerrit/mad-hatter'

Change-Id: I975228925366adc94f136bbbb014cb6817bf180e
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 95e67be..9fdc81a 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -773,7 +773,7 @@
                             createExternalDatasetProperties(dataverseName, dd, metadataProvider, mdTxnCtx);
                     ExternalDataUtils.normalize(properties);
                     ExternalDataUtils.validate(properties);
-                    validateExternalDatasetDetails(externalDetails, properties);
+                    validateExternalDatasetProperties(externalDetails, properties, dd.getSourceLocation());
                     datasetDetails = new ExternalDatasetDetails(externalDetails.getAdapter(), properties, new Date(),
                             TransactionState.COMMIT);
                     break;
@@ -3453,13 +3453,13 @@
         }
     }
 
-    protected void validateExternalDatasetDetails(ExternalDetailsDecl externalDetails, Map<String, String> properties)
-            throws RuntimeDataException {
+    protected void validateExternalDatasetProperties(ExternalDetailsDecl externalDetails,
+            Map<String, String> properties, SourceLocation srcLoc) throws CompilationException {
         String adapter = externalDetails.getAdapter();
         // "format" parameter is needed for "S3" data source
         if (ExternalDataConstants.KEY_ADAPTER_NAME_AWS_S3.equals(adapter)
                 && properties.get(ExternalDataConstants.KEY_FORMAT) == null) {
-            throw new RuntimeDataException(ErrorCode.PARAMETERS_REQUIRED, ExternalDataConstants.KEY_FORMAT);
+            throw new CompilationException(ErrorCode.PARAMETERS_REQUIRED, srcLoc, ExternalDataConstants.KEY_FORMAT);
         }
     }
 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-header/query-dataset.001.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-header/query-dataset.001.ddl.sqlpp
index 54022fc..cef7274 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-header/query-dataset.001.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-header/query-dataset.001.ddl.sqlpp
@@ -33,5 +33,5 @@
 ("container"="playground"),
 ("definition"="data_dir"),
 ("format"="CSV"),
-("header"="true")
+("header"=true)
 );
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.007.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.007.ddl.sqlpp
index 047a540..6f96ecf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.007.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.007.ddl.sqlpp
@@ -29,5 +29,5 @@
 ("definition"="data_dir"),
 ("format"="CSV"),
 ("header"="false"),
-("redact-warnings"="true")
+("redact-warnings"="True")
 );
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.010.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.010.ddl.sqlpp
index 575d46f..47daa38 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.010.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv-warnings/query-dataset.010.ddl.sqlpp
@@ -29,6 +29,6 @@
 ("definition"="data_dir"),
 ("format"="CSV"),
 ("header"="true"),
-("redact-warnings"="true"),
+("redact-warnings"=True),
 ("null"="\\N")
 );
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/csv/query-dataset.000.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/csv/query-dataset.000.ddl.sqlpp
index 54e0dc4..a63f3bc 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/csv/query-dataset.000.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/csv/query-dataset.000.ddl.sqlpp
@@ -33,6 +33,6 @@
 ("container"="playground"),
 ("definition"="csv-data/reviews/csv"),
 ("format"="Csv"),
-("header"="false"),
+("header"=False),
 ("null"="")
 );
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/gz/query-dataset.000.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/gz/query-dataset.000.ddl.sqlpp
index 413987d..b8df075 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/gz/query-dataset.000.ddl.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/external-dataset/aws/s3/csv/gz/query-dataset.000.ddl.sqlpp
@@ -33,6 +33,6 @@
 ("container"="playground"),
 ("definition"="csv-data/reviews/gz"),
 ("format"="Csv"),
-("header"="false"),
+("header"=false),
 ("null"="")
 );
\ No newline at end of file
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 e064e8c..f689b5a 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
@@ -81,7 +81,9 @@
     public static final int INVALID_LIKE_PATTERN = 46;
     public static final int INVALID_REQ_PARAM_VAL = 47;
     public static final int INVALID_REQ_JSON_VAL = 48;
-    public static final int INCOMPARABLE_TYPES = 49;
+    public static final int PARAMETERS_REQUIRED = 49;
+    public static final int INVALID_PARAM = 50;
+    public static final int INCOMPARABLE_TYPES = 51;
 
     public static final int UNSUPPORTED_JRE = 100;
 
@@ -314,9 +316,7 @@
     public static final int FAILED_TO_PARSE_METADATA = 3115;
     public static final int INPUT_DECODE_FAILURE = 3116;
     public static final int FAILED_TO_PARSE_MALFORMED_LOG_RECORD = 3117;
-    public static final int PARAMETERS_REQUIRED = 3118;
-    public static final int MALFORMED_RECORD = 3119;
-    public static final int METADATA_DROP_LIBRARY_IN_USE = 3120;
+    public static final int METADATA_DROP_LIBRARY_IN_USE = 3118;
 
     // Lifecycle management errors
     public static final int DUPLICATE_PARTITION_ID = 4000;
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 35509f7..033f377 100644
--- a/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
+++ b/asterixdb/asterix-common/src/main/resources/asx_errormsg/en.properties
@@ -40,7 +40,7 @@
 13,1006 = Duplicate field name \"%1$s\"
 1009 = A returning expression cannot contain dataset access
 37,1091 = Type mismatch: expected value of type %1$s, but got the value of type %2$s
-49 = Incomparable input types: %1$s and %2$s
+51 = Incomparable input types: %1$s and %2$s
 
 # Data errors
 6 = Invalid format for %1$s in %2$s
@@ -83,7 +83,9 @@
 46 = Invalid pattern \"%1$s\" for LIKE
 47 = Invalid value for parameter \"%1$s\": %2$s
 48 = Unable to process JSON content in request
-#49 is used
+49 = Parameter(s) %1$s must be specified
+50 = Invalid parameter \"%1$s\"
+#51 is used
 
 100 = Unsupported JRE: %1$s
 
@@ -234,7 +236,7 @@
 3035 = Feed already has an intake job
 3036 = Feed job already registered in intake jobs
 3037 = Feed job already registered in all jobs
-3038 = Record is too large!. Maximum record size is %1$s
+3038 = Record is too large. Maximum record size is %1$s
 3039 = Cannot parse list item of type %1$s
 3040 = Argument type: %1$s
 3041 = Unable to load/instantiate class %1$s
@@ -312,9 +314,7 @@
 3115 = Failed to parse record metadata
 3116 = Failed to decode input
 3117 = Failed to parse record, malformed log record
-3118 = Parameter(s) %1$s must be specified
-3119 = Record number %1$s is malformed
-3120 = Library %1$s is being used. It cannot be dropped
+3118 = Library %1$s is being used. It cannot be dropped
 
 # Lifecycle management errors
 4000 = Partition id %1$s for node %2$s already in use by node %3$s
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
index 2bb9077..3cf67e6 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
@@ -23,7 +23,6 @@
 import static org.apache.asterix.external.util.ExternalDataConstants.KEY_QUOTE;
 import static org.apache.asterix.external.util.ExternalDataConstants.KEY_RECORD_END;
 import static org.apache.asterix.external.util.ExternalDataConstants.KEY_RECORD_START;
-import static org.apache.asterix.external.util.ExternalDataConstants.KEY_REDACT_WARNINGS;
 
 import java.util.EnumMap;
 import java.util.Map;
@@ -383,11 +382,10 @@
                 configuration.put(ExternalDataConstants.KEY_FORMAT, lowerCaseFormat);
             }
         }
-        // normalize the "header" parameter
-        paramValue = configuration.get(ExternalDataConstants.KEY_HEADER);
-        if (paramValue != null) {
-            configuration.put(ExternalDataConstants.KEY_HEADER, paramValue.toLowerCase().trim());
-        }
+        // normalize "header" parameter
+        putToLowerIfExists(configuration, ExternalDataConstants.KEY_HEADER);
+        // normalize "redact-warnings" parameter
+        putToLowerIfExists(configuration, ExternalDataConstants.KEY_REDACT_WARNINGS);
     }
 
     /**
@@ -408,9 +406,10 @@
         char delimiter = validateGetDelimiter(configuration);
         validateGetQuote(configuration, delimiter);
         validateGetEscape(configuration);
-        String value = configuration.get(KEY_REDACT_WARNINGS);
+        String value = configuration.get(ExternalDataConstants.KEY_REDACT_WARNINGS);
         if (value != null && !isBoolean(value)) {
-            throw new RuntimeDataException(ErrorCode.INVALID_REQ_PARAM_VAL, KEY_REDACT_WARNINGS, value);
+            throw new RuntimeDataException(ErrorCode.INVALID_REQ_PARAM_VAL, ExternalDataConstants.KEY_REDACT_WARNINGS,
+                    value);
         }
     }
 
@@ -443,4 +442,11 @@
             throw new RuntimeDataException(ErrorCode.INVALID_CHAR_LENGTH, parameterValue, parameterName);
         }
     }
+
+    private static void putToLowerIfExists(Map<String, String> configuration, String key) {
+        String paramValue = configuration.get(key);
+        if (paramValue != null) {
+            configuration.put(key, paramValue.toLowerCase().trim());
+        }
+    }
 }
diff --git a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
index 2711e16..0a1d485 100644
--- a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
+++ b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
@@ -1281,7 +1281,9 @@
   String value;
 }
 {
-  <LEFTPAREN> key = StringLiteral() <EQ> value = StringLiteral() <RIGHTPAREN>
+  <LEFTPAREN> key = StringLiteral()
+  <EQ>( value = StringLiteral() | (<TRUE> | <FALSE>) {value = token.image.toLowerCase();} )
+  <RIGHTPAREN>
     {
       return new Pair<String, String>(key, value);
     }
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index ae1493a..ca5b1d8 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -2068,7 +2068,9 @@
   String value;
 }
 {
-  <LEFTPAREN> key = ConstantString() <EQ> value = ConstantString()  <RIGHTPAREN>
+  <LEFTPAREN> key = ConstantString()
+  <EQ> ( value = ConstantString() | (<TRUE> | <FALSE>) {value = token.image.toLowerCase();} )
+  <RIGHTPAREN>
     {
       return new Pair<String, String>(key, value);
     }
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
index ec536c0..7423419 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
@@ -20,6 +20,7 @@
 # 0 --- 9999: runtime errors
 1 = Unsupported operation %1$s in %2$s operator
 2 = Error in processing tuple %1$s in a frame
+3 = Failure on node %1$s
 4 = The file with absolute path %1$s is not within any of the current IO devices
 5 = Phrase search in Full-text is not supported. An expression should include only one word
 6 = Job queue is full with %1$s jobs