You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2018/03/07 19:49:56 UTC

[2/2] asterixdb git commit: [ASTERIXDB-2305][FUN] replace() should not accept regular expressions

[ASTERIXDB-2305][FUN] replace() should not accept regular expressions

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

Details:
- replace() function was equivalent to regexp_replace(),
  both were based on regular expressions
- this change makes replace() function operate on plain strings
- regexp_replace() continues to operate on regular expressions

Change-Id: Ic01db334c2ef0cab5834cc161ee4f212cf2cb105
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2440
Reviewed-by: Till Westmann <ti...@apache.org>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/c8ba268f
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/c8ba268f
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/c8ba268f

Branch: refs/heads/master
Commit: c8ba268f7f0b2f0aa3ab6fdbd82b79852ff1ae65
Parents: 70daead
Author: Dmitry Lychagin <dm...@couchbase.com>
Authored: Thu Mar 1 17:03:30 2018 -0800
Committer: Dmitry Lychagin <dm...@couchbase.com>
Committed: Wed Mar 7 11:49:37 2018 -0800

----------------------------------------------------------------------
 .../regexp_replace/regexp_replace.1.query.aql   |  28 ++++
 .../regexp_replace/regexp_replace.2.query.aql   |  23 +++
 .../regexp_replace/regexp_replace.3.query.aql   |  21 +++
 .../regexp_replace/regexp_replace.4.query.aql   |  21 +++
 .../regexp_replace/regexp_replace.5.query.aql   |  23 +++
 .../queries/string/replace1/replace1.1.ddl.aql  |  21 ---
 .../string/replace1/replace1.2.update.aql       |  18 ---
 .../string/replace1/replace1.3.query.aql        |  24 ---
 .../queries/string/replace2/replace2.1.ddl.aql  |  21 ---
 .../string/replace2/replace2.2.update.aql       |  18 ---
 .../string/replace2/replace2.3.query.aql        |  22 ---
 .../string/replace21/replace21.1.ddl.aql        |  21 ---
 .../string/replace21/replace21.2.update.aql     |  18 ---
 .../string/replace21/replace21.3.query.aql      |  24 ---
 .../string/replace22/replace22.1.ddl.aql        |  21 ---
 .../string/replace22/replace22.2.update.aql     |  18 ---
 .../string/replace22/replace22.3.query.aql      |  29 ----
 .../queries/string/replace3/replace3.1.ddl.aql  |  21 ---
 .../string/replace3/replace3.2.update.aql       |  18 ---
 .../string/replace3/replace3.3.query.aql        |  22 ---
 .../regexp_replace/regexp_replace.1.query.sqlpp |   2 -
 .../regexp_replace/regexp_replace.2.query.sqlpp |  24 +++
 .../regexp_replace/regexp_replace.3.query.sqlpp |  22 +++
 .../regexp_replace/regexp_replace.4.query.sqlpp |  22 +++
 .../regexp_replace/regexp_replace.5.query.sqlpp |  24 +++
 .../string/replace/replace.1.query.sqlpp        |  33 +++++
 .../string/replace/replace.2.query.sqlpp        |  22 +++
 .../string/replace1/replace1.1.ddl.sqlpp        |  22 ---
 .../string/replace1/replace1.2.update.sqlpp     |  19 ---
 .../string/replace1/replace1.3.query.sqlpp      |  23 ---
 .../string/replace2/replace2.1.ddl.sqlpp        |  22 ---
 .../string/replace2/replace2.2.update.sqlpp     |  19 ---
 .../string/replace2/replace2.3.query.sqlpp      |  23 ---
 .../string/replace21/replace21.1.ddl.sqlpp      |  22 ---
 .../string/replace21/replace21.2.update.sqlpp   |  19 ---
 .../string/replace21/replace21.3.query.sqlpp    |  23 ---
 .../string/replace22/replace22.1.ddl.sqlpp      |  22 ---
 .../string/replace22/replace22.2.update.sqlpp   |  19 ---
 .../string/replace22/replace22.3.query.sqlpp    |  23 ---
 .../string/replace3/replace3.1.ddl.sqlpp        |  22 ---
 .../string/replace3/replace3.2.update.sqlpp     |  19 ---
 .../string/replace3/replace3.3.query.sqlpp      |  23 ---
 .../replace_with_limit.1.query.sqlpp            |  35 +++++
 .../replace_with_limit.2.query.sqlpp            |  22 +++
 .../string/regexp_replace/regexp_replace.1.adm  |   1 +
 .../string/regexp_replace/regexp_replace.2.adm  |   1 +
 .../string/regexp_replace/regexp_replace.3.adm  |   1 +
 .../string/regexp_replace/regexp_replace.4.adm  |   1 +
 .../string/regexp_replace/regexp_replace.5.adm  |   1 +
 .../results/string/replace/replace.1.adm        |  10 ++
 .../results/string/replace/replace.2.adm        |   4 +
 .../results/string/replace1/replace1.1.adm      |   1 -
 .../results/string/replace2/replace2.1.adm      |   1 -
 .../results/string/replace21/replace21.1.adm    |   1 -
 .../results/string/replace22/replace22.1.adm    |   1 -
 .../results/string/replace3/replace3.1.adm      |   1 -
 .../replace_with_limit/replace_with_limit.1.adm |  12 ++
 .../replace_with_limit/replace_with_limit.2.adm |   4 +
 .../src/test/resources/runtimets/testsuite.xml  |  24 +--
 .../resources/runtimets/testsuite_sqlpp.xml     |  27 +---
 .../main/markdown/builtins/2_string_common.md   |  34 ++++-
 .../lang/common/util/CommonFunctionMapUtil.java |   1 -
 .../asterix/om/functions/BuiltinFunctions.java  |  10 +-
 .../impl/StringIntToStringTypeComputer.java     |  19 ++-
 .../AbstractStringStringStringIntEval.java      | 145 +++++++++++++++++++
 .../functions/AbstractTripleStringBoolEval.java |   9 +-
 .../functions/AbstractTripleStringEval.java     |  23 +--
 .../functions/AbstractTripleStringIntEval.java  |   8 +-
 .../AbstractTripleStringStringEval.java         |   8 +-
 .../StringRegExpContainsWithFlagDescriptor.java |   4 +-
 .../StringRegExpLikeWithFlagDescriptor.java     |   4 +-
 .../StringRegExpPositionWithFlagDescriptor.java |   2 -
 .../StringRegExpReplaceDescriptor.java          |   4 +-
 .../StringRegExpReplaceWithFlagsDescriptor.java |   2 +-
 .../functions/StringReplaceDescriptor.java      |  73 ++++++++++
 .../StringReplaceWithLimitDescriptor.java       |  74 ++++++++++
 .../functions/utils/StringReplacer.java         |  62 ++++++++
 .../runtime/functions/FunctionCollection.java   |   4 +
 .../data/std/primitive/UTF8StringPointable.java |  55 ++++++-
 79 files changed, 848 insertions(+), 742 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.1.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.1.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.1.query.aql
