LLMs to turn Ad Hoc Questions into Real-Time AnswersRegister

Skip to main content

MD_CREATE_DIVE

Public Preview

Dives are currently in public preview and functionality is subject to change.

Creates a new Dive in your MotherDuck account. Returns the created Dive's metadata and initial version information.

Syntax

SELECT * FROM MD_CREATE_DIVE(
title ='My Dive',
content ='<JSX component code>',
description ='A brief description',
api_version =1
);

Parameters

ParameterTypeRequiredDescription
titleVARCHARYesThe title of the Dive
contentVARCHARYesThe JSX/React component code
descriptionVARCHARNoA brief description of the Dive
api_versionUINTEGERNoAPI version for the Dive format. Defaults to 1.

Return Columns

ColumnTypeDescription
idUUIDUnique identifier of the created Dive
titleVARCHARDive title
descriptionVARCHARDive description
owner_idUUIDUUID of the Dive owner
current_versionINTEGERVersion number (1 for newly created Dives)
created_atTIMESTAMP WITH TIME ZONEWhen the Dive was created
updated_atTIMESTAMP WITH TIME ZONEWhen the Dive was last updated
owner_nameVARCHARName of the Dive owner
version_idUUIDUUID of the initial version
version_storage_urlVARCHARStorage URL of the version content
version_descriptionVARCHARDescription for this version
version_created_atTIMESTAMP WITH TIME ZONEWhen this version was created
version_api_versionUINTEGERAPI version used

Examples

Create a Dive with title and content:

SELECT id, title, current_version
FROM MD_CREATE_DIVE(
title ='Revenue Trends',
content ='import { useSQLQuery } from "@motherduck/react-sql-query";
export default function Dive() {
const { data } = useSQLQuery(`SELECT * FROM sales`);
return <div>{JSON.stringify(data)}</div>;
}'
);

Create a Dive with a description:

SELECT *
FROM MD_CREATE_DIVE(
title ='Monthly Revenue',
description ='Line chart of revenue by month',
content ='<component code>'
);