After you create a data table, you can use Fast Modeling Language (FML) statements in the code editor to configure table fields and partitions. This topic describes how to use FML statements to configure a data table.
Features
Fast Modeling Language (FML) is a language that uses standard SQL-like syntax to design data tables in dimensional modeling. In DataWorks, the design of a data model (a logical table) is decoupled from its materialization. When you design a logical table, you do not need to consider how it will be materialized on different big data engines. The modeling engine uses the schema defined in FML to perform operations on the underlying big data engines. During materialization, the modeling engine converts the logical table into a physical table for your selected engine. The engine then translates the FML statements into SQL syntax that the target engine can recognize, and submits and runs the statements.
Preparations
DataWorks does not support creating data tables using FML. You must first create a logical table using the visual interface. You can create the following types of tables:
Limits
DataWorks does not support using FML statements to create data tables or change table names. You can use FML statements only for editing operations on existing tables, such as editing fields, configuring associations, and configuring partitions.
You can use FML statements to materialize data tables only to the MaxCompute, Hologres, and Hive engines.
FML uses SQL keywords as reserved words. If your table name or a field name is a keyword, you must enclose it in backticks (
``). Otherwise, an error occurs when you configure the table.
Go to the FML editor of a table
On the Dimensional Modeling page, double-click the name of the table in the directory tree.
On the Table Details page, click Code Editor.
In the FML editor on the Code Editor tab, you can view the FML CREATE TABLE statement for the table. You can also configure or modify the fields of the table. For more information, see Configure a table.

Configure a table
For ease of reference, all statements for configuring tables are presented in the format of a CREATE TABLE statement. Note that data modeling in DataWorks does not support creating tables using FML statements. When you use this feature, you need to refer only to the statements that define table content, such as constraints and partitions. The format of the FML statement for configuring the target table is as follows:
--Create a new table
CREATE <table_type> TABLE
IF NOT EXISTS
--Table name
<table_name> [ALIAS <alias>]
--Define column properties
<col_name> [ALIAS <alias>] <datatype> [<category>] [COMMENT <comment>] [WITH (<key>=<value>,....)]
--Define constraints
PRIMARY KEY (<col_name>),
--Dimension constraint
CONSTRAINT <constraint_name> DIM KEY (<col_name>) REFERENCES <ref_table_name> (<ref_table_col_name>),
--Hierarchy constraint
CONSTRAINT <constraint_name> LEVEL <col_name:(<col_name>)>, --Group constraint
CONSTRAINT <constraint_name> COLUMN_GROUP(<col_name>,...),
--Define comment
COMMENT 'comment'
--Define partitions
PARTITION BY (col DATATYPE COMMENT 'comment' WITH ('key'='value',...), ...)
--Define properties
WITH ('key'='value', 'key1'='value1', ...)
;
tableType
: dimDetailType? DIM
| factDetailType? FACT
| CODE
| DWS
;
dimDetailType
: NORMAL
| LEVEL
| ENUM
;
factDetailType
: TRANSACTION
| AGGREGATE
| PERIODIC_SNAPSHOT
| ACCUMULATING_SNAPSHOT
| CONSOLIDATED
;
comment
: COMMENT 'comment'
;
Parameter | Description |
tableName | The name of the data table. We recommend that the name consists of letters, digits, and underscores (_) and is no more than 128 characters long. |
if not exists | If a table with the same name already exists in the target engine and you do not specify |
alias | The alias of the table or a field in the table. This parameter is usually used to define the Chinese name of the data table. This parameter is optional. |
tableType | The type of table to create. You can use FML statements to create the following types of tables:
|
comment | The comment for the table. We recommend that the comment is no more than 1,024 characters long. |
columnDefinition | The definition of a table column. It can include the following parameters:
Note FML statements support designing a table first and materializing it later. Therefore, a newly created table does not need to have column information. |
constraint | Defines the constraints of the table schema. Valid values are:
|
Partitioned BY | Creates partitions for the table. |
WITH | Custom information that you can define when you create a table. Use the |