Skip to main content

Use Magic

Make your analysis smarter and faster with Hex's AI assistant.

Use Magic to generate code from scratch, tweak or fix existing code, or create a multi-cell analysis.

Use Magic in a new project

Magic can generate multiple cells at a time in your notebook, chaining together SQL, Python, and Chart cells to answer complex questions or start a new analysis. Access Magic from a new project by asking a question in the purple prompt bar at the top of your project.

By default, Magic will reference schemas in your default Data connection. If you'd like Magic to reference data in a different data connection, select a different data source in the Magic prompt bar.

New project example

In this example, we ask Magic about orders data at a dumpling restaurant:

"What are our most popular appetizers? Does it change based on what kind of dumplings someone has in their order?"

Magic is able to access the correct data in our warehouse, write a SQL query to manipulate the data as requested, and then create a visualization to answer the question.

New cells are created as drafts, allowing you to review, edit, and validate the generated code. Select Done to add Magic-generated cells to your project, or select Discard to delete them. If you'd like to share feedback on how Magic's response could be more useful, select Improve these results and let us know how!

Use magic in an existing project

You can also use Magic from anywhere in an existing project to help with complex questions or take your analysis in a new direction. Access generate mode with Cmd+G, hitting ↓ from an edit mode prompt bar, or from the “Add with Magic” button between cells.

Activate Magic on a cell in your project with Cmd+Shift+M, or by selecting the Magic icon to the left of the run button. Seamlessly switch between editing existing cells or generating new cells with the ↑ and ↓ keys.

Existing project example

In this example, we open up Magic in the middle of our project and prompt Magic, using @ tagging:

"filter @orders down to just dumplings and build a simple forecast of monthly dumpling orders"

Magic filters the orders dataframe as requested, creates a forecasting model in Python, and plots the forecasted data in a Chart cell.

Tag warehouse tables and dataframes

Assist Magic by “@ mentioning” specific warehouse tables or dataframes you'd like it to use in its response. This helps Magic hone in on the objects you want to reference to improve its usefulness.

Fix errors with Magic

Have a query erroring on the wrong syntax? Forgot the name of the pandas function you wanted to use? When a Python or SQL cell errors, click Fix with Magic to have Magic try and fix your error. If you have more context, provide Magic with additional information to help form the right response.