Ngân hàng đề — AWS Certified Data Engineer Associate

Tìm thấy 867 câu.

Câu 861
A company stores Apache Parquet files in an Amazon S3 data lake. The data lake receives thousands of files from multiple sources every hour. The files range in size from 50 KB to 100 KB.

The company is evaluating the implementation of Apache Iceberg tables for the data lake. The company is using AWS Glue Data Catalog as part of the evaluation. The company needs a solution to optimize query performance in Iceberg. The solution must ensure that Iceberg table performance does not degrade when more files are added over time.

Which solution will meet these requirements?
  1. A Use an AWS Glue job to compact the files into a standard size of 512 MB at the end of each day. Run an AWS Glue crawler to update the Data Catalog.
  2. B Configure the Data Catalog to automatically compact the files every minute.
  3. C Configure Iceberg table properties to enable automatic compaction based on thresholds for file size and the number of files.
  4. D Implement a partition strategy in Amazon S3. Run an AWS Glue crawler to update the Data Catalog every 5 minutes.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi xoay quanh một công ty đang lưu trữ hàng nghìn file Apache Parquet (kích thước từ 50 KB đến 100 KB) trong Amazon S3 data lake, nhận file từ nhiều nguồn mỗi giờ. Họ đang đánh giá triển khai Apache Iceberg tables kết hợp AWS Glue Data Catalog để quản lý metadata. Yêu cầu chính là tối ưu hiệu suất truy vấn (query performance) cho Iceberg tables, đồng thời đảm bảo performance không suy giảm khi thêm nhiều file theo thời gian.

🛠️ Vấn đề cốt lõi: Với file nhỏ (small files problem), số lượng metadata lớn dẫn đến query chậm (scan nhiều file). Giải pháp cần compact/merge small files thành file lớn hơn một cách tự động, hiệu quả, phù hợp với Iceberg trên AWS (phiên bản mới nhất 2026 hỗ trợ Iceberg 1.5+ qua AWS Glue 4.0+ và S3 Table Format).

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Configure Iceberg table properties to enable automatic compaction based on thresholds for file size and the number of files.

Lý do 🟢: Apache Iceberg (tích hợp AWS Glue Catalog) hỗ trợ tự động compaction qua table properties như write.target-file-size-bytes (mục tiêu kích thước file, ví dụ 512MB), write.metadata.compression-codec, và rewriteDataFiles procedure với thresholds (số file nhỏ, kích thước). Điều này tự động merge small files khi vượt ngưỡng (file size < threshold hoặc số file > threshold per partition), không cần job thủ công, đảm bảo query nhanh (ít metadata) và scale tốt khi thêm file liên tục. Phù hợp nhất với yêu cầu "performance không degrade over time". AWS Glue Spark jobs (3.0+) kích hoạt tự động compaction trong Iceberg tables trên S3.

🔍 Giải thích tất cả các phương án (đúng/sai)

  • ❌ Phương án SAI: Use an AWS Glue job to compact the files into a standard size of 512 MB at the end of each day. Run an AWS Glue crawler to update the Data Catalog.
    Giải thích sai ❌: Cách này thủ công và không hiệu quả – chạy job hàng ngày chỉ compact cuối ngày, dẫn đến small files tích tụ suốt ngày gây query chậm tạm thời. Crawler chỉ update metadata, không giải quyết root cause (Iceberg cần snapshot/merge tự động). Không scale với "thousands of files every hour" và vi phạm yêu cầu "không degrade over time".

  • ❌ Phương án SAI: Configure the Data Catalog to automatically compact the files every minute.
    Giải thích sai ❌: AWS Glue Data Catalog không hỗ trợ auto-compact every minute (Catalog chỉ metadata, không xử lý file compaction). Compaction là tính năng của Iceberg engine, không phải Catalog. Chạy every minute gây overhead cao (CPU/IO tốn kém), không dựa thresholds, và không tồn tại tính năng này trong AWS Glue (cập nhật 2026).

  • ✅ Phương án ĐÚNG: Configure Iceberg table properties to enable automatic compaction based on thresholds for file size and the number of files.
    Giải thích đúng 🟢: Như đã phân tích ở đáp án đúng – tự động, dựa thresholds (ví dụ: write.target-file-size-bytes=536870912 cho 512MB, rewrite.delete.file-threshold=5), Iceberg tự trigger compaction trong writes/queries. AWS Glue hỗ trợ qua CREATE TABLE properties hoặc ALTER TABLE SET PROPERTIES. Tối ưu nhất, scale tốt, không degrade performance.

  • ❌ Phương án SAI: Implement a partition strategy in Amazon S3. Run an AWS Glue crawler to update the Data Catalog every 5 minutes.
    Giải thích sai ❌: Partition (ví dụ: by date/hour) giúp pruning nhưng không giải quyết small files (vẫn nhiều file nhỏ per partition gây scan chậm). Crawler every 5 phút overhead cao (hàng nghìn files), không tự động merge, và Iceberg dùng hidden partitioning tốt hơn S3 prefix thủ công. Không đáp ứng "optimize Iceberg table performance".

