HDML, or Hyperdata Markup Language, is a markup language designed for describing hierarchical data structures in a web-based environment. It provides a set of custom HTML components to represent and organize various data models. HDML is particularly useful for creating structured and interactive representations of complex data relationships on the web.
HDML supports the concept of Distributed Documents, allowing you to split one document into several independent documents for security or organizational reasons. This approach enables you to reference and include external documents where necessary.
-
Separation of Concerns:
- Distributed Documents facilitate the separation of different aspects of your data model for better organization and security.
-
External Inclusion:
- Use the concept of Distributed Documents to split your model into modular components.
-
HDIO Server Processing:
- The merging of included documents and processing occur on the HDIO (Hyperdata Input-Output) server.
-
SQL Query Generation:
- Included documents contribute to the generation of an SQL query, executed on the server.
The HDIO (Hyperdata Input-Output) server is a critical component in the HDML (Hyperdata Markup Language) ecosystem. It plays a central role in the processing, execution, and management of HDML documents, especially in the context of Distributed Documents and the hdml-include component.
-
Document Merging and SQL Query Execution:
- The HDIO server is responsible for merging included documents specified by the
<hdml-include>component in the main document. - It generates SQL queries based on the processed HDML document structure and executes them against relevant data sources.
- The HDIO server is responsible for merging included documents specified by the
-
Load Balancing:
- HDIO ensures balanced distribution of queries to prevent data sources from being overloaded, particularly in scenarios involving analytical queries.
-
Security and Access Control:
- The HDIO server provides authentication mechanisms to secure document processing and SQL query execution.
- It facilitates the use of environment variables for managing secrets and sensitive information.
-
Environment Variable Support:
- HDIO allows the specification of environment variables that can be utilized to securely store and manage confidential information, such as database credentials.
-
Result Delivery in Apache Arrow Format:
- HDIO delivers query results in the Apache Arrow format, providing a columnar in-memory data representation.
- Apache Arrow offers benefits such as efficient data transfer, improved performance, and compatibility across different programming languages.
-
Execution Optimization:
- HDIO optimizes the execution of SQL queries, ensuring efficient processing and minimizing the load on data sources.
-
Document Ingestion:
- HDML documents, including hidden and main documents, are ingested by the HDIO server.
-
Merging and Processing:
- The server merges included documents specified by
<hdml-include>, creating a cohesive structure for further processing.
- The server merges included documents specified by
-
SQL Query Generation and Execution:
- Based on the merged document structure, the HDIO server generates SQL queries and executes them against the relevant database or system.
-
Load Balancing and Optimization:
- HDIO optimizes query execution and ensures even distribution of queries to prevent overloading data sources.
-
Result Delivery to Client in Apache Arrow Format:
- Only the result of the SQL query, formatted in Apache Arrow, is sent to the client. This format offers advantages in terms of data transfer efficiency, improved analytics, and cross-language compatibility.
The HDIO server significantly enhances the functionality, security, and efficiency of the HDML language, particularly in distributed and data-intensive scenarios.
HDML (Hyperdata Markup Language) supports the use of environment variables within attributes, allowing for dynamic and secure configuration. This feature enables the referencing of environment variables directly in HDML attributes, enhancing flexibility and facilitating the management of sensitive information, such as credentials.
To include an environment variable in an HDML attribute, use the following syntax:
<hdml-element
attribute="${ENV_VARIABLE_NAME}">
</hdml-element>Replace ENV_VARIABLE_NAME with the name of the desired environment variable.
Consider the following example where an environment variable is used within the host attribute of an <hdml-connection> element:
<hdml-connection
name="MyDatabase"
type="postgres"
host="${DB_HOST}"
user="user"
password="password">
</hdml-connection>In this case, the value of the host attribute is dynamically set to the value of the DB_HOST environment variable.
Using environment variables in HDML attributes provides several advantages that enhance flexibility, security, and adaptability in web application development:
-
Dynamic Configuration:
- HDML attributes can be dynamically configured based on environment variables, allowing for easy adaptation to different environments without modifying the HDML document. This flexibility is especially beneficial during development, testing, and production stages.
-
Secure Credential Management:
- Sensitive information, such as database credentials, can be securely managed by storing them as environment variables. By referencing these variables in HDML attributes, the actual credentials are kept external to the HDML document, reducing the risk of exposing sensitive data.
-
Environment-Agnostic Documents:
- HDML documents can be designed to be environment-agnostic, meaning they can seamlessly function in various environments with distinct configurations. By leveraging environment variables, you create a more portable and adaptable web application.
To ensure effective and secure utilization of environment variables within HDML attributes, consider adopting the following best practices:
-
Consistent Naming Conventions:
- Adopt a consistent and descriptive naming convention for environment variables. This practice enhances clarity and makes it easier for developers to identify and understand the purpose of each variable.
-
Secure Handling of Sensitive Variables:
- Exercise caution when using environment variables that contain sensitive information, such as database credentials. Ensure that these variables are properly protected and not exposed unintentionally.
-
Documentation and Comments:
- Clearly document the use of environment variables within your HDML document. Include comments explaining the purpose of each variable and any dependencies. This documentation enhances the understanding of your configuration model.
By incorporating environment variables in HDML attributes, you can create more versatile, secure, and adaptable configurations for your web applications.
Hook functions in HDIO serve as a powerful mechanism for customizing HDML documents on the server side. These functions are exported, named hook, and reside in a specific hook folder on the HDIO server. The HDIO server automatically discovers and executes these functions during the document processing pipeline, allowing users to dynamically modify the merged HDML document based on various conditions, including authentication details.
-
Exported Function: The hook function must be exported from its module and named
hook. The server automatically detects and executes this function. -
Location: Place the file containing the
hookfunction in the designated hook folder on the HDIO server. -
Parameters:
dom(Type:Element): The HTML element representing the HDML document.scope(Type:Object): The context derived from the HTTP token of the initial request, typically containing authentication details.
-
Return Value: The hook function must return the modified or unmodified HTML element (
dom).
Create a file named hook.js with the following content and place it in the hook folder on the HDIO server:
// hook.js
/**
* Hook function for customizing the HDML document.
* @param {Element} dom - The HTML element representing the HDML document.
* @param {Object} scope - The context taken from the HTTP token of the initial request, typically containing authentication details.
* @returns {Element} - The modified or unmodified HTML element.
*/
export function hook(dom, scope) {
// Add your custom logic here, utilizing the provided `dom` and
// `scope` parameters. For example, you can conditionally modify
// the document based on the authenticated user's context.
// Return the modified or unmodified HTML element
return dom;
};-
Create a Hook Function File:
- Write a hook function named
hookin a file. - Export the function to make it accessible.
- Write a hook function named
-
Place the File in the Hook Folder:
- Save the hook function file in the specific hook folder on the HDIO server.
-
Leverage Authentication Context:
- Utilize the
scopeparameter to access the authentication context from the HTTP token. - Make decisions or perform actions based on the authenticated user's context.
- Utilize the
-
Dynamic Document Customization:
- Hook functions enable real-time customization of HDML documents based on the current user's authentication context.
-
Secure Server-Side Execution:
- Hook functions execute on the server side within a secure context, ensuring that sensitive data and operations are handled securely.
-
Authentication-Driven Modifications:
- Leverage the authentication context (
scope) to drive document modifications based on the user's identity or permissions.
- Leverage the authentication context (
-
Decentralized Configuration:
- By storing hook functions in a dedicated folder, configuration remains decentralized, making it easier to manage and update individual customization logic.
-
No Registration Required:
- There's no need to register hook functions explicitly. Placing the file in the designated folder makes it automatically accessible to the HDIO server.
-
Security: Ensure that the hook function handles external data securely, especially when making decisions based on the authentication context.
-
Hook Folder: Make sure to place the hook function file in the designated hook folder on the HDIO server for automatic discovery.
By following these instructions, users can create and deploy hook functions to tailor HDML documents based on the authentication context, providing a flexible and secure customization mechanism.
The <hdml-include> component is used to include external HDML documents within another document. It serves as a mechanism to link separate documents and merge their content during processing on the HDIO (Hyperdata Input-Output) server.
<hdml-include
path="/path/to/external-document.hdml">
</hdml-include>path(Required): The path to the external HDML document on the HDIO (Hyperdata Input-Output) server that you want to include.
Assuming you have a hidden document with connection definitions named connections.hdml:
<!-- connections.hdml - Hidden Document with Connection Definitions -->
<hdml-connection
name="connection-1"
type="postgres"
host="localhost"
user="user1"
password="pass1"
ssl="true"
meta="Connection 1">
</hdml-connection>
<!-- Add more connections as needed -->You can use the hdml-include component in your main document:
<!-- main-models.hdml - Main Document with Model Definitions -->
<hdml-include
path="/path/to/connections.hdml">
</hdml-include>
<!-- Define models with references to named connections -->
<hdml-model
name="Model1">
<hdml-table
name="`connection-1`.`public`.`users`">
<!-- ... fields ... -->
</hdml-table>
</hdml-model>
<!-- Add more models and components as needed -->The hdml-connection component represents a connection to a database. It is used to define the connection details for various database types.
-
name(Required): The name of the connection. -
type(Required): The type of the database. Available types are:postgresmysqlmssqlmariadboracleclickhousedruidigniteredshiftbigquerygooglesheetselasticsearchmongodb
-
meta(Optional): Additional metadata or description for the connection.
The hdml-connection component allows you to specify the name and type attributes to identify and categorize your database connections. Choose the appropriate type based on the database system you are connecting to.
For the following database types: Postgres, MySQL, MS SQL, MariaDB, Oracle, ClickHouse, Druid, Ignite, Redshift, you can use the following common parameters:
| Attribute | Description | Required | Default |
|---|---|---|---|
ssl |
A boolean value indicating whether SSL is enabled. | No | false |
host |
The host address of the database. | Yes | - |
user |
The username for authentication. | Yes | - |
password |
The password for authentication. | Yes | - |
meta |
Additional metadata or description for the connection. | No | - |
For the bigquery database type, you can use the following parameters:
| Attribute | Description | Required | Default |
|---|---|---|---|
project-id |
The ID of the Google Cloud Platform (GCP) project. | Yes | - |
credentials-key |
The path to the JSON file containing GCP credentials. | Yes | - |
meta |
Additional metadata or description for the connection. | No | - |
For the googlesheets database type, you can use the following parameters:
| Attribute | Description | Required | Default |
|---|---|---|---|
sheet-id |
The ID of the Google Sheets document. | Yes | - |
credentials-key |
The path to the JSON file containing Google API credentials. | Yes | - |
meta |
Additional metadata or description for the connection. | No | - |
For the elasticsearch database type, you can use the following parameters:
| Attribute | Description | Required | Default |
|---|---|---|---|
host |
The host address of the Elasticsearch server. | Yes | - |
port |
The port number on which Elasticsearch is running. | No | 9200 |
user |
The username for authentication. | No | - |
password |
The password for authentication. | No | - |
ssl |
A boolean value indicating whether SSL is enabled. | No | false |
region |
The region where the Elasticsearch server is located. (Required for AWS deployment) | Yes | - |
access-key |
The access key for AWS authentication. | No | - |
secret-key |
The secret key for AWS authentication. | No | - |
meta |
Additional metadata or description for the connection. | No | - |
For the mongodb database type, you can use the following parameters:
| Attribute | Description | Required | Default |
|---|---|---|---|
host |
The host address of the MongoDB server. | Yes | - |
port |
The port number on which MongoDB is running. | Yes | 27017 |
user |
The username for authentication. | Yes | - |
password |
The password for authentication. | Yes | - |
ssl |
A boolean value indicating whether SSL is enabled. | No | false |
schema |
The name of the MongoDB collection containing schema information. | Yes | - |
meta |
Additional metadata or description for the connection. | No | - |
<hdml-connection
name="myDatabase"
type="postgres"
host="example.com"
user="user"
password="pass">
</hdml-connection>In this example, the PostgreSQL connection is configured directly within the HDML document without utilizing environment variables.
<hdml-connection
name="myDatabase"
type="postgres"
host="${DB_HOST}"
user="${DB_USER}"
password="${DB_PASSWORD}">
</hdml-connection>In this example, environment variables are used to parameterize the PostgreSQL connection configuration. The ${DB_HOST}, ${DB_USER}, and ${DB_PASSWORD} placeholders are placeholders that will be replaced with the actual values from the environment when the HDML document is processed.
Make sure that the environment variables (DB_HOST, DB_USER, DB_PASSWORD) are set appropriately before processing the HDML document.
These examples showcase how you can configure database connections both directly and using environment variables within the hdml-connection component. Adjust the attribute values according to your specific database setup and requirements.
The hdml-model component represents a data model within the HDML structure. It serves as a container for organizing various tables, joins, and relationships that define the structure of the data.
name(Required): The name of the data model.meta(Optional): Additional metadata or description for the model.
<hdml-model
name="EmployeeData">
<!-- Tables within the data model -->
<hdml-table
name="employee"
type="table"
identifier="`database`.`schema`.`employee_table`">
<!-- ... fields ... -->
</hdml-table>
<hdml-table
name="department"
type="query"
identifier="SELECT * FROM `database`.`schema`.`department_table`">
<!-- ... fields ... -->
</hdml-table>
<!-- Join tables using hdml-join -->
<hdml-join
type="inner"
left="employee"
right="department">
<!-- Additional join configuration -->
</hdml-join>
<!-- Additional tables, joins, and relationships can be added here -->
</hdml-model>In this example, the hdml-model component named "EmployeeData" contains tables (hdml-table) and a join (hdml-join) that define the data structure. Adjust the attributes and content based on your specific data modeling requirements.
The hdml-table component represents a table within a data model in the HDML structure. It provides a way to define and organize data tables, whether they are actual tables, views, or materialized views from a database or the result of a SQL query.
name(Required): The name of the table.type(Required): The type of the table, either "table" for an actual database table, view, or materialized view, or "query" for a table generated from a SQL query.identifier(Required): The unique identifier for the table, which should include the full three-tier table name for database tables, views, or materialized views, enclosed in back quotes.meta(Optional): Additional metadata or description for the table.
<hdml-table
name="employee"
type="table"
identifier="`database`.`schema`.`employee_table`">
<!-- ... fields ... -->
</hdml-table>
<hdml-table
name="department"
type="table"
identifier="`database`.`schema`.`department_view`">
<!-- ... fields ... -->
</hdml-table>
<hdml-table
name="sales_data"
type="query"
identifier="SELECT * FROM `database`.`schema`.`sales_materialized_view`">
<!-- ... fields ... -->
</hdml-table>In these examples, the hdml-table components represent a database table named "employee," a database view named "department," and a materialized view named "sales_data." Adjust the attributes and content based on your specific data modeling requirements.
The hdml-field component represents a field within an hdml-table in the HDML context.
name(Required): The name of the field in the HDML context.origin(Optional): The name of the original field in the database if used within the scope ofhdml-table, or in the parent structure if used within the scope of anhdml-frame. If omitted, it is assumed to be the same as the HDML field name.type(Optional): The data type of the field in the HDML context. Supported types include:int-8,int-16,int-32,int-64,uint-8,uint-16,uint-32,uint-64,float-16,float-32,float-64,binary,utf-8,decimal,date,time,timestamp.nullable(Optional, default:false): Specifies whether the field can contain null values.clause(Optional): An SQL clause defining the field. It takes precedence over theoriginattribute. For example,clause="concat(`table_catalog`, '-', `table_schema`, '-', `table_name`)".agg(Optional, applicable inhdml-frame): Specifies an aggregation function for the field. Supported functions include:none,count,countDistinct,countDistinctApprox,sum,avg,min,max.asc(Optional, applicable inhdml-frame): Specifies the type of sorting for the field. Usetruefor ascending andfalsefor descending.meta(Optional): Additional metadata or description for the field.
scale(Optional): The number of decimal places.precision(Optional): The total number of digits, including both the integer and fractional parts.bit-width(Optional): The bit width of the decimal field. Supported values include128and256.
unit(Optional): Specifies the date format unit. Supported values includesecondandmillisecond.
unit(Optional): Specifies the timestamp format unit. Supported values includesecond,millisecond,microsecond, andnanosecond.timezone(Optional): Specifies the timezone for the timestamp field.
-
originAttribute: Theoriginattribute, if specified, represents the original field name in the database if used within the scope ofhdml-table, or in the parent structure if used within the scope of anhdml-frame. This attribute allows you to map the HDML field to its counterpart in the database orhdml-model, or parenthdml-frame. -
typeAttribute: Thetypeattribute represents the data type of the field in the HDML context. It does not necessarily mirror the original data type of the field in the database. For example, you may usetype="decimal"in HDML, even if the original field in the database is of a different numeric type. This attribute allows flexibility in defining the data type as it should be treated within the HDML structure.
<hdml-table
type="table"
identifier="`database`.`schema`.`your_table`">
<hdml-field
name="employee_name"
origin="emp_name"
type="utf-8"
nullable="false">
</hdml-field>
<hdml-field
name="full_name"
clause="concat(`first_name`, ' ', `last_name`)"
type="utf-8">
</hdml-field>
</hdml-table>In this example, we define two fields within the database.schema.your_table table. The employee_name field maps to the emp_name field in the database, specifying a UTF-8 data type and a non-nullable constraint. The full_name field is created using an SQL concat clause, combining the first_name and last_name fields.
<hdml-table
type="table"
identifier="`database`.`schema`.`your_table`">
<hdml-field
name="price"
type="decimal"
scale="2"
precision="10"
bit-width="128"
nullable="false">
</hdml-field>
</hdml-table>In this example, the hdml-field component with type="decimal" includes additional attributes to specify the scale, precision, and bit-width.
<hdml-table
type="table"
identifier="`database`.`schema`.`your_table`">
<hdml-field
name="event_date"
type="date"
unit="millisecond"
nullable="false">
</hdml-field>
</hdml-table>In this example, the hdml-field component with type="date" includes the additional unit attribute to specify the date format.
<hdml-table
type="table"
identifier="`database`.`schema`.`your_table`">
<hdml-field
name="event_time"
type="time"
unit="microsecond"
nullable="false">
</hdml-field>
</hdml-table>In this example, the hdml-field component with type="time" includes the additional unit attribute to specify the time format.
<hdml-table
type="table"
identifier="`database`.`schema`.`your_table`">
<hdml-field
name="event_time"
type="timestamp"
unit="microsecond"
timezone="UTC"
nullable="false">
</hdml-field>
</hdml-table>In this example, the hdml-field component with type="timestamp" includes the additional unit and timezone attributes to specify the timestamp format and timezone.
The hdml-join component is used to define joins between tables within an hdml-model. It provides flexibility in specifying the type of join and the conditions for the join through a combination of attributes and child components.
-
type(Required): Specifies the type of join. Supported values include:cross: Produces the Cartesian product of two tables.inner: Returns only the rows that have matching values in both tables.full: Returns all rows when there is a match in either left or right table records.left,right: Returns all rows from the left or right table and matching rows from the right or left table.full-outer,left-outer,right-outer: Similar tofull,left, andrightbut includes unmatched rows as well.
-
left(Required): The name of the left table in the join. Should match the name of anhdml-tablewithin the samehdml-model. -
right(Required): The name of the right table in the join. Should match the name of anhdml-tablewithin the samehdml-model.
-
hdml-connective(Required): Serves as a logical connective for defining conditions.-
Attributes:
operator(Required): Specifies the logical operator (andoror) for connecting multiple filter conditions.
-
Child Components:
-
hdml-filter(Required): Describes the conditions.-
Attributes:
type(Required): Specifies the type of filter. Supported values include:keys: Join based on matching key fields. (Note: Only for use underhdml-join)expr: Use a custom SQL-like conditional clause.
-
Attributes for
type="keys":left(Required): The name of the field in the left table.right(Required): The name of the field in the right table.
-
Attributes for
type="expr":clause(Required): Specifies the SQL-like conditional clause.- Example:
<hdml-filter type="expr" clause="`table1`.`field1` = `table2`.`field2`"> </hdml-filter>
In this example, it defines a condition based on the equality of
field1intable1withfield2intable2.
-
-
-
<hdml-join
type="inner"
left="table1"
right="table2">
<hdml-connective
operator="and">
<hdml-filter
type="keys"
left="field1"
right="field2">
</hdml-filter>
<hdml-filter
type="expr"
clause="`table1`.`field1` = `table2`.`field2`">
</hdml-filter>
</hdml-connective>
</hdml-join>This example demonstrates an inner join between table1 and table2 with a root hdml-connective connecting two conditions.
- You can't have two
hdml-connectiveunder thehdml-join. Some root connective must be there for proper connection. hdml-filterwith type "keys" is specific tohdml-joinand must not be used elsewhere.hdml-connectiveandhdml-filterwill be used not only for joins.
The hdml-connective component is utilized to define logical connectives. It is commonly employed within the context of hdml-join conditions under hdml-model or within the context of hdml-filter-by conditions under hdml-frame. This component enables you to merge multiple filters using logical operators. hdml-connective is specifically designed for connecting multiple hdml-filter and other hdml-connective components.
operator(Required): Specifies the logical operator to connect filters. Supported values include:and: Logical AND operator.or: Logical OR operator.
<hdml-model
name="my_model">
<!-- hdml-model configuration -->
<hdml-join
type="inner"
left="table1"
right="table2">
<hdml-connective
operator="and">
<hdml-filter
type="keys"
left="field1"
right="field2">
</hdml-filter>
<hdml-filter
type="expr"
clause="`table1`.`field3` = 'value'">
</hdml-filter>
</hdml-connective>
</hdml-join>
<!-- hdml-model configuration -->
</hdml-model><hdml-frame
name="my_frame"
source="?hdml-model=my_model">
<!-- hdml-frame configuration -->
<hdml-filter-by>
<hdml-connective
operator="and">
<hdml-filter
type="expr"
clause="`field1` = 'ABC'">
</hdml-filter>
<hdml-filter
type="expr"
clause="`field6` > 100">
</hdml-filter>
</hdml-connective>
</hdml-filter-by>
<!-- hdml-frame configuration -->
</hdml-frame>The hdml-filter component is utilized to define filters within the context of hdml-join conditions under hdml-model or within the context of hdml-filter-by conditions under hdml-frame. This component allows you to specify conditions for joining tables or filtering data based on specific criteria. Filters are always specified under the hdml-connective element, allowing you to articulate the logical conditions for joining tables or filtering data.
type(Required): Specifies the type of filter. Supported values include:keys(Used only inhdml-join): Indicates a filter based on key fields. Requires additional attributes:leftandright.expr: Represents a filter based on a conditional SQL-like expression. Requires additional attribute:clause.named: Reserved for future use. Requires additional attributes:name,field, andvalue.
left(Required): Specifies the left field for key-based filters. Should match the name of thehdml-fieldin the left table.right(Required): Specifies the right field for key-based filters. Should match the name of thehdml-fieldin the right table.
-
clause(Required): Specifies the SQL-like conditional clause for expression-based filters. The format depends on the context:- Under
hdml-model(hdml-join): Should be set as:
clause="`hdml-table-name`.`hdml-table-field-name` = 'string'"
- Under
hdml-frame(hdml-filter-by): Should be set as:
clause="`hdml-frame-field-name` = 'string'"
- Under
-
name(Required): Specifies the filter condition name. Supported values include:equals: Field value equals the specified value.not-equals: Field value does not equal the specified value.contains: Field value contains the specified value.not-contains: Field value does not contain the specified value.starts-with: Field value starts with the specified value.ends-with: Field value ends with the specified value.greater: Field value is greater than the specified value.greater-equal: Field value is greater than or equal to the specified value.less: Field value is less than the specified value.less-equal: Field value is less than or equal to the specified value.is-null: Field value is null.is-not-null: Field value is not null.between: Field value is between two specified values.
-
field(Required): Specifies the field name in the same way it is specified in the clause attribute:- Under
hdml-model(hdml-join): Should be set as:
field="`hdml-table-name`.`hdml-table-field-name`"
- Under
hdml-frame(hdml-filter-by): Should be set as:
field="`hdml-frame-field-name`"
- Under
-
value(Required): Specifies the value used to filter data.
<hdml-model
name="my_model">
<!-- hdml-model configuration -->
<hdml-join
type="inner"
left="table1"
right="table2">
<hdml-connective
operator="and">
<hdml-filter
type="keys"
left="field1"
right="field2">
</hdml-filter>
</hdml-connective>
</hdml-join>
<!-- hdml-model configuration -->
</hdml-model><hdml-model
name="my_model">
<!-- hdml-model configuration -->
<hdml-join
type="inner"
left="table1"
right="table2">
<hdml-connective
operator="and">
<hdml-filter
type="expr"
clause="`table1`.`field1` = 'value'">
</hdml-filter>
</hdml-connective>
</hdml-join>
<!-- hdml-model configuration -->
</hdml-model><hdml-frame
name="my_frame"
source="?hdml-model=my_model">
<!-- hdml-frame configuration -->
<hdml-filter-by>
<hdml-connective
operator="and">
<hdml-filter
type="expr"
clause="`field1` = 'ABC'">
</hdml-filter>
</hdml-connective>
</hdml-filter-by>
<!-- hdml-frame configuration -->
</hdml-frame><hdml-model
name="my_model">
<!-- hdml-model configuration -->
<hdml-join
type="inner"
left="table1"
right="table2">
<hdml-connective
operator="and">
<hdml-filter
type="named"
name="equals"
field="`table1`.`field1`"
value="'ABC'">
</hdml-filter>
</hdml-connective>
</hdml-join>
<!-- hdml-model configuration -->
</hdml-model><hdml-frame
name="my_frame"
source="?hdml-model=my_model">
<!-- hdml-frame configuration -->
<hdml-filter-by>
<hdml-connective
operator="and">
<hdml-filter
type="named"
name="equals"
field="`field1`"
value="'ABC'">
</hdml-filter>
</hdml-connective>
</hdml-filter-by>
<!-- hdml-frame configuration -->
</hdml-frame>The hdml-frame component is used to create a data frame based on the provided HDML model or another HDML frame. It serves as a container for organizing and processing data within the HDML structure. This includes tasks such as filtering, aggregating, sorting, and performing calculations on the data. Essentially, the hdml-frame allows for manipulating and analyzing the data according to specified criteria.
name(Required): The name of the data frame.source(Required): Specifies the parent structure for the frame. This attribute indicates the source of the data model used to construct the frame. Depending on whether the parent structure is stored separately or within the same document, the value of this attribute varies:- If the parent structure is stored separately on the HDIO server, the value should be an HDIO path to the file, followed by either
hdml-model=model_nameorhdml-frame=frame_name. For example:/path/to/file.hdml?hdml-model=model_nameor/path/to/file.hdml?hdml-frame=frame_name. - If the parent structure is declared within the same file, only specify
hdml-model=model_nameorhdml-frame=frame_namewithout the path and file name. For example:?hdml-model=model_nameor?hdml-frame=frame_name.
- If the parent structure is stored separately on the HDIO server, the value should be an HDIO path to the file, followed by either
limit(Optional): Specifies the maximum number of rows to include in the frame.offset(Optional): Specifies the number of rows to skip before starting to include rows in the frame.
Note: At least one hdml-field must be specified within the hdml-frame.
Note: In the case of using hdml-field within the hdml-frame component scope, the origin attribute refers to the "parent" structure field name.
hdml-filter-by(Optional): Thehdml-filter-bycomponent is used to filter data within the context of anhdml-frame. It allows you to specify conditions to filter rows of data based on specific criteria. This component is essential for refining datasets and focusing on relevant information.- The
hdml-connectiveelement must be a child element ofhdml-filter-byand is used to specify the logical operator for joining multiple filter conditions. - Multiple
hdml-filterelements can be included withinhdml-connectiveto define complex filter conditions.
- The
hdml-group-by(Optional): Thehdml-group-bycomponent is used within the context of anhdml-frameto group data based on specific fields. It allows you to aggregate data based on common values in one or more fields. This component is useful for summarizing data and performing operations on grouped subsets of the dataset.- The
hdml-group-bycomponent must contain at least onehdml-fieldelement to specify the field(s) by which the data will be grouped. - Grouped data can then be further manipulated or analyzed within the frame's scope.
- The
hdml-sort-by(Optional): Thehdml-sort-bycomponent is used within the context of anhdml-frameto sort data based on specific fields. It allows you to arrange data in ascending or descending order based on one or more fields. This component is useful for organizing data and presenting it in a structured manner.- The
hdml-sort-bycomponent must contain at least onehdml-fieldelement to specify the field(s) by which the data will be sorted. - Sorted data can then be further manipulated or analyzed within the frame's scope.
- The asc attribute of the
hdml-fieldelement determines whether the sorting is done in ascending (true) or descending (false) order. This attribute is meaningful only within the context ofhdml-sort-by.
- The
<hdml-frame
name="my_frame"
source="?hdml-model=my_model"
limit="100"
offset="10">
<hdml-field
name="field_name"
origin="my_model_field_name">
</hdml-field>
<hdml-field
name="field_counter"
origin="my_model_field_name"
agg="count">
</hdml-field>
<hdml-filter-by>
<hdml-connective
operator="and">
<hdml-filter
type="named"
name="starts-with"
field="field_name"
value="'A'">
</hdml-filter>
</hdml-connective>
</hdml-filter-by>
<hdml-group-by>
<hdml-field
name="field_name">
</hdml-field>
</hdml-group-by>
<hdml-sort-by>
<hdml-field
name="field_name"
asc="true">
</hdml-field>
</hdml-sort-by>
</hdml-frame>The following HDML code demonstrates the configuration of an hdml-frame component with various data processing operations:
-
Frame Definition:
- The
hdml-framecomponent named "my_frame" is defined with the following attributes:name: Specifies the name of the data frame.source: Indicates the source of the data model used to construct the frame.limit: Specifies the maximum number of rows to include in the frame.offset: Specifies the number of rows to skip before starting to include rows in the frame.
- The
-
Field Definitions:
- Two
hdml-fieldcomponents are included within thehdml-frame:- The first field, "field_name", retrieves data from the HDML model's field named "my_model_field_name".
- The second field, "field_counter", also retrieves data from "my_model_field_name" but applies an aggregation function to count the occurrences of each value.
- Two
-
Data Filtering:
- The
hdml-filter-bycomponent is used to filter data based on specific criteria. - In this example, data is filtered to include only rows where the value of the "field_name" field starts with the letter 'A'.
- The
-
Data Grouping:
- The
hdml-group-bycomponent is employed to group data based on the values of one or more fields. - Here, data is grouped based on the "field_name" field.
- The
-
Data Sorting:
- The
hdml-sort-bycomponent is utilized to sort the data based on specified fields. - The data is sorted in ascending order based on the values of the "field_name" field.
- The
This example showcases the versatility of HDML in organizing, processing, and analyzing data within a structured framework.