Skip to content

Adding Query Validation Workflow #5514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6bcc8f2
Adding Query Validation Workflow
ntanwar-sumo Jun 23, 2025
187b52f
Merge branch 'main' into doc_pr_validations
ntanwar-sumo Jun 23, 2025
e645bf9
Potential fix for code scanning alert no. 10: Workflow does not conta…
ntanwar-sumo Jun 23, 2025
fac336c
changes
ntanwar-sumo Jun 23, 2025
088acb9
changes
ntanwar-sumo Jun 23, 2025
0e8ea7e
changes
ntanwar-sumo Jun 23, 2025
872b8d1
changes
ntanwar-sumo Jun 23, 2025
71268b6
changes
ntanwar-sumo Jun 23, 2025
6991012
changes
ntanwar-sumo Jun 23, 2025
ecd58ae
chnages-checking for incorrect query
ntanwar-sumo Jun 23, 2025
d2c9a2c
changes
ntanwar-sumo Jun 23, 2025
994b81a
changes
ntanwar-sumo Jun 23, 2025
2dc87df
changes
ntanwar-sumo Jun 24, 2025
18fda2d
changes
ntanwar-sumo Jun 24, 2025
318734d
Merge branch 'main' into doc_pr_validations
ntanwar-sumo Jun 24, 2025
2b09da4
changes
ntanwar-sumo Jun 25, 2025
b9c4d0e
Merge branch 'doc_pr_validations' of github.com:SumoLogic/sumologic-d…
ntanwar-sumo Jun 25, 2025
3b44020
changes
ntanwar-sumo Jun 25, 2025
db58bb8
Fix header update order in SumoLogicClient init
ntanwar-sumo Jun 25, 2025
f61e18b
changes
ntanwar-sumo Jun 25, 2025
95e4d85
changes
ntanwar-sumo Jun 25, 2025
ae88c80
changes
ntanwar-sumo Jul 8, 2025
52d50f1
chnages
ntanwar-sumo Jul 8, 2025
62433df
chnage
ntanwar-sumo Jul 8, 2025
1ddefbc
changes
ntanwar-sumo Jul 30, 2025
886d6db
New changes
ntanwar-sumo Jul 30, 2025
3eb3520
Updated changes
ntanwar-sumo Jul 30, 2025
458f024
new changes
ntanwar-sumo Jul 30, 2025
e4b7a76
changes
ntanwar-sumo Jul 30, 2025
a92d5a5
Changes
ntanwar-sumo Jul 30, 2025
09972fa
Add missing reducer functions to where operator documentation
ntanwar-sumo Jul 31, 2025
b631559
Fix validation script to only process changed files
ntanwar-sumo Jul 31, 2025
362d343
Fix SQL validation to exclude Markdown table content
ntanwar-sumo Jul 31, 2025
899c089
Add comprehensive debugging to identify file processing issue
ntanwar-sumo Jul 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/validate-queries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: SQL Query Validation
on:
pull_request:
paths:
- 'docs/**/*.md'
- 'blog-*/**/*.md'

jobs:
validate-queries:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git diff detection

- name: Check for SQL changes
id: check-sql
run: |
# Get the base commit for comparison
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_COMMIT="${{ github.event.pull_request.base.sha }}"
else
# For push events, compare with previous commit
BASE_COMMIT="${{ github.event.before }}"
fi

echo "Base commit: $BASE_COMMIT"
echo "Current commit: ${{ github.sha }}"

# Get changed markdown files
git diff --name-only --diff-filter=AM $BASE_COMMIT...${{ github.sha }} -- '**/*.md' > changed_files.txt

if [ ! -s changed_files.txt ]; then
echo "No markdown files changed"
echo "sql_changed=false" >> $GITHUB_OUTPUT
exit 0
fi

echo "Changed markdown files:"
cat changed_files.txt

# Check if any of the changed files have SQL code block modifications
SQL_CHANGED=false
while IFS= read -r file; do
if [ -f "$file" ]; then
# Check if the file contains SQL code blocks AND has changes
if grep -q "\`\`\`sql\|\`\`\`sumo" "$file"; then
echo "File contains SQL blocks, validating: $file"
SQL_CHANGED=true
fi
fi
done < changed_files.txt

echo "sql_changed=$SQL_CHANGED" >> $GITHUB_OUTPUT
echo "SQL changes detected: $SQL_CHANGED"

- name: Set up Python
if: steps.check-sql.outputs.sql_changed == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
if: steps.check-sql.outputs.sql_changed == 'true'
run: pip install requests python-dotenv

- name: Validate queries
if: steps.check-sql.outputs.sql_changed == 'true'
working-directory: ./scripts
env:
SUMO_LOGIC_ACCESS_ID: ${{ secrets.SUMO_LOGIC_ACCESS_ID }}
SUMO_LOGIC_ACCESS_KEY: ${{ secrets.SUMO_LOGIC_ACCESS_KEY }}
BASE_COMMIT: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
CURRENT_COMMIT: ${{ github.sha }}
run: |
echo "Validating only changed SQL queries between $BASE_COMMIT and $CURRENT_COMMIT"
python validate_queries.py

- name: Skip validation
if: steps.check-sql.outputs.sql_changed == 'false'
run: echo "No SQL code block changes detected, skipping validation"
1 change: 0 additions & 1 deletion docs/metrics/metrics-operators/where.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ You can use the `where` operator to filter out either entire time series, or ind
```sql
where [VALUE BOOLEAN EXPRESSION | REDUCER BOOLEAN EXPRESSION]
```

Where:

* `[VALUE BOOLEAN EXPRESSION]` is a value expression that operates on individual data points of a time series. For example,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ The following returns `true`:
```sql
| isValidIP("10.255.255.255") as isIP
```
```sql
| isValidIP("30.255.255.255") as isIP
```

The following returns `true`:

Expand Down
7 changes: 7 additions & 0 deletions docs/search/search-query-language/search-operators/where.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ For example, using `where` with the boolean operator [`isValidIP`](/docs/searc
```sql
| where isValidIP("192.168.0.10")
```
* Checking my PR:
```sql
_collector="ABC1" | where type="web"
```
```sql
_collector="ABC7" | where type="web"
```
* Filters as false and will not return results:
```sql
| where !isValidIP("192.168.0.10")
Expand Down
Loading
Loading