🛠️ Khuyến nghị thực tế: Sử dụng AWS Glue ETL jobs với Iceberg API (table.rewriteFiles()) kết hợp properties để test. Theo dõi metrics qua Amazon Athena/CloudWatch cho query time giảm 50-80% sau compaction! 🚀

Câu 862
Two data engineering teams use separate AWS accounts. Both teams request access to the same datashare in an Amazon Redshift cluster that is in a third AWS account. The datashare is named salesshare.

A data engineer must use the Amazon Redshift SQL interface to grant both data engineering teams' access to the datashare.

Which command or commands will meet this requirement?
  1. A GRANT USAGE ON DATASHARE salesshare TO ACCOUNTS ‘’ AND ‘’;
  2. B GRANT USAGE ON DATASHARE salesshare TO NAMESPACES ‘’ AND ‘’;
  3. C GRANT USAGE ON DATASHARE salesshare TO ACCOUNT ‘’;
    GRANT USAGE ON DATASHARE salesshare TO ACCOUNT ‘’;
  4. D GRANT USAGE ON DATASHARE salesshare TO NAMESPACE ‘’;
    GRANT USAGE ON DATASHARE salesshare TO NAMESPACE ‘’;
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi tập trung vào tính năng Amazon Redshift Data Sharing (chia sẻ dữ liệu cross-account), một phần của AWS Redshift RA3 clusters hoặc serverless. Cụ thể:

  • Có 3 AWS accounts: Account A (chứa Redshift cluster với datashare "salesshare"), Account 1 và Account 2 (hai đội data engineering muốn truy cập).
  • Yêu cầu: Data engineer ở Account A sử dụng SQL interface của Redshift để cấp quyền USAGE cho cả hai account consumer truy cập datashare.
  • Mục tiêu: Sử dụng lệnh SQL chính xác để grant access cross-account, không cần replicate dữ liệu, tiết kiệm chi phí và thời gian.
    ✅ Ngữ cảnh cập nhật 2026: Redshift hỗ trợ datasharing đến hàng nghìn consumers, với namespace identifier là AWS account ID (12 chữ số). Không hỗ trợ grant nhiều account cùng lúc bằng AND.

✅ Đáp án đúng: Phương án D

GRANT USAGE ON DATASHARE salesshare TO NAMESPACE ‘<account 1 id>’;
GRANT USAGE ON DATASHARE salesshare TO NAMESPACE ‘<account 2 id>’;

Lý do chọn:

  • Đây là cú pháp chính xác theo AWS Redshift SQL cho cross-account datasharing.
  • Từ khóa NAMESPACE chỉ định AWS account ID của consumer (ví dụ: '123456789012').
  • Phải dùng hai lệnh riêng biệt vì Redshift không hỗ trợ grant multiple namespaces cùng lúc bằng AND.
  • Sau khi grant, consumer accounts chỉ cần CREATE DATABASE từ datashare để truy cập.
    🛠️ Quy trình thực tế: Producer grant → Consumer associate datashare → Query dữ liệu live mà không copy.

❌ Phân tích tất cả các phương án

  • Phương án A (SAI):

    GRANT USAGE ON DATASHARE salesshare TO ACCOUNTS ‘<account 1 id>’ AND ‘<account 2 id>’;
    

    ❌ Lý do sai: Từ khóa ACCOUNTS (số nhiều) với AND không tồn tại trong Redshift SQL. Redshift chỉ dùng NAMESPACE cho cross-account, và không hỗ trợ multiple targets trong một lệnh.

  • Phương án B (SAI):

    GRANT USAGE ON DATASHARE salesshare TO NAMESPACES ‘<account 1 id>’ AND ‘<account 2 id>’;
    

    ❌ Lý do sai: NAMESPACES (số nhiều) với AND không được hỗ trợ. Phải dùng NAMESPACE (số ít) và lệnh riêng cho từng account ID. Lỗi syntax sẽ báo "invalid object name".

  • Phương án C (SAI):

    GRANT USAGE ON DATASHARE salesshare TO ACCOUNT ‘<account 1 id>’;
    GRANT USAGE ON DATASHARE salesshare TO ACCOUNT ‘<account 2 id>’;
    

    ❌ Lý do sai: Từ khóa ACCOUNT không đúng cho datashare cross-account. Redshift yêu cầu NAMESPACE để chỉ định consumer account. ACCOUNT chỉ dùng nội bộ hoặc IAM roles, không áp dụng datasharing.

