DBZ-4707 MySQL unparseable DDL - CREATE PROCEDURE

This commit is contained in:
harveyyue 2022-02-12 22:03:58 +08:00 committed by Anisha Mohanty
parent 54ba2cd598
commit d07507ddd7
2 changed files with 48 additions and 1 deletions

View File

@ -1753,7 +1753,7 @@ showStatement
(LIMIT (LIMIT
(offset=decimalLiteral ',')? (offset=decimalLiteral ',')?
rowCount=decimalLiteral rowCount=decimalLiteral
) #showErrors )? #showErrors
| SHOW COUNT '(' '*' ')' errorFormat=(ERRORS | WARNINGS) #showCountErrors | SHOW COUNT '(' '*' ')' errorFormat=(ERRORS | WARNINGS) #showCountErrors
| SHOW showSchemaEntity | SHOW showSchemaEntity
(schemaFormat=(FROM | IN) uid)? showFilter? #showSchemaFilter (schemaFormat=(FROM | IN) uid)? showFilter? #showSchemaFilter

View File

@ -366,6 +366,53 @@ BEGIN
END -- //-- delimiter ; END -- //-- delimiter ;
#end #end
#begin #begin
CREATE DEFINER=`bettingservice`@`stage-us-nj-app%` PROCEDURE `AggregatePlayerFactDaily`()
BEGIN
DECLARE CID_min BIGINT;
DECLARE CID_max BIGINT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
SHOW ERRORS;
ROLLBACK;
END;
SELECT LastID+1 INTO CID_min FROM AggregateStatus
WHERE TableName = 'Combination_Transaction_Player_Fact';
SELECT Id INTO CID_max FROM Combination_Transaction ORDER BY Id DESC LIMIT 1;
START TRANSACTION;
UPDATE AggregateStatus SET LastId = CID_max, LastUpdated = CURRENT_TIMESTAMP
WHERE TableName = 'Combination_Transaction_Player_Fact';
INSERT INTO Combination_Transaction_Player_Fact
SELECT
NULL `Id`,
CT.Player_UID,
CT.Tx_Type `Type`,
DATE(BT.Timestamp) `Date`,
SUM(CT.Real_Amount) `Real_Amount`,
SUM(CT.Bonus_Amount) `Bonus_Amount`,
BT.Currency_UID,
COUNT(CT.Id) Tx_Count,
SUM(IF(CT.Real_Amount>0,1,0)) `Real_Count`,
SUM(IF(CT.Bonus_Amount>0,1,0)) `Bonus_Count`
FROM Combination_Transaction CT
LEFT JOIN Betting_Transaction BT ON CT.Betting_Tx_ID = BT.ID
WHERE CT.Id BETWEEN CID_min
AND CID_max
GROUP BY CT.Player_UID, CT.Tx_Type, DATE(BT.Timestamp)
ON DUPLICATE KEY UPDATE
Currency_UID = VALUES(Currency_UID),
Tx_Count = Tx_Count + VALUES(Tx_Count),
Real_Amount = Real_Amount + VALUES(Real_Amount),
Bonus_Amount = Bonus_Amount + VALUES(Bonus_Amount),
Real_Count = Real_Count + VALUES(Real_Count),
Bonus_Count = Bonus_Count + VALUES(Bonus_Count);
COMMIT;
END
#end
#begin
-- Create Role -- Create Role
create role 'RL_COMPLIANCE_NSA'; create role 'RL_COMPLIANCE_NSA';
create role if not exists 'RL_COMPLIANCE_NSA'; create role if not exists 'RL_COMPLIANCE_NSA';