Skip to content

Views

Manage SQL views on Microsoft Fabric Data Warehouses and SQL Analytics Endpoints.

Targets: Data Warehouse / SQL Analytics Endpoint

CLI

views columns

Targets: Data Warehouse / SQL Analytics Endpoint

List the columns of a view, including name, formatted data type, nullability, ordinal position, collation, identity, and computed flags.

Synopsis

fdw [-w WORKSPACE] views columns [WAREHOUSE] QUALIFIED_NAME

QUALIFIED_NAME must be a dot-separated schema.view_name string, e.g. dbo.vw_sales.

Example

fdw -w MyWorkspace views columns SalesWH dbo.vw_sales
 ordinal  name    data_type     nullable  is_identity  is_computed  collation_name
 -------  ------  ------------  --------  -----------  -----------  ----------------------------
 1        id      INT           False     False        False
 2        amount  DECIMAL(18,2) True      False        False

views count

Targets: Data Warehouse / SQL Analytics Endpoint

Return the total row count of a view using SELECT COUNT_BIG(*).

Use --as-of or --ago to count rows as they were at an earlier point in time (time travel). The same retention window applies as for views read.

Synopsis

fdw [-w WORKSPACE] views count [OPTIONS] [WAREHOUSE] QUALIFIED_NAME
Option Description
--as-of ISO8601 Count rows as they were at this UTC timestamp. Mutually exclusive with --ago.
--ago DURATION Count rows as they were this duration ago (e.g. 1h, 90m, 2d). Mutually exclusive with --as-of.

Example

fdw -w MyWorkspace --json views count SalesWH dbo.vw_sales
{"schema": "dbo", "name": "vw_sales", "row_count": 12345}
# Point-in-time row count
fdw -w MyWorkspace --json views count SalesWH dbo.vw_sales --as-of 2024-03-15T10:00:00Z
fdw -w MyWorkspace --json views count SalesWH dbo.vw_sales --ago 1h

views export

Targets: Data Warehouse / SQL Analytics Endpoint

Export the full contents of a view to a local file in Parquet, CSV, or JSON format.

The output format is inferred from the --output extension (.parquet, .csv, .json, .pq). Use --format to override.

Memory caveat: the full result set is loaded into the Python process before writing. Ensure sufficient RAM, or use --limit to export a sample only. A streaming variant is a planned future follow-up.

Use --as-of or --ago to export the view's data as it was at an earlier point in time (time travel). The view definition itself is not affected; only the underlying data is time-travelled. The same retention window applies as for views read.

By default, if the output file already exists it is overwritten. Pass --no-overwrite to fail instead.

Synopsis

fdw [-w WORKSPACE] views export [OPTIONS] [WAREHOUSE] QUALIFIED_NAME
Option Description Default
--output PATH Required. Destination file path.
--format {csv\|json\|parquet} Output format. Inferred from extension when omitted. inferred
--limit N Export at most N rows (sampling). Omit for full export.
--no-overwrite Fail if --output already exists. overwrite
--as-of ISO8601 Export as it was at this UTC timestamp. Mutually exclusive with --ago.
--ago DURATION Export as it was this duration ago (e.g. 1h, 90m, 2d). Mutually exclusive with --as-of.

Example

# Full export to Parquet (format inferred from extension)
fdw -w MyWorkspace views export SalesWH dbo.vw_sales --output vw_sales.parquet

# Sample 200 rows as CSV
fdw -w MyWorkspace views export SalesWH dbo.vw_sales --output sample.csv --limit 200

# Point-in-time export
fdw -w MyWorkspace views export SalesWH dbo.vw_sales --output snapshot.parquet --ago 2d

# JSON output (machine-readable)
fdw -w MyWorkspace --json views export SalesWH dbo.vw_sales --output out.parquet
{"status": "exported", "rows": 12345, "output": "out.parquet"}

views create

Targets: Data Warehouse / SQL Analytics Endpoint