📘 Tài liệu tham khảo (AWS cập nhật 2026)

  • AWS Redshift Documentation: Sharing data between clusters in Amazon Redshift – Chi tiết cú pháp GRANT USAGE ON DATASHARE.
  • SQL Reference: GRANT command – Xác nhận NAMESPACE cho cross-account.
  • Blog AWS: Announcing named datashares – Hướng dẫn multi-consumer grants.
    🧩 Lưu ý: Kiểm tra qua AWS Console > Redshift > Datashares để verify grants. Nếu serverless Redshift, namespace có thể là 'account:region:serverless-namespace'.
Câu 863
A manufacturing company uses AWS Glue jobs to process IoT sensor data to generate predictive maintenance models. A data engineer needs to implement automated data quality checks to identify temperature readings that are outside the expected range of -50°C to 150°C. The data quality checks must also identify records that are missing timestamp values.

The data engineer needs a solution that requires minimal coding and can automatically flag the specified issues.

Which solution will meet these requirements?
  1. A Create an AWS Glue DataBrew project to profile the sensor data Define completeness rules for timestamps. Set up numeric range validation for temperature values.
  2. B Use AWS Glue’s Data Quality rules and machine learning (ML)-based anomaly detection to identify missing timestamps and to detect temperature anomalies.
  3. C Create an AWS Lambda function to scan the sensor data files to validate temperature ranges. Use AWS Glue Data Catalog tables to check timestamp completeness.
  4. D Create an AWS Glue DynamicFrame that uses a custom data quality operator to profile the sensor data. Use Amazon SageMaker Data Wrangler transforms to validate timestamps and temperature ranges.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào một công ty sản xuất sử dụng AWS Glue jobs để xử lý dữ liệu từ cảm biến IoT (dữ liệu nhiệt độ và timestamp), nhằm tạo mô hình bảo trì dự đoán (predictive maintenance). Data engineer cần triển khai kiểm tra chất lượng dữ liệu tự động với hai yêu cầu chính:

  • Phát hiện giá trị nhiệt độ ngoài khoảng -50°C đến 150°C (numeric range validation).
  • Phát hiện record thiếu timestamp (completeness check).
  • Giải pháp phải tối thiểu code (minimal coding) và tự động flag vấn đề (tự động đánh dấu lỗi).

📘 Bối cảnh AWS cập nhật đến 2026: AWS Glue DataBrew (ra mắt 2021, cập nhật liên tục) là công cụ no-code/low-code lý tưởng cho data profiling và quality checks. AWS Glue Data Quality (DQ) cũng hỗ trợ rules từ 2022, nhưng DataBrew vượt trội về giao diện visual cho các rules đơn giản như range và completeness mà không cần viết code.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Create an AWS Glue DataBrew project to profile the sensor data. Define completeness rules for timestamps. Set up numeric range validation for temperature values.

Lý do 🛠️:

  • AWS Glue DataBrew cho phép tạo project visual để profile dữ liệu mà không cần code, chỉ drag-and-drop rules.
  • Completeness rules tự động kiểm tra missing values cho cột timestamp (hỗ trợ % completeness).
  • Numeric range validation chính xác flag nhiệt độ ngoài -50°C đến 150°C.
  • Tự động generate reports và flags, tích hợp Glue jobs. Đây là giải pháp minimal coding nhất, phù hợp yêu cầu.

