[ASTERIXDB-2980][*DB][IDX] Add the option "CAST (DEFAULT NULL)" to CREATE INDEX statement

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
Add the option "CAST (DEFAULT NULL)" to CREATE INDEX statement.

- when CAST (DEFAULT NULL) is specified in CREATE INDEX, use
  constructor types to cast the input type to the indexed field type as
  follows: CONSTRUCTOR(IF_MISSING(indexed_field, NULL)).
- in index bulk load path, cast only the indexed fields instead of the
  whole dataset record.
- allow CAST (DEFAULT NULL) only for b-trees.
- add tests.

Change-Id: I3a3ffd3735f1b311bd532dda955e08bf150ced31
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/13883
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
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 27575fb..597034d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -4308,6 +4308,20 @@
         <output-dir compare="Text">index-bad-fields</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="ddl">
+      <compilation-unit name="index-cast-null">
+        <output-dir compare="Text">index-cast-null</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="ddl">
+      <compilation-unit name="index-cast-null-negative">
+        <output-dir compare="Text">index-cast-null-negative</output-dir>
+        <expected-error>Cast Default Null is only allowed for B-Tree indexes</expected-error>
+        <expected-error>Cast Default Null cannot be specified together with ENFORCED</expected-error>
+        <expected-error>CAST is not allowed since field "[typed_f1]" is typed</expected-error>
+        <expected-error>CAST is not allowed since field "[typed_f2]" is typed</expected-error>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="dml">
     <test-case FilePath="dml">