@@ -58,6 +58,20 @@ def download_dataset(args):
5858def install_database (args ):
5959 metadata_dir = os .path .join (SPARK_DIR , "spark-4.0.3-bin-hadoop3" , "metastore_db" )
6060 database_dir = os .path .join (args .warehouse_dir , f"{ args .dataset_name .lower ()} .db" )
61+
62+ # Require both: a half-present pair yields "Table or view not found".
63+ if getattr (args , "skip_datagen" , 0 ):
64+ if os .path .exists (metadata_dir ) and os .path .exists (database_dir ):
65+ print (
66+ f"skip-datagen: reusing existing warehouse at { database_dir } "
67+ f"and metastore at { metadata_dir } "
68+ )
69+ return
70+ print (
71+ "skip-datagen requested but warehouse or metastore is missing; "
72+ "building the database this run"
73+ )
74+
6175 if os .path .exists (metadata_dir ):
6276 print ("Removing stale metastore_db to ensure tables are recreated" )
6377 shutil .rmtree (metadata_dir )
@@ -457,6 +471,14 @@ def init_parser():
457471 default = 0 ,
458472 help = "sanity check for total read and write IOPS" ,
459473 )
474+ run_parser .add_argument (
475+ "--skip-datagen" ,
476+ type = int ,
477+ default = 0 ,
478+ choices = [0 , 1 ],
479+ help = "reuse an existing warehouse and metastore instead of rebuilding "
480+ "them. Falls back to building if either is missing." ,
481+ )
460482 run_parser .add_argument ("--real" , action = "store_true" , help = "for real" )
461483 setup_parser .set_defaults (func = setup )
462484 run_parser .set_defaults (func = run )
0 commit comments