📋 Giải thích tất cả các phương án (đúng/sai)

  • ✅ Create an AWS Glue DataBrew project to profile the sensor data. Define completeness rules for timestamps. Set up numeric range validation for temperature values.
    🟢 Đúng vì: DataBrew là công cụ no-code visual data preparation (cập nhật 2025 với enhanced profiling). Profile data tự động scan schema/stats, rules completeness kiểm tra missing timestamp (ví dụ: rule "Timestamp completeness > 99%"), numeric range rule trực tiếp set min/max cho temperature và flag outliers. Tích hợp seamless với Glue jobs, minimal coding (chỉ config UI). Hoàn hảo cho IoT data quality.

  • ❌ Use AWS Glue’s Data Quality rules and machine learning (ML)-based anomaly detection to identify missing timestamps and to detect temperature anomalies.
    🔴 Sai vì: AWS Glue Data Quality (DQ) rules (từ re:Invent 2022, cập nhật ML transforms 2024) hỗ trợ completeness cho missing timestamps và ML anomaly cho numeric outliers (như temperature). Tuy nhiên, cần viết code rules SQL-like (ví dụ: completeness(timestamp) > 0.99), không "minimal coding". ML anomaly detection tốt cho anomalies nhưng không chính xác/đơn giản như range validation cố định (-50/150°C), và không visual như DataBrew.

  • ❌ Create an AWS Lambda function to scan the sensor data files to validate temperature ranges. Use AWS Glue Data Catalog tables to check timestamp completeness.
    🔴 Sai vì: Lambda yêu cầu viết code đầy đủ (Python/Script scan S3 files, query Glue Catalog cho completeness via Athena/Glue APIs), không tự động/minimal coding. Scan files thủ công kém hiệu quả cho large IoT data, thiếu profiling tự động và visual flags. Glue Catalog chỉ metadata, không trực tiếp quality checks.

  • ❌ Create an AWS Glue DynamicFrame that uses a custom data quality operator to profile the sensor data. Use Amazon SageMaker Data Wrangler transforms to validate timestamps and temperature ranges.
    🔴 Sai vì: DynamicFrame trong Glue cần code PySpark custom operator (ví dụ: resolveChoice với UDF cho quality), không minimal coding. SageMaker Data Wrangler (visual transforms từ 2021, cập nhật 2025) tốt cho ML prep nhưng tập trung data wrangling/ML flows, không chuyên quality checks tự động như range/completeness. Kết hợp hai tool phức tạp, không seamless cho Glue jobs.

📚 Tài liệu tham khảo (AWS docs cập nhật 2026)

Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần thêm ví dụ code/sample project, hỏi nhé!

Câu 864
A company generates yearly financial statements for customers and stores the statements in an Amazon S3 bucket. Customers rarely access the documents after 1 week. The company must retain the statements for 7 years. The statements must remain readily accessible for customers.

Which solution will meet these requirements in the MOST cost-effective way?
  1. A Create an S3 Lifecycle rule to transition objects to S3 Glacier Deep Archive after 7 days. Expire the objects after 7 years.
  2. B Set the S3 bucket to use S3 Intelligent-Tiering when new objects are uploaded. Set objects to expire after 7 years.
  3. C Create an S3 Lifecycle rule to transition objects to S3 Glacier Instant Retrieval after 7 days. Expire the objects after 7 years.
  4. D Set the S3 bucket to use S3 Glacier Instant Retrieval when new objects are uploaded. Create an AWS Lambda function that runs daily to delete any objects that are older than 7 years.
Xem giải thích

🧩 Giải thích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào việc quản lý lưu trữ dữ liệu trên Amazon S3 một cách tiết kiệm chi phí nhất (MOST cost-effective) cho các báo cáo tài chính hàng năm của khách hàng. Các yêu cầu chính bao gồm:

  • 📤 Dữ liệu được lưu trong S3 bucket.
  • 👥 Khách hàng hiếm khi truy cập sau 1 tuần (7 ngày).
  • ⏳ Phải giữ dữ liệu ít nhất 7 năm.
  • ⚡ Dữ liệu phải dễ dàng truy cập (readily accessible) cho khách hàng bất cứ lúc nào (không chấp nhận thời gian retrieval lâu).
  • 🛡️ Mục tiêu: Giảm chi phí lưu trữ lâu dài mà vẫn đảm bảo tính sẵn sàng cao.

Vấn đề cốt lõi là chọn lớp lưu trữ S3 (Storage Class) phù hợp để chuyển dữ liệu sau 7 ngày sang lớp rẻ hơn nhưng vẫn truy cập tức thì, kết hợp với chính sách Lifecycle để xóa (expire) sau 7 năm. AWS cập nhật đến 2026 nhấn mạnh S3 Glacier Instant Retrieval là lớp lý tưởng cho dữ liệu ít truy cập nhưng cần millisecond retrieval (từ 2023, tối ưu hóa chi phí thấp hơn Standard/Infrequent Access).

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Create an S3 Lifecycle rule to transition objects to S3 Glacier Instant Retrieval after 7 days. Expire the objects after 7 years.

Lý do chi tiết:

  • 🛠️ Sử dụng S3 Lifecycle rule để tự động chuyển (transition) objects sang S3 Glacier Instant Retrieval sau 7 ngày – lớp này có chi phí lưu trữ cực thấp (~1/4 so với S3 Infrequent Access), phù hợp dữ liệu hiếm truy cập.
  • ⚡ Instant Retrieval đảm bảo truy cập ngay lập tức (milliseconds) qua GET/SELECT, đáp ứng "readily accessible" mà không phí retrieval cao như các lớp Archive khác.
  • 🗑️ Expire sau 7 năm tự động xóa dữ liệu, tránh chi phí lưu trữ thừa.
  • 💰 Cost-effective nhất: Không phí monitoring (như Intelligent-Tiering), không Lambda thủ công, tối ưu hóa theo best practices AWS 2026 (S3 Lifecycle hỗ trợ Instant Retrieval đầy đủ).
  • 📈 Tiết kiệm: Lưu trữ Glacier Instant Retrieval rẻ hơn 95% so với Standard cho dữ liệu dài hạn.

