Skip to content

Commit eaf66c5

Browse files
authored
add power case to pattern query (#1008)
1 parent 110d7df commit eaf66c5

7 files changed

Lines changed: 600 additions & 0 deletions

File tree

37.4 KB
Loading
57.8 KB
Loading
21.2 KB
Loading

src/UserGuide/Master/Table/User-Manual/Pattern-Query_timecho.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,3 +986,153 @@ MATCH_RECOGNIZE (
986986
+---------+-----+-----------------------------+-----------------------------+------------+
987987
Total line number = 2
988988
```
989+
990+
991+
## 4. Practical Cases
992+
993+
### 4.1 Altitude Monitoring
994+
995+
* **Business Background**
996+
997+
During oil product transportation, environmental pressure is directly affected by altitude: higher altitude means lower atmospheric pressure, which increases oil evaporation risks. To accurately assess natural oil loss, BeiDou positioning data must identify altitude anomalies to support loss evaluation.
998+
999+
* **Data Structure**
1000+
1001+
Monitoring table contains these core fields:
1002+
1003+
| **ColumnName** | DataType | Category | Comment |
1004+
| ---------------------- | ----------- | ---------- | ------------------------ |
1005+
| time | TIMESTAMP | TIME | Data collection timestamp |
1006+
| device\_id | STRING | TAG | Vehicle device ID (partition key) |
1007+
| department | STRING | FIELD | Affiliated department |
1008+
| altitude | DOUBLE | FIELD | Altitude (unit: meters) |
1009+
1010+
* **Business Requirements**
1011+
1012+
Identify altitude anomaly events: When vehicle altitude exceeds 500m and later drops below 500m, it constitutes a complete anomaly event. Calculate core metrics:
1013+
1014+
* Event start time (first timestamp exceeding 500m)
1015+
* Event end time (last timestamp above 500m)
1016+
* Maximum altitude during event
1017+
1018+
![](/img/pattern-query-altitude.png)
1019+
1020+
* **Implementation Method**
1021+
1022+
```SQL
1023+
SELECT *
1024+
FROM beidou
1025+
MATCH_RECOGNIZE (
1026+
PARTITION BY device_id -- Partition by vehicle device ID
1027+
ORDER BY time -- Chronological ordering
1028+
MEASURES
1029+
FIRST(A.time) AS ts_s, -- Event start timestamp
1030+
LAST(A.time) AS ts_e, -- Event end timestamp
1031+
MAX(A.altitude) AS max_a -- Maximum altitude during event
1032+
PATTERN (A+) -- Match consecutive records above 500m
1033+
DEFINE
1034+
A AS A.altitude > 500 -- Define A as altitude > 500m
1035+
)
1036+
```
1037+
1038+
### 4.2 Safety Injection Operation Identification
1039+
1040+
* **Business Background**
1041+
1042+
Nuclear power plants require periodic safety tests (e.g., PT1RPA010 "Safety Injection Logic Test with 1 RPA 601KC") to verify equipment integrity. These tests cause characteristic flow pattern changes. The control system must identify these patterns to detect anomalies and ensure equipment safety.
1043+
1044+
* **Data Structure**
1045+
1046+
Sensor table contains these core fields:
1047+
1048+
| **ColumnName** | DataType | Category | Comment |
1049+
| ---------------------- | ----------- | ---------- | ------------------------ |
1050+
| time | TIMESTAMP | TIME | Data collection timestamp |
1051+
| pipe\_id | STRING | TAG | Pipe ID (partition key) |
1052+
| pressure | DOUBLE | FIELD | Pipe pressure |
1053+
| flow\_rate | DOUBLE | FIELD | Pipe flow rate (key metric) |
1054+
1055+
* **Business Requirements**
1056+
1057+
Identify PT1RPA010 flow pattern: Normal flow → Continuous decline → Extremely low flow (<0.5) → Continuous recovery → Normal flow. Extract core metrics:
1058+
1059+
* Pattern start time (initial normal flow timestamp)
1060+
* Pattern end time (recovered normal flow timestamp)
1061+
* Extremely low phase start/end times
1062+
* Minimum flow rate during extremely low phase
1063+
1064+
![](/img/pattern-query-flow.png)
1065+
1066+
* **Implementation Method**
1067+
1068+
```SQL
1069+
SELECT * FROM sensor MATCH_RECOGNIZE(
1070+
PARTITION BY pipe_id -- Partition by pipe ID
1071+
ORDER BY time -- Chronological ordering
1072+
MEASURES
1073+
A.time AS start_ts, -- Pattern start timestamp
1074+
E.time AS end_ts, -- Pattern end timestamp
1075+
FIRST(C.time) AS low_start_ts, -- Extremely low phase start
1076+
LAST(C.time) AS low_end_ts, -- Extremely low phase end
1077+
MIN(C.flow_rate) AS min_low_flow -- Minimum flow during low phase
1078+
ONE ROW PER MATCH -- Output one row per match
1079+
PATTERN(A B+? C+ D+? E) -- Match normal→decline→extremely low→recovery→normal
1080+
DEFINE
1081+
A AS flow_rate BETWEEN 2 AND 2.5, -- Initial normal flow
1082+
B AS flow_rate < PREV(B.flow_rate), -- Continuous decline
1083+
C AS flow_rate < 0.5, -- Extremely low threshold
1084+
D AS flow_rate > PREV(D.flow_rate), -- Continuous recovery
1085+
E AS flow_rate BETWEEN 2 AND 2.5 -- Normal recovery
1086+
);
1087+
```
1088+
1089+
### 4.3 Extreme Operational Gust (Sombrero Wind) Identification
1090+
1091+
* **Business Background**
1092+
1093+
In wind power generation, "extreme operational gusts (sombrero wind)" are short-duration (≈10s) sinusoidal gusts with prominent peaks that can cause physical turbine damage. Identifying these gusts and calculating their frequency helps assess turbine damage risks and guide maintenance.
1094+
1095+
* **Data Structure**
1096+
1097+
Turbine sensor table contains:
1098+
1099+
| **ColumnName** | DataType | Category | Comment |
1100+
| ---------------------- | ----------- | ---------- | ------------------------ |
1101+
| time | TIMESTAMP | TIME | Wind speed timestamp |
1102+
| speed | DOUBLE | FIELD | Wind speed (key metric) |
1103+
1104+
* **Business Requirements**
1105+
1106+
Identify sombrero wind pattern: Gradual speed decline → Sharp increase → Sharp decrease → Gradual recovery to initial value (≈10s total). Primary goal: count gust occurrences for risk assessment.
1107+
1108+
![](/img/pattern-query-speed.png)
1109+
1110+
* **Implementation Method**
1111+
1112+
```SQL
1113+
SELECT COUNT(*) -- Count extreme gust occurrences
1114+
FROM sensor
1115+
MATCH_RECOGNIZE(
1116+
ORDER BY time -- Chronological ordering
1117+
MEASURES
1118+
FIRST(B.time) AS ts_s, -- Gust start timestamp
1119+
LAST(D.time) AS ts_e -- Gust end timestamp
1120+
PATTERN (B+ R+? F+? D+? E) -- Match sombrero wind pattern
1121+
DEFINE
1122+
-- Phase B: Gradual decline, initial speed>9, delta<2.5
1123+
B AS speed <= AVG(B.speed)
1124+
AND FIRST(B.speed) > 9
1125+
AND (FIRST(B.speed) - LAST(B.speed)) < 2.5,
1126+
-- Phase R: Sharp increase (above phase average)
1127+
R AS speed >= AVG(R.speed),
1128+
-- Phase F: Sharp decrease, peak>16 (crest threshold)
1129+
F AS speed <= AVG(F.speed)
1130+
AND MAX(F.speed) > 16,
1131+
-- Phase D: Gradual recovery, delta<2.5
1132+
D AS speed >= AVG(D.speed)
1133+
AND (LAST(D.speed) - FIRST(D.speed)) < 2.5,
1134+
-- Phase E: Recovery to ±0.2 of initial value, total duration <11s
1135+
E AS speed - FIRST(B.speed) BETWEEN -0.2 AND 0.2
1136+
AND time - FIRST(B.time) < 11
1137+
);
1138+
```

src/UserGuide/latest-Table/User-Manual/Pattern-Query_timecho.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,3 +986,152 @@ MATCH_RECOGNIZE (
986986
+---------+-----+-----------------------------+-----------------------------+------------+
987987
Total line number = 2
988988
```
989+
990+
## 4. Practical Cases
991+
992+
### 4.1 Altitude Monitoring
993+
994+
* **Business Background**
995+
996+
During oil product transportation, environmental pressure is directly affected by altitude: higher altitude means lower atmospheric pressure, which increases oil evaporation risks. To accurately assess natural oil loss, BeiDou positioning data must identify altitude anomalies to support loss evaluation.
997+
998+
* **Data Structure**
999+
1000+
Monitoring table contains these core fields:
1001+
1002+
| **ColumnName** | DataType | Category | Comment |
1003+
| ---------------------- | ----------- | ---------- | ------------------------ |
1004+
| time | TIMESTAMP | TIME | Data collection timestamp |
1005+
| device\_id | STRING | TAG | Vehicle device ID (partition key) |
1006+
| department | STRING | FIELD | Affiliated department |
1007+
| altitude | DOUBLE | FIELD | Altitude (unit: meters) |
1008+
1009+
* **Business Requirements**
1010+
1011+
Identify altitude anomaly events: When vehicle altitude exceeds 500m and later drops below 500m, it constitutes a complete anomaly event. Calculate core metrics:
1012+
1013+
* Event start time (first timestamp exceeding 500m)
1014+
* Event end time (last timestamp above 500m)
1015+
* Maximum altitude during event
1016+
1017+
![](/img/pattern-query-altitude.png)
1018+
1019+
* **Implementation Method**
1020+
1021+
```SQL
1022+
SELECT *
1023+
FROM beidou
1024+
MATCH_RECOGNIZE (
1025+
PARTITION BY device_id -- Partition by vehicle device ID
1026+
ORDER BY time -- Chronological ordering
1027+
MEASURES
1028+
FIRST(A.time) AS ts_s, -- Event start timestamp
1029+
LAST(A.time) AS ts_e, -- Event end timestamp
1030+
MAX(A.altitude) AS max_a -- Maximum altitude during event
1031+
PATTERN (A+) -- Match consecutive records above 500m
1032+
DEFINE
1033+
A AS A.altitude > 500 -- Define A as altitude > 500m
1034+
)
1035+
```
1036+
1037+
### 4.2 Safety Injection Operation Identification
1038+
1039+
* **Business Background**
1040+
1041+
Nuclear power plants require periodic safety tests (e.g., PT1RPA010 "Safety Injection Logic Test with 1 RPA 601KC") to verify equipment integrity. These tests cause characteristic flow pattern changes. The control system must identify these patterns to detect anomalies and ensure equipment safety.
1042+
1043+
* **Data Structure**
1044+
1045+
Sensor table contains these core fields:
1046+
1047+
| **ColumnName** | DataType | Category | Comment |
1048+
| ---------------------- | ----------- | ---------- | ------------------------ |
1049+
| time | TIMESTAMP | TIME | Data collection timestamp |
1050+
| pipe\_id | STRING | TAG | Pipe ID (partition key) |
1051+
| pressure | DOUBLE | FIELD | Pipe pressure |
1052+
| flow\_rate | DOUBLE | FIELD | Pipe flow rate (key metric) |
1053+
1054+
* **Business Requirements**
1055+
1056+
Identify PT1RPA010 flow pattern: Normal flow → Continuous decline → Extremely low flow (<0.5) → Continuous recovery → Normal flow. Extract core metrics:
1057+
1058+
* Pattern start time (initial normal flow timestamp)
1059+
* Pattern end time (recovered normal flow timestamp)
1060+
* Extremely low phase start/end times
1061+
* Minimum flow rate during extremely low phase
1062+
1063+
![](/img/pattern-query-flow.png)
1064+
1065+
* **Implementation Method**
1066+
1067+
```SQL
1068+
SELECT * FROM sensor MATCH_RECOGNIZE(
1069+
PARTITION BY pipe_id -- Partition by pipe ID
1070+
ORDER BY time -- Chronological ordering
1071+
MEASURES
1072+
A.time AS start_ts, -- Pattern start timestamp
1073+
E.time AS end_ts, -- Pattern end timestamp
1074+
FIRST(C.time) AS low_start_ts, -- Extremely low phase start
1075+
LAST(C.time) AS low_end_ts, -- Extremely low phase end
1076+
MIN(C.flow_rate) AS min_low_flow -- Minimum flow during low phase
1077+
ONE ROW PER MATCH -- Output one row per match
1078+
PATTERN(A B+? C+ D+? E) -- Match normal→decline→extremely low→recovery→normal
1079+
DEFINE
1080+
A AS flow_rate BETWEEN 2 AND 2.5, -- Initial normal flow
1081+
B AS flow_rate < PREV(B.flow_rate), -- Continuous decline
1082+
C AS flow_rate < 0.5, -- Extremely low threshold
1083+
D AS flow_rate > PREV(D.flow_rate), -- Continuous recovery
1084+
E AS flow_rate BETWEEN 2 AND 2.5 -- Normal recovery
1085+
);
1086+
```
1087+
1088+
### 4.3 Extreme Operational Gust (Sombrero Wind) Identification
1089+
1090+
* **Business Background**
1091+
1092+
In wind power generation, "extreme operational gusts (sombrero wind)" are short-duration (≈10s) sinusoidal gusts with prominent peaks that can cause physical turbine damage. Identifying these gusts and calculating their frequency helps assess turbine damage risks and guide maintenance.
1093+
1094+
* **Data Structure**
1095+
1096+
Turbine sensor table contains:
1097+
1098+
| **ColumnName** | DataType | Category | Comment |
1099+
| ---------------------- | ----------- | ---------- | ------------------------ |
1100+
| time | TIMESTAMP | TIME | Wind speed timestamp |
1101+
| speed | DOUBLE | FIELD | Wind speed (key metric) |
1102+
1103+
* **Business Requirements**
1104+
1105+
Identify sombrero wind pattern: Gradual speed decline → Sharp increase → Sharp decrease → Gradual recovery to initial value (≈10s total). Primary goal: count gust occurrences for risk assessment.
1106+
1107+
![](/img/pattern-query-speed.png)
1108+
1109+
* **Implementation Method**
1110+
1111+
```SQL
1112+
SELECT COUNT(*) -- Count extreme gust occurrences
1113+
FROM sensor
1114+
MATCH_RECOGNIZE(
1115+
ORDER BY time -- Chronological ordering
1116+
MEASURES
1117+
FIRST(B.time) AS ts_s, -- Gust start timestamp
1118+
LAST(D.time) AS ts_e -- Gust end timestamp
1119+
PATTERN (B+ R+? F+? D+? E) -- Match sombrero wind pattern
1120+
DEFINE
1121+
-- Phase B: Gradual decline, initial speed>9, delta<2.5
1122+
B AS speed <= AVG(B.speed)
1123+
AND FIRST(B.speed) > 9
1124+
AND (FIRST(B.speed) - LAST(B.speed)) < 2.5,
1125+
-- Phase R: Sharp increase (above phase average)
1126+
R AS speed >= AVG(R.speed),
1127+
-- Phase F: Sharp decrease, peak>16 (crest threshold)
1128+
F AS speed <= AVG(F.speed)
1129+
AND MAX(F.speed) > 16,
1130+
-- Phase D: Gradual recovery, delta<2.5
1131+
D AS speed >= AVG(D.speed)
1132+
AND (LAST(D.speed) - FIRST(D.speed)) < 2.5,
1133+
-- Phase E: Recovery to ±0.2 of initial value, total duration <11s
1134+
E AS speed - FIRST(B.speed) BETWEEN -0.2 AND 0.2
1135+
AND time - FIRST(B.time) < 11
1136+
);
1137+
```

0 commit comments

Comments
 (0)