# ของดี! dbt\_project\_evaluator ตัวช่วยตรวจสอบโปรเจค dbt ว่ายัง align กับ best practices อยู่ไหม

**URL:** <https://discuss.dataengineercafe.io/t/dbt-project-evaluator-dbt-align-best-practices/465>\
**Category:** dbt\
**Tags:** dbt\
**Created:** [December 13, 2022, 6:31am UTC](https://discuss.dataengineercafe.io/t/dbt-project-evaluator-dbt-align-best-practices/465 "2022-12-13T06:31:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zkan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.dataengineercafe.io/zkan/32/2_2.png) [@zkan](https://discuss.dataengineercafe.io/u/zkan)\
**Post date:** [December 13, 2022, 6:31am UTC](https://discuss.dataengineercafe.io/t/dbt-project-evaluator-dbt-align-best-practices/465/1 "2022-12-13T06:31:38Z")

</div>

ทาง dbt Labs ทำเครื่องมือที่จะช่วยเราคอยเช็ค practices ต่าง ๆ ในโปรเจค dbt ของเราว่ายัง align กันอยู่ไหม ดีงามมาก ๆ 👍

> The [dbt\_project\_evaluator](https://github.com/dbt-labs/dbt-project-evaluator) was born: a dbt package that uses the shared language of SQL, models, and tests to identify and assert specific recommendations for a given dbt project.

ลองอ่านรายละเอียดได้ที่บทความด้านล่างนี้ครับ

> **[Introducing the dbt\_project\_evaluator: Automatically evaluate your dbt...](https://docs.getdbt.com/blog/align-with-dbt-project-evaluator)**
>
> The dbt\_project\_evaluator is a dbt package created by the Professional Services team at dbt Labs to help analytics engineers automatically audit their dbt projects for bad practices. Goodbye auditing nightmares, hello beautiful DAG.

สามารถดู Demo เพิ่มเติมได้ที่วีดีโอด้านล่างนี้เลย เค้าไปแชร์ที่งาน Coalesce 2022 ที่ผ่านมา

[![](https://canada1.discourse-cdn.com/flex035/uploads/dataengineercafe/original/1X/e8a23923aa9b4d1e5495d930bdadfdc25474fe4e.jpeg "dbt Project Evaluator") ](https://www.youtube.com/watch?v=smbRwmcM1Ok)

---

<div class="post-metadata">

**Author:** ![zkan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discuss.dataengineercafe.io/zkan/32/2_2.png) [@zkan](https://discuss.dataengineercafe.io/u/zkan)\
**Post date:** [December 13, 2022, 12:58pm UTC](https://discuss.dataengineercafe.io/t/dbt-project-evaluator-dbt-align-best-practices/465/2 "2022-12-13T12:58:27Z")

</div>

หลังจากที่เราเซตอัพ แล้วรันคำสั่ง

```bash
dbt build --select package:dbt_project_evaluator

```

เรียบร้อยแล้ว เราจะได้ tables กับ views อยู่บน data warehouse ของเรา แล้วที่ console จะมี log พวก warning เกิดขึ้น ก็ให้เราเอา warning พวกนั้นเทียบกับ rules ต่าง ๆ ที่ 👇

> **[GitHub - dbt-labs/dbt-project-evaluator: This package contains macros and...](https://github.com/dbt-labs/dbt-project-evaluator#rules-1)**
>
> This package contains macros and models to find DAG issues automatically - GitHub - dbt-labs/dbt-project-evaluator: This package contains macros and models to find DAG issues automatically

ยกตัวอย่างเช่น ถ้าผมเจอแบบ screenshot ด้านล่างนี้

 ![is_empty_fct_missing_primary_key_tests_](https://canada1.discourse-cdn.com/flex035/uploads/dataengineercafe/original/1X/4dcb29ce5d5a04de941fb6581b288245d7dd7d69.png)

ตรงนี้ผมก็ต้องไปหา rule ที่เป็นเรื่อง [Missing Primary Key Tests](https://github.com/dbt-labs/dbt-project-evaluator#missing-primary-key-tests) พอเข้าไปอ่านแล้วก็พบว่า อ๋อ… มีโมเดลที่ผมไม่ได้เขียนเทสเรื่อง primary keys ไว้ และ dbt\_project\_evaluator ก็ได้สร้างโมเดล `fct_missing_primary_key_tests` ที่เก็บข้อมูลโมเดลที่ไม่มีเทสเรื่อง primary keys ไว้ให้ผมแล้วด้วย! 🤩

ซึ่งผมก็สามารถที่จะเข้าไป query ดึงข้อมูลดูได้ว่าโมเดลไหนบ้างที่เป็นแบบนั้น ตามรูปด้านล่างนี้เลย

 ![Results stored in fct_missing_primary_key_tests](https://canada1.discourse-cdn.com/flex035/uploads/dataengineercafe/original/1X/2a9b3952d3a727073039b875063c66ca64b10d1c.png)

ตอนนี้เจอ warning ไปเป็นร้อย… แก้กันสนุกสนาน 😂
