tencent cloud

Tencent Cloud WeData

Release Notes
Dynamic Release Record (2026)
Product Introduction
Product Overview
Product Advantages
Product Architecture
Product Features
Application Scenarios
Purchase Guide
Billing Overview
Product Version Purchase Instructions
Execute Resource Purchase Description
Billing Modes
Overdue Policy
Refund
Preparations
Overview of Account and Permission Management
Add allowlist /security groups (Optional)
Sign in to WeData with Microsoft Entra ID (Azure AD) Single Sign-On (SSO)
Operation Guide
Console Operation
Project Management
Data Integration
Studio
Data Development
Data Analysis
Data Science
Data Governance (with Unity Semantics)
API Documentation
History
Introduction
API Category
Making API Requests
Smart Ops Related Interfaces
Project Management APIs
Resource Group APIs
Data Development APIs
Data Asset - Data Dictionary APIs
Data Development APIs
Ops Center APIs
Data Operations Related Interfaces
Data Exploration APIs
Asset APIs
Metadata Related Interfaces
Task Operations APIs
Data Security APIs
Instance Operation and Maintenance Related Interfaces
Data Map and Data Dictionary APIs
Data Quality Related Interfaces
DataInLong APIs
Platform Management APIs
Data Source Management APIs
Data Quality APIs
Platform Management APIs
Asset Data APIs
Data Source Management APIs
Data Types
Error Codes
WeData API 2025-08-06
Service Level Agreements
Related Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

SQL Tag statement

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-11-01 16:35:04
The development and orchestration space of WeData supports the SQL Tag statement feature. Users can use if-else, for loops, and other logical judgments in SQL to achieve more complex business logic with simpler code.

Special identifier at the beginning of the script

--SQL/VMSCRIPT
#set( $cnt = 10 )
select $cnt;

Assignment statements and operators

--SQL/VMSCRIPT
#set( $cnt = 10 )
#set( $cnt = $cnt + 1 )
select $cnt;

Operator

Operator
Operators
Sample code
Object Equivalence
==
#if( $foo == $bar )
Not Equals
!=
#if( $foo != $bar )
Less Than or Equal To
<=
#if( $foo <= 42 )
Less Than
<
#if( $foo < 42 )
Greater Than or Equal To
>=
#if( $foo >= 42 )
Greater Than
>
#if( $foo > 42 )
Equals String
==
#if( $foo == "bar" )
Equals Number
==
#if( $foo == 42 )
Boolean NOT
!
#if( !$foo )

for-each statement

Integer format

--SQL/VMSCRIPT
#set( $cnt = 10 )
#set( $cnt = $cnt + 1 )
#foreach($i in $_range.of(1, $cnt, 1))
select $cnt,$i;
#end

List mode

--SQL/VMSCRIPT
#foreach($table in ["test_user_info_table", "test_issue_info_table"])
select '$table' table_name, count(1) cnt from $table where substring(create_time, 1, 7) = '2022-11'
#if($foreach.last != true)
union all
#end
#end

Condition judgment statement

Using assigned variables

--SQL/VMSCRIPT
--This statement will execute the branch where age>2
#set( $flag_1 = 0 )
#set( $flag_2 = 0 )
select * from default.demo_hive
where
#if($flag_1 == 1)
id = 1;
#elseif( $flag_2 == 1)
id = 2;
#else
id >2;
#end
Using system parameters, system parameters must be used in the ${variable_name} format.
Here, the variables flag_1 and flag_2 are both set to 0 in Workflow Task Scheduling.
--SQL/VMSCRIPT
--This statement will execute the branch where age>2
select * from default.demo_hive
where
#if(${flag_1} == 1)
age = 1;
#elseif(${flag_2} == 1)
age = 2;
#else
age >2;
#end
Using system variables and time variables, where dt, dt_pre_7d, and dt_pre_1d are created as time parameter variables.
--SQL/VMSCRIPT
--This statement will execute the else branch
select * from default.user_info
where
#if(${is_reload} == "1")
create_time <= ${dt};
#elseif(${is_deltareload} == "1")
create_time between ${dt_pre_7d} and ${dt};
#else
create_time between ${dt_pre_1d} and ${dt};
#end

Scope of application description

SQL Tag can be used in the Development Space and Orchestration Space of WeData.

Condition judgment statement

Implementations use velocity, and relevant documentation can be referred to in Apache Velocity Engine VTL Reference.
Note:
The SQL Tag statements will be automatically effective for newly purchased Schedule Resource Groups. For older Schedule Resource Groups, assistance from the Product Research and Development Team is required to restart and upgrade. It is recommended to purchase new Schedule Resource Groups and then bind them to the project.


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan