analytics:query (Deprecated)

Execute an Analytics query.

As of April 20, 2023, we no longer maintain this section of the command reference. Refer to the reference information about the sf-style commands instead, which we update regularly. We keep this reference information about the sfdx-style commands as-is for historical reference only.

The sfdx-style commands continue to work the same as before, and any scripts that use the commands won’t break. However, we recommend that you start using the equivalent sf-style commands.

The reference page for each sfdx command has been updated with information about its equivalent sf command. The page also shows how the flag names have changed between the sfdx and sf commands. Use this information to migrate your scripts.

For background information about this change, read this blog post, which describes how we’ve updated many of the existing sfdx commands to use the improvements we made in sf commands. To view all the changes, read the CLI release notes starting with version 7.183.1 on January 12, 2023.

Warning

Examples for analytics:query 

1sfdx analytics:query -f query.saql
1sfdx analytics:query -f query.sql -t America/Denver
1sfdx analytics:query -q "..." --sql --limit 10 -r csv

Command Syntax 

sfdx analytics:query

[--json]

[--loglevel LOGLEVEL]

[-u TARGETUSERNAME]

[--apiversion APIVERSION]

[-f QUERYFILE]

[-q QUERY]

[--nomapnames]

[--sql]

[-t TIMEZONE]

[--connector CONNECTOR]

[--limit LIMIT]

[-r RESULTFORMAT]

Parameters 

--json

Optional

Format output as JSON.

Type: boolean

--loglevel LOGLEVEL

Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: enum

Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL

Default value: warn

-u | --targetusername TARGETUSERNAME

Optional

A username or alias for the target org. Overrides the default target org.

Type: string

--apiversion APIVERSION

Optional

Override the API version used for API requests made by this command.

Type: string

-f | --queryfile QUERYFILE

Optional

Path to the file containing the query to execute.

Type: filepath

-q | --query QUERY

Optional

The query to execute.

Type: string

--nomapnames

Optional

Skip mapping dataset names in the SAQL query to ids.

Type: boolean

--sql

Optional

Execute the query as SQL.

Type: boolean

-t | --timezone TIMEZONE

Optional

The timezone for the query.

Type: string

--connector CONNECTOR

Optional

Execute the SQL query against this external data connector id or name.

Type: string

--limit LIMIT

Optional

The maximum number of rows to include.

Type: number

-r | --resultformat RESULTFORMAT

Optional

Result format emitted to stdout.

Type: enum

Permissible values are: human, csv, json

Default value: human