Q65 — AWS DEA-C01 Ch.1
Question 65 of 100 | ← Chapter 1
A data engineer creates an AWS Glue Data Catalog table by using an AWS Glue crawler that is named Orders. The data engineer wants to add the following new partitions: s3://transactions/orders/order_date=2023-01-01 s3://transactions/orders/order_date=2023-01-02 The data engineer must edit the metadata to include the new partitions in the table without scanning all the folders and files in the location of the table. Which data definition language (DDL) statement should the data engineer use in Amazon Athena?
- A. ALTER TABLE Orders ADD PARTITION(order_date=’2023-01-01’) LOCATION ‘s3://transactions/orders/order_date=2023-01-01’; ALTER TABLE Orders ADD PARTITION(order_date=’2023-01-02’) LOCATION ‘s3://transactions/orders/order_date=2023-01-02’; ✓
- B. MSCK REPAIR TABLE Orders;
- C. REPAIR TABLE Orders;
- D. ALTER TABLE Orders MODIFY PARTITION(order_date=’2023-01-01’) LOCATION ‘s3://transactions/orders/2023-01-01’; ALTER TABLE Orders MODIFY PARTITION(order_date=’2023-01-02’) LOCATION ‘s3://transactions/orders/2023-01-02’;
Correct Answer: A. ALTER TABLE Orders ADD PARTITION(order_date=’2023-01-01’) LOCATION ‘s3://transactions/orders/order_date=2023-01-01’; ALTER TABLE Orders ADD PARTITION(order_date=’2023-01-02’) LOCATION ‘s3://transactions/orders/order_date=2023-01-02’;
Explanation
在AmazonAthena中,要手动添加分区到已经存在的表中,需要使用ALTERTABLE语句来添加新的分区。选项A中的DDL语句正确地使用了ALTERTABLE命令来添加两个新的分区,每个分区都指定了对应的order_date和Location。这是符合题目要求的正确做法。选项B的MSCKREPAIRTABLE命令用于同步元数据和数据源之间的分区信息,但它不会添加新的分区。选项C的REPAIRTABLE命令不是AmazonAthena中的有效命令。选项D尝试使用MODIFYPARTITION,但这是用于修改已存在的分区,而不是添加新的分区。因此,选项A是正确的答案。