Create a new SQL view.

Synopsis

fdw [-w WORKSPACE] views create [OPTIONS] [WAREHOUSE]
Option Description
--name SCHEMA.VIEW Required. Qualified view name (e.g. dbo.vw_sales).
--select TEXT Inline SELECT statement for the view body.
--from-file PATH Path to a .sql file containing the SELECT statement.

Exactly one of --select or --from-file must be provided.

Example

fdw -w MyWorkspace views create SalesWH \
  --name dbo.vw_recent \
  --select "SELECT id, amount FROM dbo.sales WHERE sale_date >= '2026-01-01'"

views drop

Targets: Data Warehouse / SQL Analytics Endpoint

Drop a SQL view. You will be asked to confirm unless --yes is passed.

Synopsis

fdw [-w WORKSPACE] views drop [WAREHOUSE] QUALIFIED_NAME

Example

fdw -w MyWorkspace --yes views drop SalesWH dbo.vw_recent

views get

Targets: Data Warehouse / SQL Analytics Endpoint

Get the full definition of a single view.

Synopsis

fdw [-w WORKSPACE] views get [WAREHOUSE] QUALIFIED_NAME

QUALIFIED_NAME must be a dot-separated schema.view_name string, e.g. dbo.vw_sales.

Example

fdw -w MyWorkspace views get SalesWH dbo.vw_sales
schema_name    dbo
name           vw_sales
qualified_name dbo.vw_sales
created        2026-01-10T08:00:00Z
modified       2026-06-01T12:00:00Z
definition     SELECT id, amount FROM dbo.sales

views list

Targets: Data Warehouse / SQL Analytics Endpoint

List all views on a warehouse or SQL Analytics Endpoint. Pass --schema to filter to a single schema.

Synopsis

fdw [-w WORKSPACE] views list [OPTIONS] [WAREHOUSE]
Option Description
--schema TEXT Only list views in this schema.

Example

fdw -w MyWorkspace views list SalesWH --schema dbo
 schema_name  name         created               modified
 ------------ ------------ --------------------- ---------------------
 dbo          vw_sales     2026-01-10T08:00:00Z  2026-06-01T12:00:00Z
 dbo          vw_monthly   2026-02-01T09:00:00Z  2026-05-15T14:00:00Z

views read

Targets: Data Warehouse / SQL Analytics Endpoint

Read up to --count rows from a view and emit them as JSON (default), CSV, or Parquet.

CSV and Parquet formats require --output. JSON is emitted to stdout by default.

Use --as-of or --ago to read the view as it was at an earlier point in time (time travel). The data visible through the view is time-travelled; the view definition itself is not affected. Timestamps outside the Fabric retention window (1-120 days, default 30) error server-side.

Synopsis

fdw [-w WORKSPACE] views read [OPTIONS] [WAREHOUSE] QUALIFIED_NAME
Option Description Default
--count N Maximum rows to return. 10
--format {json\|csv\|parquet} Output format. json
--output PATH Write to file instead of stdout. Required for csv and parquet.
--as-of ISO8601 Read the view as it was at this UTC timestamp. Mutually exclusive with --ago.
--ago DURATION Read the view as it was this duration ago (e.g. 1h, 90m, 2d). Mutually exclusive with --as-of.

Example

fdw -w MyWorkspace views read SalesWH dbo.vw_sales --count 5
[
  {"id": 1, "amount": 99.99, "customer_id": 42},
  ...
]
# Point-in-time read
fdw -w MyWorkspace views read SalesWH dbo.vw_sales --as-of 2024-03-15T10:00:00Z
fdw -w MyWorkspace views read SalesWH dbo.vw_sales --ago 2d

views rename

Targets: Data Warehouse / SQL Analytics Endpoint

Rename a SQL view via sp_rename. The new name must be an unqualified (bare) identifier - sp_rename cannot move a view to a different schema.

