hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iw...@apache.org
Subject incubator-hawq git commit: HAWQ-1014. Add feature test for information_schema with new test framework
Date Tue, 13 Sep 2016 01:13:43 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master ecf00d087 -> f1fb48379


HAWQ-1014.  Add feature test for information_schema with new test framework


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

Branch: refs/heads/master
Commit: f1fb48379451c145e1ad4ad7fcbe0d7206f8cc6c
Parents: ecf00d0
Author: ivan <iweng@pivotal.io>
Authored: Fri Sep 9 10:02:12 2016 +0800
Committer: ivan <iweng@pivotal.io>
Committed: Tue Sep 13 09:13:05 2016 +0800

----------------------------------------------------------------------
 .../feature/query/ans/information_schema.ans    | 105 +++++++++++++++++++
 .../feature/query/sql/information_schema.sql    |  57 ++++++++++
 .../feature/query/test_information_schema.cpp   |  19 ++++
 3 files changed, 181 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f1fb4837/src/test/feature/query/ans/information_schema.ans
----------------------------------------------------------------------
diff --git a/src/test/feature/query/ans/information_schema.ans b/src/test/feature/query/ans/information_schema.ans
new file mode 100644
index 0000000..798d558
--- /dev/null
+++ b/src/test/feature/query/ans/information_schema.ans
@@ -0,0 +1,105 @@
+drop table if exists r;
+psql:/tmp/TestInformationSchema_BasicTest.sql:5: NOTICE:  table "r" does not exist, skipping
+DROP TABLE
+create table r(a int, b int);
+CREATE TABLE
+ 
+SELECT attnum::information_schema.cardinal_number 
+from pg_attribute 
+where attnum > 0 and attrelid = 'r'::regclass;
+ attnum 
+--------
+      1
+      2
+(2 rows)
+
+-- this one should fail
+SELECT attnum::information_schema.cardinal_number 
+from pg_attribute 
+where attrelid = 'r'::regclass;
+psql:/tmp/TestInformationSchema_BasicTest.sql:15: ERROR:  value for domain information_schema.cardinal_number
violates check constraint "cardinal_number_domain_check"
+SELECT *
+from (SELECT attnum::information_schema.cardinal_number 
+      from pg_attribute 
+      where attnum > 0 and attrelid = 'r'::regclass) q
+where attnum=2;
+ attnum 
+--------
+      2
+(1 row)
+
+select table_schema, table_name,column_name,ordinal_position
+from information_schema.columns
+where table_name ='r';
+ table_schema | table_name | column_name | ordinal_position 
+--------------+------------+-------------+------------------
+ public       | r          | b           |                2
+ public       | r          | a           |                1
+(2 rows)
+
+select table_schema, table_name,column_name,ordinal_position
+from information_schema.columns
+where table_name ='r'
+and ordinal_position =1;
+ table_schema | table_name | column_name | ordinal_position 
+--------------+------------+-------------+------------------
+ public       | r          | a           |                1
+(1 row)
+
+select table_schema, table_name,column_name,ordinal_position
+from information_schema.columns
+where ordinal_position = 20;
+    table_schema    |      table_name       |    column_name     | ordinal_position 
+--------------------+-----------------------+--------------------+------------------
+ pg_catalog         | pg_proc               | prodataaccess      |               20
+ pg_catalog         | pg_partitions         | parenttablespace   |               20
+ pg_catalog         | pg_class              | reltriggers        |               20
+ pg_catalog         | pg_type               | typtypmod          |               20
+ pg_catalog         | pg_am                 | ambuild            |               20
+ hawq_toolkit       | __hawq_log_master_ext | logdetail          |               20
+ pg_catalog         | pg_filesystem         | fsysacl            |               20
+ pg_catalog         | pg_statistic          | stavalues3         |               20
+ information_schema | parameters            | numeric_scale      |               20
+ information_schema | attributes            | datetime_precision |               20
+ information_schema | element_types         | interval_precision |               20
+ information_schema | routines              | collation_catalog  |               20
+ information_schema | domains               | udt_catalog        |               20
+ information_schema | columns               | collation_catalog  |               20
+(14 rows)
+
+-- MPP-25724
+select a.column_name
+from information_schema.columns a
+where a.table_name
+in
+(select b.table_name from information_schema.tables b where
+	a.column_name like 'b') and a.table_name = 'r';
+ column_name 
+-------------
+ b
+(1 row)
+
+select c.relname
+from pg_class c
+where c.relname
+in
+(select b.table_name from information_schema.tables b where
+	c.relname like 'r');
+ relname 
+---------
+ r
+(1 row)
+
+select a.table_name
+from information_schema.tables a
+where a.table_name
+in
+(select b.relname from pg_class b where
+	a.table_name like 'r');
+ table_name 
+------------
+ r
+(1 row)
+
+drop table r;
+DROP TABLE

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f1fb4837/src/test/feature/query/sql/information_schema.sql
----------------------------------------------------------------------
diff --git a/src/test/feature/query/sql/information_schema.sql b/src/test/feature/query/sql/information_schema.sql
new file mode 100644
index 0000000..ef2db03
--- /dev/null
+++ b/src/test/feature/query/sql/information_schema.sql
@@ -0,0 +1,57 @@
+drop table if exists r;
+create table r(a int, b int);
+ 
+SELECT attnum::information_schema.cardinal_number 
+from pg_attribute 
+where attnum > 0 and attrelid = 'r'::regclass;
+
+-- this one should fail
+SELECT attnum::information_schema.cardinal_number 
+from pg_attribute 
+where attrelid = 'r'::regclass;
+
+
+
+SELECT *
+from (SELECT attnum::information_schema.cardinal_number 
+      from pg_attribute 
+      where attnum > 0 and attrelid = 'r'::regclass) q
+where attnum=2;
+
+select table_schema, table_name,column_name,ordinal_position
+from information_schema.columns
+where table_name ='r';
+
+
+select table_schema, table_name,column_name,ordinal_position
+from information_schema.columns
+where table_name ='r'
+and ordinal_position =1;
+
+select table_schema, table_name,column_name,ordinal_position
+from information_schema.columns
+where ordinal_position = 20;
+
+-- MPP-25724
+select a.column_name
+from information_schema.columns a
+where a.table_name
+in
+(select b.table_name from information_schema.tables b where
+	a.column_name like 'b') and a.table_name = 'r';
+
+select c.relname
+from pg_class c
+where c.relname
+in
+(select b.table_name from information_schema.tables b where
+	c.relname like 'r');
+
+select a.table_name
+from information_schema.tables a
+where a.table_name
+in
+(select b.relname from pg_class b where
+	a.table_name like 'r');
+
+drop table r;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f1fb4837/src/test/feature/query/test_information_schema.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/query/test_information_schema.cpp b/src/test/feature/query/test_information_schema.cpp
new file mode 100644
index 0000000..c41d119
--- /dev/null
+++ b/src/test/feature/query/test_information_schema.cpp
@@ -0,0 +1,19 @@
+#include "gtest/gtest.h"
+
+#include "lib/sql_util.h"
+
+using std::string;
+
+class TestInformationSchema: public ::testing::Test
+{
+	public:
+		TestInformationSchema() { }
+		~TestInformationSchema() {}
+};
+
+TEST_F(TestInformationSchema, BasicTest)
+{
+	hawq::test::SQLUtility util(hawq::test::MODE_DATABASE);
+	util.execSQLFile("query/sql/information_schema.sql",
+	                 "query/ans/information_schema.ans");
+}


Mime
View raw message