Changeset: 506eb528d8ae for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=506eb528d8ae
Added Files:
        sql/test/null/sqllogictest/Tests/All
        sql/test/null/sqllogictest/Tests/coalesce.stable.err
        sql/test/null/sqllogictest/Tests/coalesce.stable.out
        sql/test/null/sqllogictest/Tests/coalesce.test
        sql/test/null/sqllogictest/Tests/coalesce2.stable.err
        sql/test/null/sqllogictest/Tests/coalesce2.stable.out
        sql/test/null/sqllogictest/Tests/coalesce2.test
        sql/test/null/sqllogictest/Tests/coalesce3.stable.err
        sql/test/null/sqllogictest/Tests/coalesce3.stable.out
        sql/test/null/sqllogictest/Tests/coalesce3.test
        sql/test/null/sqllogictest/Tests/null_in_case.stable.err
        sql/test/null/sqllogictest/Tests/null_in_case.stable.out
        sql/test/null/sqllogictest/Tests/null_in_case.test
        testing/convert_to_sqllogic.sh
Branch: mtest
Log Message:

start convert to sqllogic tests script


diffs (truncated from 333 to 300 lines):

diff --git a/sql/test/null/sqllogictest/Tests/All 
b/sql/test/null/sqllogictest/Tests/All
new file mode 100644
--- /dev/null
+++ b/sql/test/null/sqllogictest/Tests/All
@@ -0,0 +1,4 @@
+null_in_case
+coalesce
+coalesce2
+coalesce3
diff --git a/sql/test/null/sqllogictest/Tests/coalesce.stable.err 
b/sql/test/null/sqllogictest/Tests/coalesce.stable.err
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/coalesce.stable.out 
b/sql/test/null/sqllogictest/Tests/coalesce.stable.out
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/coalesce.test 
b/sql/test/null/sqllogictest/Tests/coalesce.test
new file mode 100644
--- /dev/null
+++ b/sql/test/null/sqllogictest/Tests/coalesce.test
@@ -0,0 +1,63 @@
+statement ok
+CREATE TABLE my_table1 ( col1 VARCHAR(1) ) 
+
+statement ok
+CREATE TABLE my_table2 ( col1 VARCHAR(1) NOT NULL, col2 INT NOT NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES ('A') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('B') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('B') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('C') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('C') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('C') 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('A', 1) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('B', 2) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('C', 3) 
+
+query I rowsort
+SELECT CASE WHEN COALESCE(x.col1,'$CS$') = '$CS$' THEN 0
+            WHEN COAlesce(X.Col1,'$CS$') = x.col1 THEN (SELECT y.col2
+FROM my_table2 y WHERE y.col1 = x.col1)
+       END AS col1
+FROM (
+      SELECT * FROM my_table1
+     ) x
+
+----
+10 values hashing to e0145663d590ae02decc8cdc9071e0c2
+
+statement ok
+DROP   TABLE my_table1 
+
+statement ok
+DROP   TABLE my_table2 
+
diff --git a/sql/test/null/sqllogictest/Tests/coalesce2.stable.err 
b/sql/test/null/sqllogictest/Tests/coalesce2.stable.err
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/coalesce2.stable.out 
b/sql/test/null/sqllogictest/Tests/coalesce2.stable.out
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/coalesce2.test 
b/sql/test/null/sqllogictest/Tests/coalesce2.test
new file mode 100644
--- /dev/null
+++ b/sql/test/null/sqllogictest/Tests/coalesce2.test
@@ -0,0 +1,69 @@
+statement ok
+CREATE TABLE my_table1 ( col1 VARCHAR(1) ) 
+
+statement ok
+CREATE TABLE my_table2 ( col1 VARCHAR(1) NOT NULL, col2 INT NOT NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES ('A') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('B') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('B') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('C') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('C') 
+
+statement ok
+INSERT INTO my_table1 VALUES ('C') 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (NULL) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('A', 1) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('B', 2) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('C', 3) 
+
+query I rowsort
+SELECT (SELECT y.col2 FROM my_table2 y WHERE y.col1 = x.col1) AS col1
+FROM (
+      SELECT * FROM my_table1
+     ) x
+
+----
+10 values hashing to da0f81f3773ec10b245318fdf05e21ce
+
+query I rowsort
+SELECT COALESCE((SELECT y.col2 FROM my_table2 y WHERE y.col1 = x.col1),0) AS 
col1
+FROM (
+      SELECT * FROM my_table1
+     ) x
+
+----
+10 values hashing to e0145663d590ae02decc8cdc9071e0c2
+
+statement ok
+DROP   TABLE my_table1 
+
+statement ok
+DROP   TABLE my_table2 
+
diff --git a/sql/test/null/sqllogictest/Tests/coalesce3.stable.err 
b/sql/test/null/sqllogictest/Tests/coalesce3.stable.err
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/coalesce3.stable.out 
b/sql/test/null/sqllogictest/Tests/coalesce3.stable.out
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/coalesce3.test 
b/sql/test/null/sqllogictest/Tests/coalesce3.test
new file mode 100644
--- /dev/null
+++ b/sql/test/null/sqllogictest/Tests/coalesce3.test
@@ -0,0 +1,62 @@
+statement ok
+CREATE TABLE my_table1 ( id INT NOT NULL, col1 VARCHAR(1) ) 
+
+statement ok
+CREATE TABLE my_table2 ( col1 VARCHAR(1) NOT NULL, col2 INT NOT NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (1,  'A') 
+
+statement ok
+INSERT INTO my_table1 VALUES (2,  'B') 
+
+statement ok
+INSERT INTO my_table1 VALUES (3,  'B') 
+
+statement ok
+INSERT INTO my_table1 VALUES (4,  'C') 
+
+statement ok
+INSERT INTO my_table1 VALUES (5,  'C') 
+
+statement ok
+INSERT INTO my_table1 VALUES (6,  'C') 
+
+statement ok
+INSERT INTO my_table1 VALUES (7,  NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (8,  NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (9,  NULL) 
+
+statement ok
+INSERT INTO my_table1 VALUES (10, NULL) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('A', 1) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('B', 2) 
+
+statement ok
+INSERT INTO my_table2 VALUES ('C', 3) 
+
+query II rowsort
+SELECT id,
+       (SELECT y.col2 FROM my_table2 y WHERE y.col1 = x.col1)
+FROM (
+      SELECT * FROM my_table1
+     ) x
+ORDER BY id
+
+----
+20 values hashing to 90517be8b415ee2ec661c591e9f0c97f
+
+statement ok
+DROP   TABLE my_table1 
+
+statement ok
+DROP   TABLE my_table2 
+
diff --git a/sql/test/null/sqllogictest/Tests/null_in_case.stable.err 
b/sql/test/null/sqllogictest/Tests/null_in_case.stable.err
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/null_in_case.stable.out 
b/sql/test/null/sqllogictest/Tests/null_in_case.stable.out
new file mode 100644
diff --git a/sql/test/null/sqllogictest/Tests/null_in_case.test 
b/sql/test/null/sqllogictest/Tests/null_in_case.test
new file mode 100644
--- /dev/null
+++ b/sql/test/null/sqllogictest/Tests/null_in_case.test
@@ -0,0 +1,5 @@
+query T rowsort
+SELECT CASE WHEN 1 = 1 THEN NULL END
+----
+NULL
+
diff --git a/testing/convert_to_sqllogic.sh b/testing/convert_to_sqllogic.sh
new file mode 100644
--- /dev/null
+++ b/testing/convert_to_sqllogic.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
+set -e 
+
+usage() {
+echo "Usage $0 --src-dir <source dir> --dst-dir <destination directory>"
+echo "Converts old test sql scripts to sqllogic scripts."
+echo "Options:"
+echo " -s|--src-dir <source dir>          directory with old sql tests."
+echo " -t|--dst-dir <destination dir>     destination dotrectory for *.test 
sqllogic tests."
+echo " -d|--dry-run                    dry run"
+echo
+}
+
+src=
+dst=
+dry_run=
+
+for arg in "$@"
+do
+    case $arg in
+        -s|--src-dir)
+            src=$(pwd)/$2
+            dst=$src
+            shift
+            shift
+            ;;
+        -t|--dest-dir)
+            dst=$2
+            shift
+            shift
+            ;;
+        -d|--dry-run)
+            dry_run="true"
+            shift
+            ;;
+    esac
+done
+
+if [[ ! -d "${src}" ]];then
+    echo "ERROR: source directory required!";
+    usage;
+    exit 1;
+fi
+
+[[ ! -d "${dst}" ]] || mkdir -p ${dst}
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to