Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update SQL delimiters #1384

Merged
merged 2 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion configuration/etl/etl.d/acls-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"name": "xdmod-public-user",
"description": "Imports the Public User if it does not already exist.",
"sql_file_list": [
"acls/xdmod/create_public_user.sql"
{
"sql_file": "acls/xdmod/create_public_user.sql",
"delimiter": ";"
}
],
"enabled": true
},
Expand Down
14 changes: 0 additions & 14 deletions configuration/etl/etl_sql.d/acls/xdmod/create_public_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,3 @@ LEFT JOIN user_acls cur
ON cur.user_id = inc.user_id AND
cur.acl_id = inc.acl_id
WHERE cur.user_acl_id IS NULL;

-- Create the Role
INSERT INTO Roles(role_id, abbrev, description)
SELECT inc.*
FROM (
SELECT MAX(r.role_id) + 1 AS role_id,
'pub' AS abbrev,
'Public' AS description
FROM Roles r
) inc
LEFT JOIN Roles cur
ON cur.abbrev = inc.abbrev AND
cur.description = inc.description
WHERE cur.role_id IS NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-- the ingestion for both formats are done on the same connection a error is thrown saying that the temporary
-- tale already exists when ingestion for the second format is run. To prevent this we drop the table and
-- recreate it.
DROP TEMPORARY TABLE IF EXISTS ${DESTINATION_SCHEMA}.tmp_end_times;
DROP TEMPORARY TABLE IF EXISTS ${DESTINATION_SCHEMA}.tmp_end_times//
CREATE TEMPORARY TABLE ${DESTINATION_SCHEMA}.tmp_end_times
AS
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ SELECT
FROM
${DESTINATION_SCHEMA}.openstack_raw_event
WHERE
event_type = "volume.delete.end";
//
event_type = "volume.delete.end"//

UPDATE
${DESTINATION_SCHEMA}.asset AS a
Expand All @@ -21,8 +20,7 @@ LEFT JOIN
ON
raw.resource_id = a.resource_id AND raw.openstack_resource_id = a.provider_identifier
SET
a.destroy_time_ts = UNIX_TIMESTAMP(CONVERT_TZ(raw.event_time_utc,'+00:00', @@session.time_zone));
//
a.destroy_time_ts = UNIX_TIMESTAMP(CONVERT_TZ(raw.event_time_utc,'+00:00', @@session.time_zone))//

UPDATE
${DESTINATION_SCHEMA}.asset AS a
Expand All @@ -37,8 +35,7 @@ ON
SET
a.destroy_time_ts = staging.event_time_ts
WHERE
staging.event_type_id = 4;
//
staging.event_type_id = 4//

-- Determine the end time for each instance in a post-processing step. To properly calculate the end
-- time we need to order the fields in order of descending start times and calculate the end time as
Expand All @@ -52,7 +49,7 @@ WHERE
-- the ingestion for both formats are done on the same connection a error is thrown saying that the temporary
-- tale already exists when ingestion for the second format is run. To prevent this we drop the table and
-- recreate it.
DROP TEMPORARY TABLE IF EXISTS ${DESTINATION_SCHEMA}.tmp_end_times;
DROP TEMPORARY TABLE IF EXISTS ${DESTINATION_SCHEMA}.tmp_end_times//
CREATE TEMPORARY TABLE ${DESTINATION_SCHEMA}.tmp_end_times
AS
SELECT
Expand All @@ -79,6 +76,6 @@ AND

-- Truncate raw and staging tables once the data is no longer needed

TRUNCATE ${DESTINATION_SCHEMA}.openstack_raw_event;
TRUNCATE ${DESTINATION_SCHEMA}.openstack_raw_event//

TRUNCATE ${DESTINATION_SCHEMA}.openstack_raw_instance_type;
TRUNCATE ${DESTINATION_SCHEMA}.openstack_raw_instance_type//
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ FROM (
) inc
LEFT JOIN modw_cloud.`domains` cur
ON cur.id = inc.id
WHERE cur.id IS NULL;
WHERE cur.id IS NULL//
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO';
SET SESSION sql_mode='NO_AUTO_VALUE_ON_ZERO'//
INSERT IGNORE INTO ${DESTINATION_SCHEMA}.`staging_resource_type` (resource_type_id, resource_type_description, resource_type_abbrev)
VALUES ('0', 'Unknown Resource Type', 'UNK');
VALUES ('0', 'Unknown Resource Type', 'UNK')//