Synopsis

fdw [-w WORKSPACE] views rename [OPTIONS] [WAREHOUSE] QUALIFIED_NAME

QUALIFIED_NAME is the current dot-separated schema.view_name.

Option Description
--new-name TEXT Required. New bare view name (no schema prefix).

Example

fdw -w MyWorkspace views rename SalesWH dbo.vw_recent --new-name vw_revenue

views transfer

Targets: Data Warehouse / SQL Analytics Endpoint

Move a view to another schema via ALTER SCHEMA ... TRANSFER OBJECT::.... The command emits exactly ALTER SCHEMA [target_schema] TRANSFER OBJECT::[schema].[view], with every identifier validated and bracket-quoted before being embedded in the DDL.

CAUTION: OBJECT::[schema].[name] matches any schema-scoped object with that name, not only views. If a table, function, or procedure shares the qualified name, the engine transfers that object instead.

Definition text is not rewritten

ALTER SCHEMA ... TRANSFER moves the view, but it does not rewrite the schema name inside the object's stored definition (sys.sql_modules.definition, OBJECT_DEFINITION()). After a transfer, get_view may still show the old schema name in the CREATE ... AS header, even though the view now lives in the new schema. This tool does not rewrite the definition text: doing so would require parsing and regenerating SQL, which this project deliberately avoids. See ALTER SCHEMA (Transact-SQL).

Synopsis

fdw [-w WORKSPACE] views transfer [OPTIONS] [ITEM] QUALIFIED_NAME

QUALIFIED_NAME is the current dot-separated schema.view_name.

Option Description
--target-schema TEXT Required. Schema to move the view into.

Example

fdw -w MyWorkspace views transfer SalesWH dbo.vw_recent --target-schema archive

views update

Targets: Data Warehouse / SQL Analytics Endpoint

Redefine an existing view using CREATE OR ALTER VIEW.

Synopsis

fdw [-w WORKSPACE] views update [OPTIONS] [WAREHOUSE] QUALIFIED_NAME

QUALIFIED_NAME is the dot-separated schema.view_name to update.

Option Description
--select TEXT Inline SELECT statement for the new view body.
--from-file PATH Path to a .sql file containing the new SELECT statement.

Exactly one of --select or --from-file must be provided.

Example

fdw -w MyWorkspace views update SalesWH dbo.vw_recent \
  --select "SELECT id, amount, region FROM dbo.sales WHERE sale_date >= '2026-01-01'"

MCP tools

count_view_rows

Targets: Data Warehouse / SQL Analytics Endpoint

Return the total row count of a view via SELECT COUNT_BIG(*).

Supports time-travel counts via as_of: supply an ISO-8601 UTC timestamp to count rows as they were at that point in time. The same retention window applies as for read_view.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated schema and view name, e.g. dbo.vw_sales.
  • as_of (str, optional): ISO-8601 UTC timestamp for a point-in-time count. Omit to count the latest data.

Returns: { "schema": str, "name": str, "row_count": int }: the schema name, view name, and total row count.

create_view

Targets: Data Warehouse / SQL Analytics Endpoint

Create a new SQL view.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated schema and view name, e.g. dbo.vw_sales.
  • select_body (str): the SELECT statement that forms the view body; executed verbatim as DDL.

Returns: View: the newly-created view object (fetched after DDL, includes definition).

drop_view

Targets: Data Warehouse / SQL Analytics Endpoint

Drop a SQL view.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated schema and view name, e.g. dbo.vw_sales.

Returns: { "dropped": true }: confirmation.

get_view

Targets: Data Warehouse / SQL Analytics Endpoint

Fetch the full definition of a single SQL view.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated schema and view name, e.g. dbo.vw_sales.

Returns: View: single view object with definition populated from sys.sql_modules.

get_view_columns

Targets: Data Warehouse / SQL Analytics Endpoint

