- Schema:
LISTING_ ACCESS_ HISTORY view¶
This view in the DATA_SHARING_USAGE schema can be used to explore the history of consumers’ usage of your listings. LISTING_ACCESS_HISTORY provides object-level information about queries run against the data shares or Native Apps attached to your listings. For more information about the data provided by the LISTING_ACCESS_HISTORY view, see the Columns section.
Each row returned by LISTING_ACCESS_HISTORY represents a single time the listing was accessed by a consumer. Because the rows represent queries instead of sessions, it is likely that the same listing will appear multiple times, one row for each query.
A single consumer query can access objects from multiple listings. The QUERY_TOKEN identifies the query that generated a row in the listing access history. To identify a collection of listing objects accessed by a single consumer query, use the QUERY_TOKEN.
The LISTING_ACCESS_HISTORY view provides selected information about consumer queries rather than their full SQL text. The view also excludes any objects that are not owned by the provider account. For example, if a consumer joins data from your listing with their own data or another provider’s data, only listing objects that you own are returned by the LISTING_ACCESS_HISTORY view. The view also reports supported consumer query types and information about how consumers use columns in your listing. For details, see Columns and SHARE_OBJECTS_ACCESSED array.
Columns¶
| Column Name | Data Type | Description |
|---|---|---|
| QUERY_TOKEN | VARCHAR | Unique ID for each query run by a consumer. A QUERY_TOKEN does not correlate with any actual query identifier on the consumer side. |
| QUERY_DATE | DATE | Date when the query was executed. |
| QUERY_TYPE | VARCHAR | Consumer query type: SELECT, INSERT, CREATE_TABLE_AS_SELECT, UNLOAD, or PARTITIONED_UNLOAD. Other types and queries predating this column return <redacted>. Returns NULL when IS_APPLICATION is TRUE. |
| EXCHANGE_NAME | VARCHAR | Snowflake Marketplace or the data exchange where the listing is available. |
| SNOWFLAKE_REGION | VARCHAR | Snowflake region where the consumption occurred. |
| LISTING_GLOBAL_NAME | VARCHAR | Global name of the listing in the Snowflake Marketplace or data exchange that provides the share. |
| PROVIDER_ACCOUNT_LOCATOR | VARCHAR | Account locator of the share owner. |
| PROVIDER_ACCOUNT_NAME | VARCHAR | Account name of the share owner. |
| SHARE_NAME | VARCHAR | Name of the data share that consumers accessed. When IS_SHARE is FALSE, the value is NULL. |
| CONSUMER_ACCOUNT_LOCATOR | VARCHAR | Account locator of the consumer. |
| CONSUMER_ACCOUNT_NAME | VARCHAR | Account name of the consumer. |
| CONSUMER_ACCOUNT_ORGANIZATION | VARCHAR | Name of the organization for the consumer account. |
| LISTING_OBJECTS_ACCESSED | ARRAY | Use SHARE_OBJECTS_ACCESSED as it contains the same data. When IS_SHARE is FALSE, the value is NULL. See LISTING_OBJECTS_ACCESSED array for formatting. |
| REGION_GROUP | VARCHAR | Region group where the account of the consumer is located. |
| CONSUMER_NAME | VARCHAR | Contains the name of the consumer account that accessed, used, or requested a listing. If no name is available, such as for trial accounts, the value is NULL. |
| IS_SHARE | BOOLEAN | TRUE if the access was on a share. When TRUE, the SHARE_OBJECTS_ACCESSED column provides details about the share objects accessed by the consumer query. |
| IS_APPLICATION | BOOLEAN | TRUE if the access was on an application. When TRUE, APPLICATION_OBJECTS_ACCESSED column provides details about the application objects accessed by the consumer query. |
| SHARE_OBJECTS_ACCESSED | ARRAY | Details the share objects accessed by the consumer query. When IS_SHARE is FALSE, the value is NULL. See SHARE_OBJECTS_ACCESSED array for formatting. |
| APPLICATION_OBJECTS_ACCESSED | ARRAY | Details the application objects accessed by the consumer query. When IS_APPLICATION is FALSE, the value is NULL. See APPLICATION_OBJECTS_ACCESSED array. |
| APPLICATION_PACKAGE_NAME | VARCHAR | The current name of the application package from which the application was installed. When IS_APPLICATION is FALSE, the value is NULL. |
| APPLICATION_VERSION | VARCHAR | The version of the application when the query occurred. When IS_APPLICATION is FALSE, the value is NULL |
| APPLICATION_PATCH_ID | NUMBER | The application patch number when the query occurred. When IS_APPLICATION is FALSE, the value is NULL. |
Usage notes¶
- Latency for the view may be up to 2 days.
- The data is retained for 365 days (1 year).
SHARE_ OBJECTS_ ACCESSED array¶
The SHARE_OBJECTS_ACCESSED array provides details about the objects in a share accessed by a consumer query. The format of an item in the array depends on the type of object that was accessed.
Functions:
Stored procedures:
Tables, views, and columns:
For tables and views, an item can also include the following arrays, which describe how consumer queries used your columns:
| Field | Description |
|---|---|
groupByObjects | Your columns that the consumer query grouped by. Each entry contains a columnId and a columnName. |
aggregateObjects | Your columns that the consumer query passed to an aggregate function. Each entry contains a columnId and a columnName. |
filterObjects | Your columns that the consumer query filtered on in a WHERE, HAVING, or QUALIFY clause. Each entry contains a columnId and a columnName. For date and timestamp columns compared with a constant, the entry can also contain a columnValue field holding the date used in the filter predicate, expressed as a UTC date (YYYY-MM-DD) without time-of-day information. For all other data types, the entry omits columnValue and doesn’t expose the filter value. |
An entry for a table or view with these arrays included looks like this:
Cortex Search Services:
APPLICATION_ OBJECTS_ ACCESSED array¶
The APPLICATION_OBJECTS_ACCESSED array provides details about the objects in a Native App accessed by a consumer query. The format of an item in the array depends on the type of object that was accessed.
Unlike the LISTING_OBJECTS_ACCESSED column array results, APPLICATION_OBJECTS_ACCESSED results containing object IDs are unavailable and database names are masked.
Functions:
Stored procedures:
Tables, views, and columns:
LISTING_ OBJECTS_ ACCESSED array¶
Use SHARE_OBJECTS_ACCESSED Array instead.
Examples¶
This section contains the following example SQL queries for the LISTING_ACCESS_HISTORY view:
- Aggregate view of access over time
- Aggregate view of access over time by consumer
- Access count by column
- Table joins
- Table joins by consumer
- Range of filter values by consumer
- Columns used in GROUP BY clauses
- Unload queries by consumer
Aggregate view of access over time¶
An aggregate view of which functions, stored procedures, tables, views, and columns have been accessed (over a certain period) and the total number of times.
Aggregate view of access over time by consumer¶
This example is similar to Aggregate view of access over time, broken down by consumer.
Access count by column¶
For a given object (table, view), how many times each column was accessed.
Table joins¶
A view of which combination of tables are being joined together.
Table joins by consumer¶
A view of which tables are being joined together (pairs) broken down by consumer.
Range of filter values by consumer¶
A view of the earliest and latest date literals in consumer filters on date and timestamp columns, broken down by consumer.
Columns used in GROUP BY clauses¶
A view of how often consumers group by each column.
To do the same for columns passed to aggregate functions, flatten aggregateObjects instead of groupByObjects.
Unload queries by consumer¶
To count the queries in the last seven days that unloaded data from your listing, broken down by consumer and unload type, run the following statement:
To count other query types, change the values in the query_type filter.