The MSCK REPAIR TABLE SYNC_DIR statement is used to automatically synchronize partition information from a specified Object Storage Service (OSS) folder. Scenarios:

  • If a table has a large number of partitions, it takes a long time to synchronize an entire table by running the MSCK statement. In this case, you can execute the MSCK REPAIR TABLE SYNC_DIR statement to synchronize all the partition information from a specific folder.
  • After the MSCK statement is executed, the partition information of all OSS folders is synchronized. If you do not want to synchronize the partition information from some OSS folders, you can execute the MSCK REPAIR TABLE SYNC_DIR statement to synchronize the partition information from the specified OSS folders.
MSCK REPAIR TABLE tbl1 SYNC_DIR 'oss://${tbl_location}/${partition_path}'
  • Limits: The OSS folder following SYNC_DIR must be a subfolder of tbl_location and comply with the naming conventions for partitions.

Example

If a partitioned table has three partition keys, year, month, and day, all of the following statements can be executed:

​MSCK REPAIR TABLE tbl1 SYNC_DIR 'oss://${tbl_location}/' 
MSCK REPAIR TABLE tbl1 SYNC_DIR 'oss://${tbl_location}/year=XXX'
MSCK REPAIR TABLE tbl1 SYNC_DIR 'oss://${tbl_location}/year=XXX/month=mmm'
MSCK REPAIR TABLE tbl1 SYNC_DIR 'oss://${tbl_location}/year=XXX/month=mmm/day=ddd'​