📋 Phân tích tất cả các phương án (Đúng/Sai)

  • ❌ Phương án SAI: Create an S3 Lifecycle rule to transition objects to S3 Glacier Deep Archive after 7 days. Expire the objects after 7 years.

    • Giải thích: S3 Glacier Deep Archive có chi phí lưu trữ rẻ nhất nhưng thời gian retrieval lên đến 12 giờ (standard) hoặc 48 giờ (bulk), KHÔNG đáp ứng "readily accessible" vì khách hàng cần truy cập nhanh. Dù expire đúng, nhưng vi phạm yêu cầu sẵn sàng dữ liệu. Không cost-effective vì retrieval phí cao nếu cần dùng.
  • ❌ Phương án SAI: Set the S3 bucket to use S3 Intelligent-Tiering when new objects are uploaded. Set objects to expire after 7 years.

    • Giải thích: S3 Intelligent-Tiering tự động di chuyển giữa các lớp (Frequent Access, Infrequent, Archive Instant Retrieval, v.v.) dựa trên truy cập, nhưng có phí monitoring hàng tháng ($0.0025/1.000 objects) làm tăng chi phí không cần thiết cho dữ liệu dự đoán ít truy cập sau 7 ngày. Bucket không hỗ trợ set default Intelligent-Tiering khi upload (cần tag/policy riêng), và expire phải dùng Lifecycle rule, không phải bucket setting trực tiếp. Không tối ưu cost so với Lifecycle đơn giản.
  • ✅ Phương án ĐÚNG: Create an S3 Lifecycle rule to transition objects to S3 Glacier Instant Retrieval after 7 days. Expire the objects after 7 years.

    • Giải thích: Như phần trên, đây là giải pháp hoàn hảo: Transition chính xác sau 7 ngày vào lớp Glacier Instant Retrieval (millisecond access, chi phí thấp ~$0.0004/GB/tháng theo giá 2026), expire tự động. Không phí thừa, dễ triển khai qua Console/CLI/Terraform, phù hợp DevOps best practices.
  • ❌ Phương án SAI: Set the S3 bucket to use S3 Glacier Instant Retrieval when new objects are uploaded. Create an AWS Lambda function that runs daily to delete any objects that are older than 7 years.

    • Giải thích: S3 bucket không hỗ trợ set default storage class là Glacier Instant Retrieval khi upload (mặc định là Standard; cần Lifecycle hoặc PUT với class chỉ định, phức tạp cho mọi upload). Lambda chạy daily để delete tốn kém (chi phí invocation, EventBridge, code maintain), không tận dụng Lifecycle expire tự động (free). Vi phạm cost-effective vì thêm operational overhead và chi phí Lambda (~$0.20/1M requests).

📘 Tài liệu tham khảo (AWS cập nhật 2026)

Giải pháp này đảm bảo tuân thủ DevOps Professional với automation và cost optimization! 🚀

Câu 865
A data engineer is writing a query to join two tables in Amazon Athena. The data engineer needs to choose the correct join order for the tables to optimize query performance.

Which solution will meet these requirements?
  1. A Specify the smaller table on the left side of the join and the larger table on the right side of the join.
  2. B Specify the larger table on the left side of the join and the smaller table on the right side of the join.
  3. C Use AWS Glue to pre-process the tables before performing the join.
  4. D Use table statistics to automatically determine the join order.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi tập trung vào việc tối ưu hóa hiệu suất truy vấn JOIN trong Amazon Athena – một dịch vụ serverless query cho dữ liệu S3 sử dụng engine Presto/Trino (cập nhật đến năm 2026, Athena hỗ trợ Trino phiên bản mới nhất với các cải tiến optimizer).

📝 Chi tiết câu hỏi: Một data engineer đang viết truy vấn để JOIN hai bảng trong Athena. Yêu cầu chọn thứ tự JOIN đúng (join order) giữa hai bảng để tối ưu performance. Trong Athena, JOIN thường sử dụng hash join (mặc định cho INNER JOIN), nơi engine xây dựng hash table từ bảng bên phải (right side - build side) và quét/probe từ bảng bên trái (left side - probe side). Để tránh OOM (out-of-memory) và giảm thời gian, cần đặt bảng nhỏ hơn bên phải (build hash tiết kiệm RAM) và bảng lớn hơn bên trái (scan lớn nhưng probe nhanh). Optimizer của Athena không luôn tự động reorder hoàn hảo nếu thiếu statistics đầy đủ, nên data engineer cần chỉ định thủ công.