Return column metadata for a SQL view via sys.columns. Works on both Fabric Data Warehouses and SQL Analytics Endpoints.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated view name, e.g. dbo.vw_sales.

Returns: list[dict]: one dict per column, each containing:

  • ordinal (int): 1-based column position (column_id).
  • name (str): column name.
  • data_type (str): formatted T-SQL type string, e.g. INT, NVARCHAR(MAX), DECIMAL(18,2).
  • nullable (bool): whether the column allows NULL.
  • collation_name (str | null): collation name, if applicable.
  • is_identity (bool): whether the column is an identity column.
  • is_computed (bool): whether the column is a computed column.

Results are ordered by ordinal position. Raises a ToolError if the view does not exist.

list_views

Targets: Data Warehouse / SQL Analytics Endpoint

List SQL views on a warehouse or SQL Analytics Endpoint, optionally filtered to a single schema.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • schema (str | null, optional): when provided, only views in this schema are returned; must be a valid SQL identifier.

Returns: list[View]: array of view objects, each with schema_name, name, qualified_name, created, modified, and definition (always null for list results).

read_view

Targets: Data Warehouse / SQL Analytics Endpoint

Return up to count rows from a view as JSON-serialisable columns and rows.

Supports time-travel reads via as_of: supply an ISO-8601 UTC timestamp to read the view as it was at that point in time. The Fabric retention window is 1-120 days (default 30); timestamps outside the window error server-side.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated schema and view name, e.g. dbo.vw_sales.
  • count (int, default 10): maximum rows to return.
  • as_of (str | null, optional): ISO-8601 UTC timestamp for a point-in-time read, e.g. 2024-03-15T10:00:00Z. Omit to read the latest data.

Returns: { "columns": list[str], "rows": list[list] }: column names and row arrays.

rename_view

Targets: Data Warehouse / SQL Analytics Endpoint

Rename a SQL view via sp_rename. Works on both Data Warehouses and SQL Analytics Endpoints. The new name must be a bare (unqualified) identifier - sp_rename cannot move a view across schemas.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): current dot-separated qualified view name, e.g. dbo.vw_sales.
  • new_name (str): new bare view name (no schema prefix), e.g. vw_revenue.

Returns: View: the updated view object (fetched after rename, includes definition).

transfer_view

Targets: Data Warehouse / SQL Analytics Endpoint

Move a SQL view to another schema via ALTER SCHEMA ... TRANSFER OBJECT::.... Works on both Fabric Data Warehouses and SQL Analytics Endpoints, no DW-only guard is applied.

CAUTION: OBJECT::[schema].[name] matches any schema-scoped object with that name, not only views. If a table, function, or procedure shares the qualified name, the engine transfers that object instead.

Definition text is not rewritten

ALTER SCHEMA ... TRANSFER moves the view, but it does not rewrite the schema name inside the object's stored definition (sys.sql_modules.definition, OBJECT_DEFINITION()). After a transfer, get_view may still show the old schema name in the CREATE ... AS header, even though the view now lives in the new schema. This tool does not rewrite the definition text: doing so would require parsing and regenerating SQL, which this project deliberately avoids. See ALTER SCHEMA (Transact-SQL).

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): current dot-separated qualified view name, e.g. dbo.vw_sales.
  • target_schema (str): schema to move the view into, e.g. archive.

Returns: View: the moved view record, fetched from the new schema. The definition field may still reference the old schema name (see warning above).

update_view

Targets: Data Warehouse / SQL Analytics Endpoint

Redefine an existing SQL view using CREATE OR ALTER VIEW.

Parameters:

  • workspace (str): workspace name or GUID.
  • item (str): warehouse or SQL analytics endpoint name or GUID.
  • qualified_name (str): dot-separated schema and view name, e.g. dbo.vw_sales.
  • select_body (str): the new SELECT statement; executed verbatim as DDL.

Returns: View: the updated view object (fetched after DDL, includes definition).