Snowflake Intelligence is here

Bring enterprise insights to every employee’s fingertips.

Snowflake for DevelopersGuidesCommunity Detection using RelationalAI

Community Detection using RelationalAI

Interactive Analytics
Patrick Lee, Steve Bertolani

Overview

In this quickstart, we'll use RelationalAI — a Native App available in the Snowflake Marketplace — to run community detection algorithms. The sample data represent food-truck orders, and we'll use them to identify groups of customers who probably know each other. This allows us to build a social graph and interact with groups of related customers.

What Is RelationalAI?

RelationalAI is a cloud-native platform that enables organizations to streamline and enhance decisions with intelligence. RelationalAI extends Snowflake with native support for an expanding set of AI workloads (e.g., graph analytics, rule-based reasoning, and optimization), all within your Snowflake account, offering the same ease of use, scalability, security, and governance.

Users can build a knowledge graph using Python and materialize it on top of their Snowflake data, which are shared with the RelationalAI app through Snowflake Streams. Insights can be written to Snowflake tables and shared across the organization.

What You’ll Learn

  • How to discover new insights by running a variety of graph algorithms on your Snowflake data
  • How to complement your graph analytics with graph visualizations
  • How — thanks to native applications with Snowpark Container Services — we can do all of this within the Snowflake Data Cloud

What You’ll Need

What You’ll Build

  • A community detection analysis to find which food truck customers frequently eat together
  • A visualization of this data

NOTE: If you do not already have the RelationalAI Native App installed, please follow the instructions here

Set Up Your Environment

In addition to your Snowflake account setup, follow the steps below to set up a local installation of Python with Jupyter Lab and the RelationalAI Python library.

  • Create a directory for this project and place the demo notebook in it.
  • Navigate to your project directory in your operating system's terminal application.
  • Check your Python installation:
    • Run python3 --version from your terminal.
      • If your Python version starts with 3.10 or 3.11, it's compatible with the RelationalAI Python library.
      • Otherwise, you'll need to download and install Python:
        • Download the installer for your OS from the Python 3.11 download page
        • Run the installer.
        • Verify that Python 3.11 is available by running python3.11 --version from your terminal.
  • Set up a virtual environment for the packages you'll install:
    python3.11 -m venv .venv # or python3 -m venv .venv, if you don't have a python3.11 executable
    source .venv/bin/activate  # Activate on Linux and macOS.
    # .venv\Scripts\activate  # Activate on Windows.
    python -m pip install jupyterlab relationalai
    

RelationalAI Config File

After installing the relationalai package, you will need to set up a RAI configuration with the Snowflake credenrtials you want to use (similar to the configuration for Snowflake CLI).

Run rai init from your terminal and follow the prompts to enter your credentials and other configuration data:

assets/rai_init.png
  1. Choose Snowflake as your host platform.
  2. Select a profile from ~/.snowflake/connections.toml if you have one, or enter your username, password, and Account ID otherwise.
  3. Select your role rai_user that you created earlier.
  4. Select a Snowflake warehouse.
  5. Select [CREATE A NEW ENGINE] to create a new engine. Enter any name you want for the engine, for example rai_engine. (Usually you would not want to select the same engine you created above for CDC.)
  6. Select HighMem|S as the engine size.
  7. Choose the compute pool rai_compute_pool that you created above.
  8. Press Enter to accept the default profile name of default.

Run the Notebook in Jupyter Lab

  1. Start Jupyter Lab with the following command:

    jupyter lab
    

    and visit the URL (something like http://localhost:8888/lab?token=XXXX) printed in the console output in your browser.

  2. Open the community-detection.ipynb file in Jupyter lab. You should see the top of the notebook:

assets/rai_notebook_1.png
  1. If you don't already have a Snowflake table called RAI_DEMO.TASTYBYTES.ORDERS, scroll down to the Appendix and run the cells in that section to insert the data for this demo into your Snowflake account.

  2. The notebook will guide you through defining a knowledge graph!


Conclusion & Resources

Congratulations on completing the our Community Detection using RelationalAI guide! In this Quickstart you learned

  • How to install the RelationalAI Native App from the Snowflake Marketplace
  • How to build a knowledge graph on top of your Snowflake data without having to export your data from Snowflake
  • How to run graph algorithms on your knowledge graph and visualize relationships in the graph

Resources

Updated 2025-11-23

This content is provided as is, and is not maintained on an ongoing basis. It may be out of date with current Snowflake instances