mc table view create
The mc table view create command creates a new Iceberg view on a MinIO AIStor cluster.
Views are virtual tables defined by SQL queries. You can provide multiple SQL representations with different dialects for cross-engine compatibility.
The following command creates a view named monthly_sales in the prod namespace of the analytics warehouse on the myaistor MinIO AIStor cluster:
mc table view create myaistor analytics prod monthly_sales --sql "SELECT * FROM sales WHERE month = 1"The command has the following syntax:
mc [GLOBALFLAGS] table view create \
ALIAS \
WAREHOUSE \
NAMESPACE \
VIEW_NAME \
--sql "SQL" \
[--attr "key=value"] \
[--ignore-existing]- Brackets
[]indicate optional parameters. - Parameters sharing a line are mutually dependent.
- Parameters separated using the pipe
|operator are mutually exclusive.
Copy the example to a text editor and modify as-needed before running the command in the terminal/shell.
Parameters
ALIAS
Required
The alias of a MinIO AIStor cluster on which to create the view.
NAMESPACE
Required
The name of the namespace in which to create the view.
VIEW_NAME
Required
The name of the view to create.
WAREHOUSE
Required
The name of the warehouse containing the target namespace.
--sql
Required
The SQL query that defines the view. Can be specified multiple times with a dialect prefix for different query engines.
Use the format dialect:SQL to specify a dialect-specific SQL representation:
spark:SELECT ...for Spark SQL syntaxtrino:SELECT ...for Trino SQL syntax
Without a dialect prefix, the SQL is treated as a generic representation.
--attr
Alias: -a
Optional
Add a custom property for the view in key=value format.
You can specify multiple --attr parameters to add multiple properties.
--ignore-existing
Alias: -p
Optional
Do not return an error if a view with the specified name already exists.
Global flags
This command supports any of the global flags.
Examples
Create a simple view
Use mc table view create to create a view with a SQL query:
mc table view create myaistor analytics prod monthly_sales --sql "SELECT * FROM sales WHERE month = 1"Create a view with a specific dialect
Use the dialect prefix to specify the SQL syntax:
mc table view create myaistor analytics prod monthly_sales --sql "spark:SELECT * FROM sales"Create a view with multiple dialect-specific SQL representations
Specify multiple SQL representations for different query engines:
mc table view create myaistor analytics prod monthly_sales --sql "spark:SELECT * FROM sales" --sql "trino:SELECT * FROM sales"Create a view with custom properties
Use the --attr flag to add custom properties:
mc table view create myaistor analytics prod monthly_sales --sql "SELECT * FROM sales" --attr owner=data-team --attr env=production