1
- from presto_utils import execute_cluster_call
1
+ from presto_utils import execute_presto_query
2
2
import argparse
3
3
import sys
4
4
5
5
def clean_directory_list_cache (hostname , username , password , catalog_name ):
6
6
query = "CALL " + catalog_name + ".system.invalidate_directory_list_cache()"
7
- return execute_cluster_call (hostname , username , password , catalog_name , query )
7
+ return execute_presto_query (hostname , username , password , catalog_name , query )
8
8
9
9
def clean_metastore_cache (hostname , username , password , catalog_name ):
10
10
query = "CALL " + catalog_name + ".system.invalidate_metastore_cache()"
11
- return execute_cluster_call (hostname , username , password , catalog_name , query )
11
+ return execute_presto_query (hostname , username , password , catalog_name , query )
12
+
13
+ def clean_statistics_file_cache (hostname , username , password , catalog_name ):
14
+ query = "CALL " + catalog_name + ".system.invalidate_statistics_file_cache()"
15
+ return execute_presto_query (hostname , username , password , catalog_name , query )
16
+
17
+ def clean_manifest_file_cache (hostname , username , password , catalog_name ):
18
+ query = "CALL " + catalog_name + ".system.invalidate_manifest_file_cache()"
19
+ return execute_presto_query (hostname , username , password , catalog_name , query )
12
20
13
21
if __name__ == "__main__" :
14
22
parser = argparse .ArgumentParser (description = 'Connect to PrestoDB' )
@@ -18,13 +26,18 @@ def clean_metastore_cache(hostname, username, password, catalog_name):
18
26
19
27
args = parser .parse_args ()
20
28
21
- catalog_list = ["hive" ]
22
- is_list_cache_cleanup_enabled = True
23
- is_metadata_cache_cleanup_enabled = True
29
+ hive_catalog_list = ["hive" ]
30
+ iceberg_catalog_list = ["iceberg" ]
31
+
32
+ # coordinator cache
33
+ is_list_cache_cleanup_enabled = True #for hive
34
+ is_metadata_cache_cleanup_enabled = True #for hive
35
+ is_statistics_file_cache_cleanup_enabled = True #for iceberg
36
+ is_manifest_file_cache_cleanup_enabled = True #for iceberg
24
37
25
38
# Directory list cache clean up
26
39
if is_list_cache_cleanup_enabled :
27
- for catalog_name in catalog_list :
40
+ for catalog_name in hive_catalog_list :
28
41
print ("Cleaning up directory list cache for " , catalog_name )
29
42
rows = clean_directory_list_cache (args .host , args .username , args .password , catalog_name )
30
43
print ("directory_list_cache_cleanup_query Query Result: " , rows )
@@ -36,7 +49,7 @@ def clean_metastore_cache(hostname, username, password, catalog_name):
36
49
37
50
# Metadata cache clean up
38
51
if is_metadata_cache_cleanup_enabled :
39
- for catalog_name in catalog_list :
52
+ for catalog_name in hive_catalog_list :
40
53
print ("Cleaning up metadata cache for " , catalog_name )
41
54
rows = clean_metastore_cache (args .host , args .username , args .password , catalog_name )
42
55
print ("metastore_cache_cleanup_query Query Result: " , rows )
@@ -45,3 +58,27 @@ def clean_metastore_cache(hostname, username, password, catalog_name):
45
58
else :
46
59
print ("Metastore cache clean up is failed for " , catalog_name )
47
60
sys .exit (1 )
61
+
62
+ # Statistics file cache clean up
63
+ if is_statistics_file_cache_cleanup_enabled :
64
+ for catalog_name in iceberg_catalog_list :
65
+ print ("Cleaning up statistics file cache for " , catalog_name )
66
+ rows = clean_statistics_file_cache (args .host , args .username , args .password , catalog_name )
67
+ print ("statistics_file_cache_cleanup_query Query Result: " , rows )
68
+ if rows [0 ][0 ] == True :
69
+ print ("Statistics file cache clean up is successful for " , catalog_name )
70
+ else :
71
+ print ("Statistics file cache clean up is failed for " , catalog_name )
72
+ sys .exit (1 )
73
+
74
+ # Manifest file cache clean up
75
+ if is_manifest_file_cache_cleanup_enabled :
76
+ for catalog_name in iceberg_catalog_list :
77
+ print ("Cleaning up manifest file cache for " , catalog_name )
78
+ rows = clean_manifest_file_cache (args .host , args .username , args .password , catalog_name )
79
+ print ("manifest_file_cache_cleanup_query Query Result: " , rows )
80
+ if rows [0 ][0 ] == True :
81
+ print ("Manifest file cache clean up is successful for " , catalog_name )
82
+ else :
83
+ print ("Manifest file cache clean up is failed for " , catalog_name )
84
+ sys .exit (1 )
0 commit comments