Skip to content
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

Update SQL reference guide for Log Workspaces #28591

Merged
merged 9 commits into from
Apr 10, 2025

Conversation

vishalshah-dd
Copy link
Contributor

@vishalshah-dd vishalshah-dd commented Apr 4, 2025

What does this PR do? What is the motivation?

In preparation for the GA release for Log Workspaces, we're reviewing public documentation and updating them to match the latest SQL functionality supported by the product.

This PR focusses on:

  • Fixing incorrect parameters for existing functions
  • Ensuring consistent type and variable names in the function definitions
  • Adding supported extraction types, cast target types, and date/time formatting options

https://datadoghq.atlassian.net/browse/LOGSQ-830

Merge instructions

Merge readiness:

  • Ready for merge

For Datadog employees:
Merge queue is enabled in this repo. Your branch name MUST follow the <name>/<description> convention and include the forward slash (/). Without this format, your pull request will not pass in CI, the GitLab pipeline will not run, and you won't get a branch preview. Getting a branch preview makes it easier for us to check any issues with your PR, such as broken links.

If your branch doesn't follow this format, rename it or create a new branch and PR.

To have your PR automatically merged after it receives the required reviews, add the following PR comment:

/merge

Additional notes

Copy link
Contributor

github-actions bot commented Apr 4, 2025

Preview links (active after the build_preview check completes)

Modified Files

@vishalshah-dd vishalshah-dd force-pushed the vishalshah/update-sql-reference branch from cdd5aa4 to 51c65d9 Compare April 4, 2025 20:46
@vishalshah-dd vishalshah-dd force-pushed the vishalshah/update-sql-reference branch from 31ae809 to e7319ff Compare April 8, 2025 15:36
@vishalshah-dd vishalshah-dd marked this pull request as ready for review April 8, 2025 18:59
@vishalshah-dd vishalshah-dd requested a review from a team as a code owner April 8, 2025 18:59
Copy link

@petternasholm petternasholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't confirm that the available options all work or are present. I'm relying on you to have done that already.

| `month` | `timestamp` | month of the year (`1` - `12`) |
| `quarter` | `timestamp` | quarter of the year (`1` - `4`) |
| `year` | `timestamp` | year |
| `timezone_hour` | `timestamp` | hour of the time-zone offfset |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prob use "timezone" instead of "time-zone" for consistency?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think I'd rather move it to "time zone" as that's how I'm seeing it being used more often in documentations (incl postgres) regardless of the consistency with the literal

{{< /code-block >}}

### `TO_CHAR`

Supported patterns for date/time formatting:
| Pattern | Description |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only have this list specified twice, right?

Seems ok to keep it duplicated for now, but might be nice to put into a shared section at least at some point. The more functions that we have that need this, the more useful a shared section would be. I'll defer to you whether that's worth doing now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep just twice. I had thought about a common section, but decided against it to save the user a click. Agree that it should be moved if it's specified in more often

to_timestamp(epoch_time) AS formatted_time
FROM
event_logs
to_timestamp('25/12/2025 04:23 pm', 'DD/MM/YYYY HH:MI am') AS ts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I noticed now that technically is unrelated to this PR: We seem to be inconsistent in how we case function names. E.g., CAST is upper case, this is lower case.

I think it would be good to do this consistently. And I would in general prefer upper case, but that's a weak preference. I think consistency is the more important aspect.

I'm curious on your thoughts here, but regardless I think it would make sense to tackle in a separate PR (so it can be done holistically and make that easier to review).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, seems like this entire section has them in lower case. I'll make a follow up PR to edit them altogether. Looking at Postgres, I'm seeing them use lower case when listing functions in tables, but upper case in SQL statements. I do prefer that, it's easier on the eyes when scanning through a list but works inside SQL with capitalizing other keywords.

@vishalshah-dd
Copy link
Contributor Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Apr 10, 2025

View all feedbacks in Devflow UI.

2025-04-10 21:17:56 UTC ℹ️ Start processing command /merge


2025-04-10 21:18:00 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-04-10 21:18:17 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in master is approximately 18m (p90).


2025-04-10 21:35:04 UTC ℹ️ MergeQueue: This merge request was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants