Skip to content

Commit 458f024

Browse files
committed
new changes
1 parent 3eb3520 commit 458f024

File tree

3 files changed

+7
-35
lines changed

3 files changed

+7
-35
lines changed

.github/workflows/validate-queries.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,9 @@ jobs:
4545
SQL_CHANGED=false
4646
while IFS= read -r file; do
4747
if [ -f "$file" ]; then
48-
# Check if the diff contains changes to SQL code blocks
49-
if git diff $BASE_COMMIT...${{ github.sha }} -- "$file" | grep -E "^[+-].*\`\`\`(sql|sumo)" > /dev/null; then
50-
echo "SQL code block changes detected in: $file"
51-
SQL_CHANGED=true
52-
elif git diff $BASE_COMMIT...${{ github.sha }} -- "$file" | grep -E "^[+-].*[^`]" | grep -A 20 -B 5 "\`\`\`sql\|\`\`\`sumo" > /dev/null; then
53-
echo "SQL code content changes detected in: $file"
48+
# Check if the file contains SQL code blocks AND has changes
49+
if grep -q "\`\`\`sql\|\`\`\`sumo" "$file"; then
50+
echo "File contains SQL blocks, validating: $file"
5451
SQL_CHANGED=true
5552
fi
5653
fi

docs/metrics/metrics-operators/where.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ where [VALUE BOOLEAN EXPRESSION | REDUCER BOOLEAN EXPRESSION]
1414
```
1515
## Checking my PR:
1616
```sql
17-
_collector="ABC3" | where type="web"
17+
_collector="ABC5" | where type="web"
1818
```
1919
Where:
2020

scripts/validate_queries.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -69,34 +69,9 @@ def get_changed_files(repo_root):
6969

7070
def extract_changed_sql_queries(file_path, base_commit, current_commit):
7171
"""Extract SQL code blocks that were added or modified in the git diff"""
72-
try:
73-
# Get the git diff for this specific file
74-
diff_cmd = ["git", "diff", f"{base_commit}...{current_commit}", "--", file_path]
75-
result = subprocess.run(diff_cmd, capture_output=True, text=True, cwd=get_repo_root())
76-
77-
if result.returncode != 0:
78-
print(f"::warning::Could not get git diff for {file_path}")
79-
return extract_sql_queries(file_path) # Fallback to all queries
80-
81-
diff_content = result.stdout
82-
83-
# Simple approach: if there are any changes in the file and it contains SQL blocks,
84-
# validate all SQL blocks in the current version of the file
85-
# This is more reliable than trying to parse complex diff output
86-
87-
has_changes = any(line.startswith(('+', '-')) for line in diff_content.split('\n')
88-
if line.strip() and not line.startswith(('+++', '---')))
89-
90-
if has_changes:
91-
# File has changes, extract all current SQL queries for validation
92-
return extract_sql_queries(file_path)
93-
94-
return []
95-
96-
except Exception as e:
97-
print(f"::error::Error extracting changed SQL queries from {file_path}: {e}")
98-
# Fallback to extracting all SQL queries from the file
99-
return extract_sql_queries(file_path)
72+
# For now, simplify by validating all SQL in changed files
73+
# This is more reliable than complex diff parsing
74+
return extract_sql_queries(file_path)
10075

10176
def extract_sql_queries(file_path):
10277
"""Extract SQL code blocks from markdown files (fallback method)"""

0 commit comments

Comments
 (0)