mirror of https://github.com/buster-so/buster.git
ok added in some sql best practices
This commit is contained in:
parent
e7a5b6817d
commit
3552a828ab
|
@ -169,6 +169,22 @@ properties:
|
||||||
description: "Human-readable time period covered by the query (e.g., 'Last 30 days', 'All time', 'August 1, 2024 - January 1, 2025', 'Comparison: August 2025 to August 2024')"
|
description: "Human-readable time period covered by the query (e.g., 'Last 30 days', 'All time', 'August 1, 2024 - January 1, 2025', 'Comparison: August 2025 to August 2024')"
|
||||||
|
|
||||||
# SQL QUERY
|
# SQL QUERY
|
||||||
|
### SQL Best Practices and Constraints** (when creating new metrics)
|
||||||
|
# - **Constraints**: Only join tables with explicit entity relationships.
|
||||||
|
# - **SQL Requirements**:
|
||||||
|
# - Use schema-qualified table names (`<SCHEMA_NAME>.<TABLE_NAME>`).
|
||||||
|
# - Select specific columns (avoid `SELECT *` or `COUNT(*)`).
|
||||||
|
# - Use CTEs instead of subqueries, and use snake_case for naming them.
|
||||||
|
# - Use `DISTINCT` (not `DISTINCT ON`) with matching `GROUP BY`/`SORT BY` clauses.
|
||||||
|
# - Show entity names rather than just IDs.
|
||||||
|
# - Handle date conversions appropriately.
|
||||||
|
# - Order dates in ascending order.
|
||||||
|
# - Reference database identifiers for cross-database queries.
|
||||||
|
# - Format output for the specified visualization type.
|
||||||
|
# - Maintain a consistent data structure across requests unless changes are required.
|
||||||
|
# - Use explicit ordering for custom buckets or categories.
|
||||||
|
# - When grouping metrics by dates, default to monthly granularity for spans over 2 months, yearly for over 3 years, weekly for under 2 months, and daily for under a week, unless the user specifies a different granularity.
|
||||||
|
###
|
||||||
sql:
|
sql:
|
||||||
type: string
|
type: string
|
||||||
description: "SQL query using YAML pipe syntax (|)"
|
description: "SQL query using YAML pipe syntax (|)"
|
||||||
|
|
|
@ -229,5 +229,21 @@ Use this checklist to select the most appropriate Analysis Type:
|
||||||
- Justify each chart's value to the objective.
|
- Justify each chart's value to the objective.
|
||||||
- Confirm feasibility with available data.
|
- Confirm feasibility with available data.
|
||||||
|
|
||||||
|
### SQL Best Practices and Constraints** (when creating new metrics)
|
||||||
|
- **Constraints**: Only join tables with explicit entity relationships.
|
||||||
|
- **SQL Requirements**:
|
||||||
|
- Use schema-qualified table names (`<SCHEMA_NAME>.<TABLE_NAME>`).
|
||||||
|
- Select specific columns (avoid `SELECT *` or `COUNT(*)`).
|
||||||
|
- Use CTEs instead of subqueries, and use snake_case for naming them.
|
||||||
|
- Use `DISTINCT` (not `DISTINCT ON`) with matching `GROUP BY`/`SORT BY` clauses.
|
||||||
|
- Show entity names rather than just IDs.
|
||||||
|
- Handle date conversions appropriately.
|
||||||
|
- Order dates in ascending order.
|
||||||
|
- Reference database identifiers for cross-database queries.
|
||||||
|
- Format output for the specified visualization type.
|
||||||
|
- Maintain a consistent data structure across requests unless changes are required.
|
||||||
|
- Use explicit ordering for custom buckets or categories.
|
||||||
|
- When grouping metrics by dates, default to monthly granularity for spans over 2 months, yearly for over 3 years, weekly for under 2 months, and daily for under a week, unless the user specifies a different granularity.
|
||||||
|
|
||||||
---
|
---
|
||||||
"##;
|
"##;
|
||||||
|
|
Loading…
Reference in New Issue