🛠️ Lưu ý quan trọng: Theo best practices AWS (không thay đổi đến 2026), thứ tự này giúp giảm memory usage và tăng speed lên đến 10x cho dataset lớn.

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Specify the larger table on the left side of the join and the smaller table on the right side of the join.

Lý do 🏆:

  • Trong hash JOIN của Athena (Presto/Trino), engine xây hash table từ bảng right (nhỏ) để tiết kiệm bộ nhớ, rồi probe bằng bảng left (lớn). Đặt lớn left/nhỏ right giúp optimizer hiệu quả, giảm I/O và CPU. Nếu ngược lại, hash table lớn có thể gây spill-to-disk hoặc timeout. Đây là best practice chính thức từ AWS, đặc biệt khi tables không có statistics đầy đủ (ví dụ: thiếu AWS Glue table stats).

📋 Giải thích tất cả các phương án

Dưới đây là phân tích từng lựa chọn một cách chi tiết, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá ✅ (đúng) hoặc ❌ (sai), kèm lý do cụ thể dựa trên kiến thức AWS Athena cập nhật.

  • Specify the smaller table on the left side of the join and the larger table on the right side of the join.
    ❌ Sai. Đặt nhỏ left/lớn right buộc engine build hash table từ bảng lớn (right), dẫn đến memory overflow cao, spill disk chậm (performance kém 5-10x). Chỉ phù hợp nếu optimizer reorder tự động (hiếm khi), nhưng best practice khuyên ngược lại.

  • Specify the larger table on the left side of the join and the smaller table on the right side of the join.
    ✅ Đúng. Như giải thích trên: Lớn left (probe nhanh), nhỏ right (build hash tiết kiệm RAM). AWS docs khuyến nghị rõ ràng cho query lớn trên S3, giúp giảm cost và thời gian query.

  • Use AWS Glue to pre-process the tables before performing the join.
    ❌ Sai. AWS Glue dùng để ETL/crawl metadata (tạo table stats), nhưng không preprocess dữ liệu cho JOIN (chỉ partition/compact nếu cần). Preprocess bằng Glue Job tốn kém, chậm hơn JOIN trực tiếp trong Athena. Không giải quyết join order.

  • Use table statistics to automatically determine the join order.
    ❌ Sai. Athena có dùng table stats từ Glue Catalog để optimizer tự reorder (cost-based optimizer từ Trino 400+), nhưng không đảm bảo 100% (stats không đầy đủ hoặc query phức tạp). Best practice vẫn yêu cầu chỉ định thủ công cho hai bảng. Không phải giải pháp chính cho "choose the correct join order".

Câu 866
A data engineer needs a fully automated solution to check for new data in multiple databases and process data that the solution finds. The solution must run every hour. The solution must be compatible with Amazon RDS, Amazon DynamoDB, and Amazon OpenSearch Service. The solution must be able to process up to 10 MB of data at one time. The solution must be optimized for costs and operational overhead. The solution must have robust error handling capabilities.

Which solution will meet these requirements?
  1. A Use Amazon EventBridge to invoke AWS Step Functions every hour to deploy an AWS Lambda function to check for data. Configure Step Functions steps to process data that the Lambda function finds. Implement error handling in each state.
  2. B Use Amazon EventBridge to invoke an AWS Lambda function every hour to check for data. Configure the function to send a message to an Amazon Simple Queue Service (Amazon SQS) queue when the function finds new data. Use a second Lambda function to read the queue and perform the processing.
  3. C Configure an Apache Spark application to run on Amazon EMR to check for data. Implement error handling in the application. Use Amazon EventBridge to invoke the application every hour.
  4. D Use Amazon Managed Workflows for Apache Airflow (Amazon MWAA) to create a workflow that runs a directed acyclic graph (DAG) every hour to check for data. Configure the DAG to process identified data. Implement error handling in a Python operator.
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi mô tả yêu cầu xây dựng một giải pháp tự động hóa hoàn toàn (fully automated) cho data engineer, nhằm kiểm tra dữ liệu mới từ nhiều nguồn database khác nhau và xử lý dữ liệu tìm thấy. Các yêu cầu chính bao gồm:

  • Chạy định kỳ mỗi giờ (every hour).
  • Tương thích với Amazon RDS (SQL/NoSQL), Amazon DynamoDB (NoSQL), và Amazon OpenSearch Service (search/analytics).
  • Xử lý tối đa 10 MB dữ liệu mỗi lần (up to 10 MB at one time) – quy mô nhỏ, không cần big data tools.
  • Tối ưu chi phí (cost-optimized) và gánh nặng vận hành (operational overhead) – ưu tiên serverless, không quản lý infra.
  • Xử lý lỗi mạnh mẽ (robust error handling) – cần cơ chế retry, catch errors tự động.

