Overview
This page documents write operations supported via the Data Transformations connector. These operations enable you to create, manage, and manipulate tables and views in your private namespace on Dune. Both read and write operations use the same Trino endpoint (trino.api.dune.com), but write operations require the transformations=true session property.
Standard read operations (SELECT, JOIN, WHERE, etc.) are documented in the Query Engine section and work without any special session properties.
While dbt is the recommended tool for data transformations, these SQL operations work with any Trino-compatible client including Hex, Jupyter notebooks, SQLMesh, or direct Trino connections.
All write operations require the
transformations=true session property to be set. Without this property, DDL and DML statements will be rejected.Prerequisites
- Dune Enterprise account with Data Transformations enabled
- Valid Dune API key with write permissions
- Queries must target the
dunecatalog
DDL Operations
Schema Management
Create and manage schemas within your namespace.CREATE SCHEMA
CREATE SCHEMA [IF NOT EXISTS] schema_name
Create a new schema in your team namespace.
Examples:
{team}__tmp_*.
SHOW SCHEMAS
SHOW SCHEMAS [FROM catalog]
List all schemas you have access to.
Example:
Query Information Schema
SELECT ... FROM dune.information_schema.schemata
Get detailed schema metadata using information schema queries.
Example:
Table Management
CREATE TABLE
CREATE TABLE [IF NOT EXISTS] table_name (column_definitions)
Create a new table with explicit column definitions.
Example:
BIGINT, DOUBLE, VARCHAR, VARBINARY, TIMESTAMP, BOOLEAN, ARRAY, MAP, and custom types like UINT256 and INT256.
CREATE TABLE AS SELECT (CTAS)
CREATE TABLE table_name AS query
Create a table from a query result.
Example:
CREATE OR REPLACE TABLE
CREATE OR REPLACE TABLE table_name AS query
Create or replace an existing table atomically.
Example:
MERGE instead.
DROP TABLE
DROP TABLE [IF EXISTS] table_name
Delete a table and its data.
Examples:
SHOW TABLES
SHOW TABLES [FROM schema]
List all tables in a schema.
Examples:
SHOW CREATE TABLE
SHOW CREATE TABLE table_name
View the DDL for a table.
Example:
CREATE TABLE statement that can recreate the table.
View Management
CREATE OR REPLACE VIEW
CREATE OR REPLACE VIEW view_name AS query
Create or update a view definition.
Example:
DROP VIEW
DROP VIEW [IF EXISTS] view_name
Delete a view definition.
Example:
SHOW CREATE VIEW
SHOW CREATE VIEW view_name
View the SQL definition of a view.
Example:
Column Operations
SHOW COLUMNS
SHOW COLUMNS FROM table_name
List all columns in a table.
Example:
DESCRIBE
DESCRIBE table_name
Get detailed column information including names, types, and metadata.
Example:
Query Information Schema for Columns
SELECT ... FROM dune.information_schema.columns
Get detailed column metadata using information schema queries.
Example:
DML Operations
Insert Operations
INSERT INTO with VALUES
INSERT INTO table_name (columns) VALUES (values)
Insert specific rows into a table.
Example:
INSERT INTO with SELECT
INSERT INTO table_name SELECT ...
Insert query results into a table.
Example:
Update Operations
MERGE INTO
MERGE INTO target USING source ON condition WHEN MATCHED THEN UPDATE ... WHEN NOT MATCHED THEN INSERT ...
Upsert data - update existing rows and insert new ones in a single operation.
Example:
Delete Operations
DELETE FROM
DELETE FROM table_name WHERE condition
Delete rows matching a condition.
Example:
TRUNCATE TABLE
TRUNCATE TABLE table_name
Remove all rows from a table efficiently.
Example:
TRUNCATE is faster than DELETE FROM table for removing all rows as it doesn’t scan individual rows.
Maintenance Operations
These operations optimize table performance and manage metadata. They consume credits based on compute and data written.OPTIMIZE
ALTER TABLE table_name EXECUTE OPTIMIZE
Compact small files and optimize table layout for better query performance.
Example:
- After many small writes
- Before running complex queries
- Periodically for frequently-updated tables
VACUUM
ALTER TABLE table_name EXECUTE VACUUM
Remove old data files and reclaim storage space.
Example:
- After major updates or deletes
- To reclaim storage space
- Based on your retention policies
Automating Maintenance in dbt
Use dbt post-hooks to automate maintenance:Information Schema Queries
Query metadata about your tables and schemas.List All Tables
Find Tables by Pattern
Get Table Column Details
Check Table Existence
Permissions & Access Control
What You Can Do
Read Permissions
- All public Dune datasets
- Your team’s private uploaded data
- Your transformation tables and views
Write Permissions
- Create schemas:
{team_name}and{team_name}__tmp_* - Create tables/views in your schemas only
- Insert, update, delete data in your tables only
- Drop your own tables and views
What You Cannot Do
- Write to public schemas (e.g.,
ethereum,prices, etc.) - Write to other teams’ namespaces
- Modify tables you don’t own
Schema Naming Rules
Valid namespace patterns:your_team- Production schemayour_team__tmp_- Default development schemayour_team__tmp_alice- Personal development schemayour_team__tmp_pr123- CI/CD schema for PR #123
eth__tmp_- Cannot use reserved prefixesanother_team- Cannot use other team namespublic__tmp_- Cannot use system schemas
Session Properties
Required Property
- dbt: Add to
profiles.ymlundersession_properties - Python: Set in connection parameters
- SQL client: Execute
SET SESSIONbefore other statements
Optional Properties
Join Distribution Type
Optimize join performance:AUTOMATIC(default) - Let Trino choosePARTITIONED- Repartition both tablesBROADCAST- Broadcast smaller table
Common Patterns
Incremental Model Pattern (Merge)
Delete+Insert Pattern
Append-Only Pattern with Deduplication
Staging Table Pattern
Best Practices
Use Appropriate Incremental Strategy
- Merge: When you need to update existing rows (e.g., daily aggregations)
- Delete+Insert: When recomputing entire partitions (e.g., hourly metrics)
- Append: For immutable event logs
Optimize Write Operations
- Batch inserts instead of single-row inserts
- Use CTAS for bulk table creation
- Partition large tables by date for efficient updates
Manage Table Lifecycle
- Drop temporary tables in
__tmp_schemas regularly - Use views for derived data that doesn’t need persistence
- Run OPTIMIZE periodically on frequently-updated tables
Monitor Credit Usage
- Track write operations in large tables
- Use incremental models to minimize data written
Limitations & Considerations
No Direct ALTER TABLE Support
You cannot alter table structure directly. Instead:No SCHEMA DROP
Empty schemas are automatically managed. You cannot explicitly drop schemas.Transaction Behavior
Each statement is auto-committed. There is no multi-statement transaction support.Concurrent Writes
Writing to the same table from multiple processes simultaneously may cause conflicts. Use:- Separate staging tables
- Partitioned writes
- Sequential execution
Troubleshooting
”Access Denied” Errors
Problem: Cannot create table in schema. Solution: Verify you’re using the correct team namespace and have Data Transformations enabled.”Session Property Required” Error
Problem: Write operation rejected. Solution: Ensuretransformations=true is set in session properties.
Slow MERGE Operations
Problem: MERGE takes too long on large tables. Solution:- Add filters to reduce rows matched
- Run OPTIMIZE before MERGE
- Consider delete+insert for full partition updates
Table Not Visible in Dune App
Problem: Created table doesn’t appear in queries. Solution: Remember to use thedune. catalog prefix:
Examples
Complete examples and templates are available in the dune-dbt-template repository. See the/models/templates/ directory for:
- View model example
- Table model example
- Merge incremental model
- Delete+insert incremental model
- Append incremental model with deduplication