Skip to content

How to Utilize SQL to Explore Data in Palzin Track

Introducing the AI Explorer and SQL Queries

The AI Explorer utilizes the powerful GPT-4 technology to translate specific product-related questions into SQL queries. These queries can then be executed on our comprehensive database. While the AI Explorer is currently in the alpha phase, it's important to acknowledge the possibility of encountering SQL queries that may not seamlessly integrate with our database schema.

In such cases, this guide will provide you with valuable insights into our database schema and the types of queries that can be executed on it. It's essential to note that our analytics database relies on ClickHouse, granting you the ability to access three significant tables: events, all_user_traits, and group_traits. This access enables you to run SELECT queries on these tables and utilize ClickHouse functions that align with the respective data types in use. Typically, you'll work with DateTime, String, and Integer functions for most scenarios.

Database Schema Details

Schema: feeds

This table contains all the EVENTS that users have sent to us.

channel*StringChannel name
event*StringEvent name
user_idStringUser ID
descriptionStringEvent description
iconEmojiSingle emoji as the event icon
notifyBooleanSend push notification
tagskey/valueEvent tags
timestampNumberunix timestamp (seconds)

Schema: Identities

This table contains all the users you've sent to us, along with all of their traits and values.

project*StringProject name
user_id*StringUser ID
propertiesKey/ValueUser Properties
computed_propertiesKey/ValueComputed Properties

Schema: web_track_analytics

This table contains all the Web Track Analytics that users have sent to us.

titleStringPage Title
urlStringURL
query_parameterStringURL Query Parameters
created_atDateTimeDate on which it was created
identity_idStringIdentity Id of the user
channel_nameStringChannel Name
tagskey/valueTags passed if any
referrerStringReferrer Page
countryStringCountry
pathStringPath

Sample Queries for Exploration

Counting Track Events

SELECT COUNT() FROM events WHERE type = 2

Counting Page Events

SELECT COUNT() FROM events WHERE type = 0

Counting Distinct Users

SELECT COUNT(DISTINCT user_id)
FROM all_user_traits
WHERE notEmpty(user_id)

Retrieving Users Belonging to a Company

SELECT DISTINCT user_id
FROM group_traits
WHERE group_id = 'A'

Retrieving Users with 'staff' Trait Set to True

SELECT
DISTINCT user_id
FROM (
SELECT
user_id,
key,
argMax(value, timestamp) AS _value
FROM all_user_traits
GROUP BY user_id, key
)
WHERE key = 'staff' AND _value = 'true'

Retrieving Companies with 'is_paying' Trait Set to True

SELECT
DISTINCT group_id
FROM (
SELECT
group_id,
key,
argMax(value, timestamp) AS _value
FROM group_traits
GROUP BY group_id, key
)
WHERE key = 'is_paying' AND _value = 'true'

Counting Events by Non-Staff Users within a Date Range

SELECT
COUNT()
FROM events
WHERE timestamp BETWEEN '2023-01-01' AND '2023-02-01'
AND user_id IN (
SELECT
DISTINCT user_id
FROM (
SELECT
user_id,
key,
argMax(value, timestamp) AS _value
FROM all_user_traits
GROUP BY user_id, key
)
WHERE key = 'staff' AND _value != 'true'
)

Event Property Breakdown

SELECT properties_values[indexOf(properties_keys, '')] AS , COUNT(*) as count
FROM events
WHERE name = '' AND has(properties_keys, '')
GROUP BY
ORDER BY count DESC

By utilizing Open.ai, we do not disclose any user-related data. However, we do receive the names of your events and traits.

FAQ:

- What does "is_active" signify in the generated queries?

Simply put, "is_active" determines whether a particular event has been deleted or not.

- Could you provide more information about your schema?

- What type of information can I inquire about using AI?