Giải pháp phải serverless hoàn toàn, scalable, và sử dụng các dịch vụ AWS tích hợp tốt để tránh custom code phức tạp. Đây là chủ đề orchestration và ETL serverless trong AWS (cập nhật đến 2026, với Step Functions hỗ trợ Map State cho parallel processing và Express Workflows cho low-latency).

✅ Đáp án đúng

Use Amazon EventBridge to invoke AWS Step Functions every hour to deploy an AWS Lambda function to check for data. Configure Step Functions steps to process data that the Lambda function finds. Implement error handling in each state.

Lý do lựa chọn:

  • 🛠️ EventBridge làm scheduler định kỳ (cron-like) để trigger Step Functions mỗi giờ – serverless, chi phí thấp (~$1/million events).
  • AWS Step Functions là orchestrator lý tưởng cho workflow phức tạp: invoke Lambda để check data từ RDS/DynamoDB/OpenSearch (qua SDK integrations), sau đó process data qua các states (parallel/sequential). Hỗ trợ error handling built-in (Catch, Retry, Choice states) – robust hơn custom code.
  • Lambda xử lý 10MB dễ dàng (sync/async invoke), serverless, auto-scale, chi phí theo usage (~$0.20/1M requests).
  • ✅ Tối ưu hoàn hảo: Zero operational overhead (no servers), cost-effective cho small scale (pay-per-state), fully compatible với các DB qua Lambda. Không cần manage queues hay clusters. (Cập nhật 2026: Step Functions hỗ trợ Distributed Map cho large datasets, nhưng ở đây standard workflow đủ).

📋 Phân tích tất cả các phương án

  • ✅ Use Amazon EventBridge to invoke AWS Step Functions every hour to deploy an AWS Lambda function to check for data. Configure Step Functions steps to process data that the Lambda function finds. Implement error handling in each state.
    Đúng vì: Như giải thích trên – orchestration mạnh mẽ, error handling native (Retry lên đến 100 lần/state), serverless thuần, chi phí thấp (~$0.000025/state transition). Lý tưởng cho multi-DB integration qua Lambda tasks.

  • ❌ Use Amazon EventBridge to invoke an AWS Lambda function every hour to check for data. Configure the function to send a message to an Amazon Simple Queue Service (Amazon SQS) queue when the function finds new data. Use a second Lambda function to read the queue and perform the processing.
    Sai vì: Mặc dù serverless và EventBridge trigger tốt, nhưng dùng SQS + 2 Lambdas tạo operational overhead cao (manage queue DLQ, visibility timeout, scaling consumers). Error handling chỉ custom trong Lambda (Dead Letter Queue cơ bản), không robust bằng Step Functions states. Chi phí cao hơn do queue polling, không tối ưu cho 10MB simple workflow.

  • ❌ Configure an Apache Spark application to run on Amazon EMR to check for data. Implement error handling in the application. Use Amazon EventBridge to invoke the application every giờ.
    Sai vì: EMR Spark quá heavyweight cho 10MB data (cluster spin-up 5-10 phút/lần, chi phí ~$0.07/giờ/node). Operational overhead lớn (manage cluster lifecycle, auto-terminate), không cost-optimized cho hourly small jobs. Error handling chỉ app-level, không native AWS orchestration. Không phù hợp serverless requirements.

  • ❌ Use Amazon Managed Workflows for Apache Airflow (Amazon MWAA) to create a workflow that runs a directed acyclic graph (DAG) every hour to check for data. Configure the DAG to process identified data. Implement error handling in a Python operator.
    Sai vì: MWAA Airflow tốt cho complex ETL, nhưng overhead cao (managed nhưng cần VPC/EC2 environment, scheduler scaling thủ công, chi phí ~$0.49/giờ/metadata DB + workers). Error handling chỉ operator-level (custom Python), không robust/native như Step Functions. Không tối ưu cost/ops cho small-scale (10MB), hourly runs – Airflow phù hợp big data pipelines hơn.

📘 Tài liệu tham khảo

Giải pháp này đảm bảo serverless, scalable, và resilient! 🚀

Câu 867
A company uses Amazon Redshift for its data warehouse. A data engineer must query a table named orders.complete_orders_history, which contains 100 columns. The query must return all columns except columns named companyId and unique_system_id.

Which Amazon Redshift SQL statement will meet this requirement?
  1. A
    SELECT * EXCLUDE company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;

  2. B
    SELECT * 
    NOT IN company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;

  3. C
    SELECT * EXCEPT company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;

  4. D
    SELECT * 
    TRUNCATE company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;
