4.2 Using the Query Service
Query Service - Using the Query Service
Last updated
Query Service - Using the Query Service
Last updated
Find and explore datasets
Learn how to address Experience Data Models objects and attributes in your queries
In this you will learn how to use PSQL to retrieve information about the available datasets, how to write a queries for Experience Data Model (XDM), and write your first simple reporting queries using the Query Service and Citi Signal datasets.
In this you will learn about the methods to retrieve information about the available datasets and how to properly retrieve data with a query from an XDM dataset.
All the datasets hat we have explored via Adobe Experience Platform in the beginning of 1, are also available for access via a SQL interface as tables. To list those tables you can use the show tables; command.
Execute show tables; in your PSQL command-line interface. (do not forget to end your command with a semicolon).
Copy the command show tables; and paste it at the prompt:
You will see the following result:
At the colon, press space bar to see the next page of the resultset, or enter q
to revert to the command prompt.
Every dataset in Platform has its corresponding Query Service table. You can find a dataset's table via the Datasets ui:
The demo_system_event_dataset_for_website_global_v1_1
table is the Query Service table that corresponds with the Demo System - Event Schema for Website (Global v1.1)
dataset.
To query some information about where a product was viewed, we will select the geo information.
Copy the statement below and paste it at the prompt in your PSQL command-line interface and hit enter:
In your query result, you will notice that columns in the Experience Data Model (XDM) can be complex types and not just scalar types. In the query above we would like to identify geo locations where a commerce.productViews did occur. To identify a commerce.productViews we have to navigate through the XDM model using the . (dot) notation.
Notice the result is a flat object rather than a single value? The placecontext.geo object contains four attributes: schema, country and city. And when an object is declared as a column it will return the entire object as a string. The XDM schema may be more complex than what you are familiar with but it's very powerful and was architected to support many solutions, channels, and use cases.
To select the individual properties of an object, you use the . (dot) notation.
Copy the statement below and paste it at the prompt in your PSQL command-line interface:
The result of the above query should look like this. The result is now a set simple values:
Don't worry, there is an easy way to obtain the path towards a specific property. In the following part you will learn how.
You will need to edit a query, so let's first open an editor.
On Windows
Click the search icon in the windows toolbar, type notepad in the search field, click the notepad result:
On Mac
Install Brackets or use another Text Editor of choice if you don't have it installed and follow the instructions. After installation, search for Brackets via Mac's spotlight search and open it.
Copy the following statement to notepad or brackets:
Go back to your Adobe Experience Platform UI (should be open in your browser) or navigate to https://platform.adobe.com.
Select Schemas, enter Demo System - Event Schema for Website (Global v1.1)
in the search field and select Demo System - Event Schema for Website (Global v1.1) Schema
from the list.
Explore the XDM model for Demo System - Event Schema for Website (Global v1.1), by clicking on an object. Expand the tree for placecontext, geo and schema. When you select the actual attribute longitude, you will see the complete path in the highlighted red box. To copy the attribute's path, click on the copy path icon.
Switch to your notepad/brackets and remove your_attribute_path_here from the first line. Position your cursor after select on the first line and paste (CTRL-V).
Copy the modified statement from notepad/brackets and paste it at the prompt in your PSQL command-line interface and hit enter.
The result should look like: