Skip to content

Commit

Permalink
Add sql federation scenario for postgresql (#29593)
Browse files Browse the repository at this point in the history
* Add sql federation scenario for postgresql

* Add authority for postgresql
  • Loading branch information
zihaoAK47 authored Jan 2, 2024
1 parent 592464b commit 2d32e71
Show file tree
Hide file tree
Showing 6 changed files with 898 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@
-->

<authority>
<sqlset db-types="PostgreSQL">
<user-create>
<sql>CREATE USER default_user</sql>
<sql>CREATE ROLE default_role</sql>
<sql>CREATE ROLE role2</sql>
<sql>CREATE ROLE role3</sql>
<sql>CREATE ROLE role4</sql>
</user-create>
<user-drop>
<sql>DROP ROLE IF EXISTS default_role</sql>
<sql>DROP ROLE IF EXISTS role_dev</sql>
<sql>DROP ROLE IF EXISTS role_dev_new</sql>
<sql>DROP ROLE IF EXISTS role2</sql>
<sql>DROP ROLE IF EXISTS role3</sql>
<sql>DROP ROLE IF EXISTS role4</sql>
<sql>DROP USER IF EXISTS user_dev</sql>
<sql>DROP USER IF EXISTS user_dev_new</sql>
<sql>DROP USER IF EXISTS default_user</sql>
</user-drop>
</sqlset>
<sqlset db-types="MySQL">
<user-create>
<sql>CREATE ROLE default_role</sql>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--
-- 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 VIEW IF EXISTS t_order_item_join_view;
DROP VIEW IF EXISTS t_order_subquery_view;
DROP VIEW IF EXISTS t_order_aggregation_view;
DROP VIEW IF EXISTS t_order_union_view;

CREATE VIEW t_order_item_join_view AS SELECT o.order_id, o.user_id, i.item_id FROM t_order o INNER JOIN t_order_item i ON o.order_id = i.order_id ORDER BY o.order_id, i.item_id;
CREATE VIEW t_order_subquery_view AS SELECT * FROM t_order o WHERE o.order_id IN (SELECT i.order_id FROM t_order_item i INNER JOIN t_product p ON i.product_id = p.product_id WHERE p.product_id = 10);
CREATE VIEW t_order_aggregation_view AS SELECT MAX(p.price) AS max_price, MIN(p.price) AS min_price, SUM(p.price) AS sum_price, AVG(p.price) AS avg_price, COUNT(1) AS count FROM t_order o INNER JOIN t_order_item i ON o.order_id = i.order_id INNER JOIN t_product p ON i.product_id = p.product_id GROUP BY o.order_id HAVING SUM(p.price) > 10000 ORDER BY max_price;
CREATE VIEW t_order_union_view AS SELECT * FROM t_order WHERE order_id > 2000 UNION SELECT * FROM t_order WHERE order_id > 1500;
Loading

0 comments on commit 2d32e71

Please sign in to comment.