CHANGE: Added auto-tests with Docker.
This commit is contained in:
31
zabbix-tests/partitioning/find_tables.py
Normal file
31
zabbix-tests/partitioning/find_tables.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import re
|
||||
|
||||
def get_partitionable_tables(schema_path):
|
||||
with open(schema_path, 'r', encoding='utf-8', errors='ignore') as f:
|
||||
content = f.read()
|
||||
|
||||
# Split into CREATE TABLE statements
|
||||
tables = content.split('CREATE TABLE')
|
||||
valid_tables = []
|
||||
|
||||
for table_def in tables:
|
||||
# Extract table name
|
||||
name_match = re.search(r'`(\w+)`', table_def)
|
||||
if not name_match:
|
||||
continue
|
||||
table_name = name_match.group(1)
|
||||
|
||||
# Check for PRIMARY KEY definition
|
||||
pk_match = re.search(r'PRIMARY KEY \((.*?)\)', table_def, re.DOTALL)
|
||||
if pk_match:
|
||||
pk_cols = pk_match.group(1)
|
||||
if 'clock' in pk_cols:
|
||||
valid_tables.append(table_name)
|
||||
|
||||
return valid_tables
|
||||
|
||||
if __name__ == '__main__':
|
||||
tables = get_partitionable_tables('/opt/git/Zabbix/partitioning/70-schema-mysql.txt')
|
||||
print("Partitionable tables (PK contains 'clock'):")
|
||||
for t in tables:
|
||||
print(f" - {t}")
|
||||
Reference in New Issue
Block a user