new file mode 100644
index 0000000..30b88fd
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.1.query.aql
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+let $c1 := regexp-replace("abracadabra", "", null, null)
+let $c2 := regexp-replace("abracadabra", "bra", "XXX", "")
+let $c3 := regexp-replace(null,"hello world", "XxXx", "x")
+let $c4 := regexp-replace("abracadabra", "bra", "XXX", null)
+let $c5 := regexp-replace("abracadabra", null, "XXX", null)
+let $c6 := regexp-replace("abracadabra", "Bra", null, "i")
+let $c7 := regexp-replace("abracadabra", "Bra", "", "i")
+let $c8 := regexp-replace("abracadabra", "", "XXX", "")
+return {"result1": $c1,"result2": $c2,"result3": $c3,"result4": $c4,"result5": $c5,"result6": $c6,"result7": $c7,"result8": $c8}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.2.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.2.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.2.query.aql
new file mode 100644
index 0000000..fa5e6bd
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.2.query.aql
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+let $c1 := regexp-replace("abracadabra", "a", "")
+let $c2 := regexp-replace("abracadabra", "a(.)", "a$1$1")
+let $c3 := regexp-replace("darted", "^(.*?)d(.*)$", "$1c$2")
+return {"result1": $c1, "result2": $c2, "result3": $c3}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.3.query.aql
new file mode 100644
index 0000000..87329ce
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.3.query.aql
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+let $c1 := regexp-replace("abracadabra", "bra", "*")
+return {"result1": $c1}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.4.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.4.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.4.query.aql
new file mode 100644
index 0000000..61ad141
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.4.query.aql
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+let $c1 := regexp-replace("abracadabra", "a.*a", "*")
+return {"result1": $c1}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.5.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.5.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.5.query.aql
new file mode 100644
index 0000000..b475933
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/regexp_replace/regexp_replace.5.query.aql
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+let $c1 := regexp-replace("abracadabra","Bra", "kkk" , "")
+let $c2 := regexp-replace("abracadabra","Bra", "kkk" ,"i")
+let $c3 := regexp-replace("helloworld","hello world", "kkk" , "x")
+return {"result1": $c1,"result2": $c2,"result3": $c3}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.1.ddl.aql
deleted file mode 100644
index d17ea60..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.1.ddl.aql
+++ /dev/null
@@ -1,21 +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.
- */
-drop dataverse test if exists;
-create dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.2.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.2.update.aql
deleted file mode 100644
index 042f3ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.2.update.aql
+++ /dev/null
@@ -1,18 +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.
- */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.3.query.aql
deleted file mode 100644
index 28a5276..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace1/replace1.3.query.aql
+++ /dev/null
@@ -1,24 +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.
- */
-use dataverse test;
-
-let $c1 := replace("abracadabra", "a", "")
-let $c2 := replace("abracadabra", "a(.)", "a$1$1")
-let $c3 := replace("darted", "^(.*?)d(.*)$", "$1c$2")
-return {"result1": $c1, "result2": $c2, "result3": $c3}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.1.ddl.aql
deleted file mode 100644
index d17ea60..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.1.ddl.aql
+++ /dev/null
@@ -1,21 +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.
- */
-drop dataverse test if exists;
-create dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.2.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.2.update.aql
deleted file mode 100644
index 042f3ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.2.update.aql
+++ /dev/null
@@ -1,18 +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.
- */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.3.query.aql
deleted file mode 100644
index 41ccd31..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace2/replace2.3.query.aql
+++ /dev/null
@@ -1,22 +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.
- */
-use dataverse test;
-
-let $c1 := replace("abracadabra", "bra", "*")
-return {"result1": $c1}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.1.ddl.aql
deleted file mode 100644
index d17ea60..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.1.ddl.aql
+++ /dev/null
@@ -1,21 +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.
- */
-drop dataverse test if exists;
-create dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.2.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.2.update.aql
deleted file mode 100644
index 042f3ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.2.update.aql
+++ /dev/null
@@ -1,18 +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.
- */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.3.query.aql
deleted file mode 100644
index 081f3f4..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace21/replace21.3.query.aql
+++ /dev/null
@@ -1,24 +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.
- */
-use dataverse test;
-
-let $c1 := replace("abracadabra","Bra", "kkk" , "")
-let $c2 := replace("abracadabra","Bra", "kkk" ,"i")
-let $c3 := replace("helloworld","hello world", "kkk" , "x")
-return {"result1": $c1,"result2": $c2,"result3": $c3}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.1.ddl.aql
deleted file mode 100644
index d17ea60..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.1.ddl.aql
+++ /dev/null
@@ -1,21 +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.
- */
-drop dataverse test if exists;
-create dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.2.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.2.update.aql
deleted file mode 100644
index 042f3ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.2.update.aql
+++ /dev/null
@@ -1,18 +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.
- */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql
deleted file mode 100644
index 16364fb..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace22/replace22.3.query.aql
+++ /dev/null
@@ -1,29 +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.
- */
-use dataverse test;
-
-let $c1 := replace("abracadabra", "", null, null)
-let $c2 := replace("abracadabra", "bra", "XXX", "")
-let $c3 := replace(null,"hello world", "XxXx", "x")
-let $c4 := replace("abracadabra", "bra", "XXX", null)
-let $c5 := replace("abracadabra", null, "XXX", null)
-let $c6 := replace("abracadabra", "Bra", null, "i")
-let $c7 := replace("abracadabra", "Bra", "", "i")
-let $c8 := replace("abracadabra", "", "XXX", "")
-return {"result1": $c1,"result2": $c2,"result3": $c3,"result4": $c4,"result5": $c5,"result6": $c6,"result7": $c7,"result8": $c8}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.1.ddl.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.1.ddl.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.1.ddl.aql
deleted file mode 100644
index d17ea60..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.1.ddl.aql
+++ /dev/null
@@ -1,21 +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.
- */
-drop dataverse test if exists;
-create dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.2.update.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.2.update.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.2.update.aql
deleted file mode 100644
index 042f3ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.2.update.aql
+++ /dev/null
@@ -1,18 +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.
- */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.3.query.aql
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.3.query.aql
deleted file mode 100644
index f722e54..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/string/replace3/replace3.3.query.aql
+++ /dev/null
@@ -1,22 +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.
- */
-use dataverse test;
-
-let $c1 := replace("abracadabra", "a.*a", "*")
-return {"result1": $c1}

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.1.query.sqlpp
index 819bb83..fbdf750 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.1.query.sqlpp
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-
-
 {
   'result1':REGEXP_REPLACE('abracadabra','',null,null),
   'result2':REGEXP_REPLACE('abracadabra','bra','XXX',''),

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.2.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.2.query.sqlpp
new file mode 100644
index 0000000..a158d7f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.2.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+{
+  'result1':regexp_replace('abracadabra','a',''),
+  'result2':regexp_replace('abracadabra','a(.)','a$1$1'),
+  'result3':regexp_replace('darted','^(.*?)d(.*)$','$1c$2')
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.3.query.sqlpp
new file mode 100644
index 0000000..910e476
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.3.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+{
+  'result1':regexp_replace('abracadabra','bra','*')
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.4.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.4.query.sqlpp
new file mode 100644
index 0000000..b43481f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.4.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+{
+  'result1':regexp_replace('abracadabra','a.*a','*')
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.5.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.5.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.5.query.sqlpp
new file mode 100644
index 0000000..600abe0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/regexp_replace/regexp_replace.5.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+{
+  'result1':regexp_replace('abracadabra','Bra','kkk',''),
+  'result2':regexp_replace('abracadabra','Bra','kkk','i'),
+  'result3':regexp_replace('helloworld','hello world','kkk','x')
+};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.1.query.sqlpp
new file mode 100644
index 0000000..e08be20
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.1.query.sqlpp
@@ -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.
+ */
+
+select value t from
+[
+  [ 0, is_missing(replace("", null, missing)) ],
+  [ 1, is_null(replace("", null, null)) ],
+  [ 2, is_null(replace("", "", null)) ],
+  [ 3, replace("", "", "") ],
+  [ 4, replace("", "", "a") ],
+  [ 5, replace("a", "a", "") ],
+  [ 6, replace("aaa", "a", "b") ],
+  [ 7, replace("ab_ba_ab", "ab", "ba") ],
+  [ 8, replace("_ab_ba_ab_", "ab", "xyz") ],
+  [ 9, replace("abracadabra_abracadabra_xyz","bra","*BRA*") ]
+] t
+order by t[0]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.2.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.2.query.sqlpp
new file mode 100644
index 0000000..61414fb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace/replace.2.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+select value replace(t, "ab", "ba")
+from ["", "aaa", "ab", "c_ab_ba_ab_ba_ab_c"] t
+order by t

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.sqlpp
deleted file mode 100644
index 21479a2..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.1.ddl.sqlpp
+++ /dev/null
@@ -1,22 +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.
- */
-
-drop  dataverse test if exists;
-create  dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.query.sqlpp
deleted file mode 100644
index 93cb554..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace1/replace1.3.query.sqlpp
+++ /dev/null
@@ -1,23 +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.
- */
-
-use test;
-
-
-{'result1':test.replace('abracadabra','a',''),'result2':test.replace('abracadabra','a(.)','a$1$1'),'result3':test.replace('darted','^(.*?)d(.*)$','$1c$2')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.sqlpp
deleted file mode 100644
index 21479a2..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.1.ddl.sqlpp
+++ /dev/null
@@ -1,22 +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.
- */
-
-drop  dataverse test if exists;
-create  dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.query.sqlpp
deleted file mode 100644
index e8d5e6f..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace2/replace2.3.query.sqlpp
+++ /dev/null
@@ -1,23 +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.
- */
-
-use test;
-
-
-{'result1':test.replace('abracadabra','bra','*')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.sqlpp
deleted file mode 100644
index 21479a2..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.1.ddl.sqlpp
+++ /dev/null
@@ -1,22 +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.
- */
-
-drop  dataverse test if exists;
-create  dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.query.sqlpp
deleted file mode 100644
index 25e5559..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace21/replace21.3.query.sqlpp
+++ /dev/null
@@ -1,23 +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.
- */
-
-use test;
-
-
-{'result1':test.replace('abracadabra','Bra','kkk',''),'result2':test.replace('abracadabra','Bra','kkk','i'),'result3':test.replace('helloworld','hello world','kkk','x')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.sqlpp
deleted file mode 100644
index 21479a2..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.1.ddl.sqlpp
+++ /dev/null
@@ -1,22 +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.
- */
-
-drop  dataverse test if exists;
-create  dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.query.sqlpp
deleted file mode 100644
index 4772d91..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace22/replace22.3.query.sqlpp
+++ /dev/null
@@ -1,23 +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.
- */
-
-use test;
-
-
-{'result1':test.replace('abracadabra','',null,null),'result2':test.replace('abracadabra','bra','XXX',''),'result3':test.replace(null,'hello world','XxXx','x'),'result4':test.replace('abracadabra','bra','XXX',null),'result5':test.replace('abracadabra',null,'XXX',null),'result6':test.replace('abracadabra','Bra',null,'i'),'result7':test.replace('abracadabra','Bra','','i'),'result8':test.replace('abracadabra','','XXX','')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.sqlpp
deleted file mode 100644
index 21479a2..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.1.ddl.sqlpp
+++ /dev/null
@@ -1,22 +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.
- */
-
-drop  dataverse test if exists;
-create  dataverse test;
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp
deleted file mode 100644
index bd244d0..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.2.update.sqlpp
+++ /dev/null
@@ -1,19 +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.
- */
-

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.query.sqlpp
deleted file mode 100644
index a0eb4b4..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace3/replace3.3.query.sqlpp
+++ /dev/null
@@ -1,23 +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.
- */
-
-use test;
-
-
-{'result1':test.replace('abracadabra','a.*a','*')};

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.1.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.1.query.sqlpp
new file mode 100644
index 0000000..3c33e49
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.1.query.sqlpp
@@ -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.
+ */
+
+select value t from
+[
+  [ 0, is_missing(replace("", null, missing, 1)) ],
+  [ 1, is_null(replace("", null, null, 1)) ],
+  [ 2, is_null(replace("", "", null, 1)) ],
+  [ 3, replace("", "", "", 1) ],
+  [ 4, replace("", "", "a", 1) ],
+  [ 5, replace("a", "a", "", tinyint("1")) ],
+  [ 6, replace("aaa", "a", "b", smallint("2")) ],
+  [ 7, replace("ab_ba_ab", "ab", "ba", integer("100")) ],
+  [ 8, replace("_ab_ba_ab_ab_ab_", "ab", "xyz", bigint("4")) ],
+  [ 9, replace("abracadabra_abracadabra_xyz","bra","*BRA*", 3) ],
+  [ 10, replace("ab_ba_ab", "ab", "ba", 0) ],
+  [ 11, replace("ab_ba_ab", "ab", "ba", -100) ]
+] t
+order by t[0]

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.2.query.sqlpp
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.2.query.sqlpp
new file mode 100644
index 0000000..073d033
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/string/replace_with_limit/replace_with_limit.2.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+select value replace(t, "ab", "ba", 2)
+from ["", "aaa", "ab", "c_ab_ba_ab_ba_ab_c"] t
+order by t

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.1.adm
new file mode 100644
index 0000000..c50c7c5
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.1.adm
@@ -0,0 +1 @@
+{ "result1": null, "result2": "aXXXcadaXXX", "result3": null, "result4": null, "result5": null, "result6": null, "result7": "acada", "result8": "XXXaXXXbXXXrXXXaXXXcXXXaXXXdXXXaXXXbXXXrXXXaXXX" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.2.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.2.adm
new file mode 100644
index 0000000..5f992ce
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.2.adm
@@ -0,0 +1 @@
+{ "result1": "brcdbr", "result2": "abbraccaddabbra", "result3": "carted" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.3.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.3.adm
new file mode 100644
index 0000000..fa45140
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.3.adm
@@ -0,0 +1 @@
+{ "result1": "a*cada*" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.4.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.4.adm
new file mode 100644
index 0000000..3882682
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.4.adm
@@ -0,0 +1 @@
+{ "result1": "*" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.5.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.5.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.5.adm
new file mode 100644
index 0000000..9fd2e6a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_replace/regexp_replace.5.adm
@@ -0,0 +1 @@
+{ "result1": "abracadabra", "result2": "akkkcadakkk", "result3": "kkk" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.1.adm
new file mode 100644
index 0000000..a7e9a61
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.1.adm
@@ -0,0 +1,10 @@
+[ 0, true ]
+[ 1, true ]
+[ 2, true ]
+[ 3, "" ]
+[ 4, "a" ]
+[ 5, "" ]
+[ 6, "bbb" ]
+[ 7, "ba_ba_ba" ]
+[ 8, "_xyz_ba_xyz_" ]
+[ 9, "a*BRA*cada*BRA*_a*BRA*cada*BRA*_xyz" ]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.2.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.2.adm
new file mode 100644
index 0000000..c911519
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace/replace.2.adm
@@ -0,0 +1,4 @@
+""
+"aaa"
+"ba"
+"c_ba_ba_ba_ba_ba_c"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace1/replace1.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace1/replace1.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace1/replace1.1.adm
deleted file mode 100644
index 5f992ce..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace1/replace1.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "result1": "brcdbr", "result2": "abbraccaddabbra", "result3": "carted" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace2/replace2.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace2/replace2.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace2/replace2.1.adm
deleted file mode 100644
index fa45140..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace2/replace2.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "result1": "a*cada*" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace21/replace21.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace21/replace21.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace21/replace21.1.adm
deleted file mode 100644
index 9fd2e6a..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace21/replace21.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "result1": "abracadabra", "result2": "akkkcadakkk", "result3": "kkk" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm
deleted file mode 100644
index c50c7c5..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace22/replace22.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "result1": null, "result2": "aXXXcadaXXX", "result3": null, "result4": null, "result5": null, "result6": null, "result7": "acada", "result8": "XXXaXXXbXXXrXXXaXXXcXXXaXXXdXXXaXXXbXXXrXXXaXXX" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace3/replace3.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace3/replace3.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace3/replace3.1.adm
deleted file mode 100644
index 3882682..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace3/replace3.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "result1": "*" }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.1.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.1.adm
new file mode 100644
index 0000000..1e7020e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.1.adm
@@ -0,0 +1,12 @@
+[ 0, true ]
+[ 1, true ]
+[ 2, true ]
+[ 3, "" ]
+[ 4, "a" ]
+[ 5, "" ]
+[ 6, "bba" ]
+[ 7, "ba_ba_ba" ]
+[ 8, "_xyz_ba_xyz_xyz_xyz_" ]
+[ 9, "a*BRA*cada*BRA*_a*BRA*cadabra_xyz" ]
+[ 10, "ab_ba_ab" ]
+[ 11, "ab_ba_ab" ]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.2.adm
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.2.adm
new file mode 100644
index 0000000..5831b1b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/replace_with_limit/replace_with_limit.2.adm
@@ -0,0 +1,4 @@
+""
+"aaa"
+"ba"
+"c_ba_ba_ba_ba_ab_c"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/c8ba268f/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 15828be..50ea7e3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -5443,28 +5443,8 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="string">
-      <compilation-unit name="replace1">
-        <output-dir compare="Text">replace1</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="string">
-      <compilation-unit name="replace2">
-        <output-dir compare="Text">replace2</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="string">
-      <compilation-unit name="replace21">
-        <output-dir compare="Text">replace21</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="string">
-      <compilation-unit name="replace22">
-        <output-dir compare="Text">replace22</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="string">
-      <compilation-unit name="replace3">
-        <output-dir compare="Text">replace3</output-dir>
+      <compilation-unit name="regexp_replace">
+        <output-dir compare="Text">regexp_replace</output-dir>
       </compilation-unit>
     </test-case>
     <test-case FilePath="string">