Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions docs/generators/bigquery.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
BigQuery DDL
============

Overview
--------

The BigQuery DDL generator produces native `Google BigQuery <https://cloud.google.com/bigquery>`_
``CREATE TABLE`` statements from a LinkML schema. It extends the SQL DDL generator with
BigQuery-specific types (``ARRAY<T>``, ``STRUCT<...>``, ``TIMESTAMP``) and supports
BigQuery table options such as time/range partitioning, clustering, and table descriptions
via LinkML annotations.

.. note::

This generator requires the ``sqlalchemy-bigquery`` optional dependency.
Install it with: ``pip install 'linkml[bigquery]'``

Example Output
--------------

Given a schema with a ``Person`` class, the generator produces DDL like:

.. code-block:: sql

CREATE TABLE `Person` (
id STRING NOT NULL,
name STRING,
age INT64,
aliases ARRAY<STRING>
);

BigQuery Annotations
--------------------

You can control BigQuery-specific table options via slot/class annotations:

- ``bigquery_type`` — override the column type (e.g. ``TIMESTAMP``)
- ``bigquery_partition_by`` — field name to use for time/range partitioning
- ``bigquery_partition_type`` — ``DAY``, ``HOUR``, ``MONTH``, ``YEAR``, or ``RANGE``
- ``bigquery_cluster_by`` — comma-separated field names for clustering
- ``bigquery_description`` — table-level description string

Docs
----

Command Line
^^^^^^^^^^^^

.. currentmodule:: linkml.generators.bigquerygen

.. click:: linkml.generators.bigquerygen:cli
:prog: gen-bigquery
:nested: short

Code
^^^^

.. autoclass:: BigQueryGenerator
:members: serialize, generate_ddl
1 change: 1 addition & 0 deletions docs/generators/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Generators specific to database frameworks, including SQL and graph databases.
sqltable
sqlalchemy
sqlvalidation
bigquery
typedb

Others
Expand Down
7 changes: 6 additions & 1 deletion packages/linkml/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
{name = "Sierra Moxon", email = "smoxon@lbl.gov"},
{name = "Harold Solbrig", email = "solbrig@jhu.edu"},
{name = "Sujay Patil", email = "spatil@lbl.gov"},
{name = "Harshad Hegde", email = "hhegde@lbl.gov"},
{name = "Harshad Hegde", email = "hegdehb@gmail.com"},
{name = "Mark Andrew Miller", email = "MAM@lbl.gov"},
{name = "Deepak Unni"},
{name = "Gaurav Vaidya", email = "gaurav@renci.org"},
Expand Down Expand Up @@ -80,6 +80,7 @@ tests = [
{ include-group = "typing" },
{ include-group = "shacl" },
"duckdb>=1.5.2",
"sqlalchemy-bigquery >= 1.9.0",
]
dev = [
{include-group = "tests" },
Expand Down Expand Up @@ -111,6 +112,9 @@ tests-rustgen = [
typedb = [
"typedb-driver >= 3.0, < 4.0",
]
bigquery = [
"sqlalchemy-bigquery >= 1.9.0",
]

tests-extra = [
"pytest >= 7.4.0",
Expand Down Expand Up @@ -178,6 +182,7 @@ gen-sqla = "linkml.generators.sqlalchemygen:cli"
gen-sqlddl = "linkml.generators.sqltablegen:cli"
gen-sqltables = "linkml.generators.sqltablegen:cli"
gen-sqlvalidation = "linkml.generators.sqlvalidationgen:cli"
gen-bigquery = "linkml.generators.bigquerygen:cli"
gen-summary = "linkml.generators.summarygen:cli"
gen-project = "linkml.generators.projectgen:cli"
run-tutorial = "linkml.utils.execute_tutorial:cli"
Expand Down
Loading
Loading