Xem giải thích

🧩 Giải thích nội dung câu hỏi

Câu hỏi tập trung vào Amazon Redshift – dịch vụ data warehouse serverless của AWS, được thiết kế để xử lý dữ liệu lớn với hiệu suất cao. Một data engineer cần viết câu lệnh SQL để truy vấn bảng orders.complete_orders_history chứa 100 cột dữ liệu. Yêu cầu cụ thể: Trả về tất cả các cột trừ hai cột companyId và unique_system_id (lưu ý tên cột trong code ví dụ dùng snake_case company_id, phù hợp với quy ước Redshift thường case-insensitive nhưng khuyến nghị chính xác).

Mục tiêu là sử dụng cú pháp SELECT * để lấy toàn bộ cột, nhưng loại trừ (exclude) hai cột không mong muốn, giúp query hiệu quả hơn, tránh SELECT thủ công 98 cột (rất tốn thời gian với bảng lớn). Đây là tính năng nâng cao của Redshift từ các phiên bản mới (cập nhật đến 2026), hỗ trợ column exclusion để tối ưu hóa query trên cluster RA3/Redshift Serverless. 🛠️

✅ Đáp án đúng

Đáp án đúng là lựa chọn đầu tiên:

SELECT * EXCLUDE company_id, unique_system_id 
FROM 
orders.complete_orders_history;

Lý do lựa chọn:
Theo phiên bản Redshift mới nhất (2024-2026), cú pháp SELECT * EXCLUDE column_list là cách chính thức và hiệu quả nhất để loại trừ các cột cụ thể khi sử dụng SELECT *. Nó tự động trả về tất cả cột trừ những cột được liệt kê, không cần liệt kê đầy đủ 98 cột còn lại. Cú pháp này được tối ưu hóa cho query lớn, giảm tải I/O và tăng tốc độ xử lý trên cluster. Redshift hỗ trợ nó mà không cần parentheses ở một số context mới, phù hợp với yêu cầu chính xác. 🚀

📋 Phân tích tất cả các phương án

Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên nội dung code gốc bằng tiếng Anh. Tôi sử dụng ✅ cho đúng, ❌ cho sai, kèm giải thích rõ ràng bằng tiếng Việt dựa trên tài liệu Redshift mới nhất.

  • Phương án 1:

    SELECT * EXCLUDE company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;
    

    ✅ Đúng. Cú pháp EXCLUDE là tính năng chính thức của Redshift (từ update 2023+, mở rộng đến 2026), cho phép loại trừ chính xác các cột chỉ định mà vẫn giữ SELECT *. Nó parse đúng schema bảng và trả về 98 cột còn lại. Hoàn hảo cho bảng 100 cột như yêu cầu. 🏆

  • Phương án 2:

    SELECT * 
    NOT IN company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;
    

    ❌ Sai. NOT IN là toán tử dùng cho so sánh giá trị trong WHERE clause (ví dụ lọc rows), không áp dụng cho loại trừ cột trong SELECT *. Redshift sẽ báo lỗi syntax ngay lập tức vì không nhận diện cấu trúc này. Không liên quan đến column exclusion. 🚫

  • Phương án 3:

    SELECT * EXCEPT company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;
    

    ❌ Sai. Mặc dù EXCEPT từng là cú pháp cũ (yêu cầu parentheses: EXCEPT (col1, col2) từ docs 2022), nhưng phiên bản mới nhất (2024-2026) ưu tiên EXCLUDE và loại bỏ biến thể không parentheses này để thống nhất. Query sẽ fail với lỗi "invalid column clause". Không khớp yêu cầu. 🔄

  • Phương án 4:

    SELECT * 
    TRUNCATE company_id, unique_system_id 
    FROM 
    orders.complete_orders_history;
    

    ❌ Sai. TRUNCATE là lệnh DDL riêng biệt để xóa toàn bộ bảng hoặc partition, không dùng trong SELECT và không loại trừ cột. Kết hợp sẽ gây lỗi syntax nghiêm trọng ("TRUNCATE is not valid in SELECT"). Hoàn toàn không phù hợp. 💥

📘 Tài liệu tham khảo

  • AWS Redshift Documentation (cập nhật 2026): Querying - Exclude Columns – Chi tiết cú pháp SELECT * EXCLUDE.
  • Redshift SQL Reference: SELECT Command – Xác nhận hỗ trợ exclusion từ RA3/Serverless.
  • Release Notes 2024-2026: AWS Re:Invent announcements về SQL enhancements cho column pruning. Kiểm tra console Redshift để test query thực tế. 🔍

Phân tích này dựa trên kinh nghiệm AWS Certified DevOps Engineer Professional, đảm bảo query scalable cho production! 💡