当前位置:网站首页>Neat Syntax Design of an ETL Language (Part 2)
Neat Syntax Design of an ETL Language (Part 2)
2022-06-25 09:46:00 【InfoQ】
- A new ETL language – Easy SQL
- A guide to write elegant ETL
- Neat syntax design of an ETL language (part 1)
Language features in Easy SQL
- An imperative structure of ETL code.
- Variables which could be defined and modified any time.
- A way to call external functions.
- A way to control whether a step should be executed.
- Templates that could be reused in the same ETL file.
- Include command that could be used to reuse code at file level.
- Debugging support: logging and assertion that could be used for debugging.
- A debugger interface.
- Other features:write data to tables; list variables; SQL actions.
Syntax in Easy SQL
Templates used to reuse code
- Template is a step in ETL. It is defined by a target with name ‘template’ and a following descriptive name. The descriptive name is the template name.
- The body of a template could be anything.
- If there are template parameters, no need to declare them, just use them by ‘#{PARAMETER_NAME}’. Easy SQL will extract these parameters for you at runtime.
- Templates could be used in any target with syntax ‘@{TEMPLATE_NAME}’. If there are template parameters, we need to pass them as named parameters.
- Variables can be referenced in template body, and the resolution of variables happens at the resolution time of the template (when the step with template reference is executing). This is useful since we can change the value of some variable between two targets referencing the same template.
- There should be no templates used in the body of templates. This is to make the resolution of templates to be simple.
Include other ETL code snippets
some_snippets.sqlsome_snippets.sql- Include command could be used at any line of code.
- When Easy SQL processed this ‘include’ command, the content of the file will simply be expanded.
Debugging support
- When using the ‘log’ target, we need to specify a message about what to log.
- The log message format is the same as a variable. I.e. It should be composed of chars ‘0-9a-zA-Z_’.
- There should be exactly one row returned from the query of some ‘log’ target. If there is more than one row returned, only the first row will be logged.
- There are two formats of ‘check’ target. One is to specify a check message with a query. The other is to call a function, which returns a boolean value.
- When the ‘check’ target is used as a message with a query, the returned value of the query must be one row with two columns named ‘actual’ and ‘expected’.
Debugger interface
Jupyter- Install
Jupyter first with command pip install jupyterlab.
- Create a file named
debugger.py with contents like below: - (A more detailed sample could be found here.)
- Create a file named
test.sql with contents as here.
- Then start jupyter lab with command:
jupyter lab.
- Start debugging like below:

Write data
- There must be a full table name (both database name and table name specified) after the ‘output’ keyword in the target definition.
- The table must be created before writing data.
- If we’d like to create tables automatically, we need to define a special variable named ‘__create_output_table__’ with value equals to 1.
- If we’d like to write data to some static partition of the output table, we need to define a special variable named ‘__partition__’ with partition column name followed by. An example could be ‘__partition__data_date’. Then the partition column is ‘data_date’. The value of the variable will be the partition value when writing data.
- If we’d like to write data to some static partition of the output table, we can only define one partition value at the moment.
- If the query returns more columns than what is defined by the real table, the extra columns will be ignored.
- If the query returns less columns than what is defined by the real table, an error will be raised.
List variables
[1, 2, 3]SQL actions
- There should be a descriptive name for an action. The name should be composed of chars ‘0-9a-zA-Z_’ and follow the ‘action’ keyword.
- In the body of an action target, templates and variables can be used as in any other target.
Summary
- Templates that could be reused in the same ETL file.
- Include command that could be used to reuse code at file level.
- Debugging support: logging and assertion that could be used for debugging.
- A debugger interface.
- Other features:write data to tables; list variables; SQL actions.
边栏推荐
- 【mysql学习笔记21】存储引擎
- Is it harder to find a job in 2020? Do a good job in these four aspects and find a good job with high salary
- STM32 receives data by using idle interrupt of serial port
- Is it safe to open an account in a mobile phone or a securities company?
- [IOU] intersection over union
- 将jar包注册为服务,实现开机自动启动
- 请问在手机上开户股票,还是去证券公司开户安全?
- [zufe school competition] difficulty classification and competition suggestions of common competitions in the school (taking Zhejiang University of Finance and economics as an example)
- Prediction of pumpkin price based on BP neural network
- CYCA少儿形体礼仪 乐清市培训成果考核圆满落幕
猜你喜欢

Wechat official account can reply messages normally, but it still prompts that the service provided by the official account has failed. Please try again later

Format analysis and explanation of wav file

8. Intelligent transportation project (1)

Voiceprint Technology (VI): other applications of voiceprint Technology

Cassava tree disease recognition based on vgg16 image classification

Solution to the problem of repeated startup of esp8266
![[zufe expense reimbursement] zhecai invoice reimbursement specification (taking Xinmiao reimbursement as an example), which can be passed in one trip at most](/img/28/c5c6b6d03b459745dc3735f8b39ea9.jpg)
[zufe expense reimbursement] zhecai invoice reimbursement specification (taking Xinmiao reimbursement as an example), which can be passed in one trip at most

203 postgraduate entrance examination Japanese self-study postgraduate entrance examination experience post; Can I learn Japanese by myself?
![[buuctf.reverse] 117-120](/img/6c/8a90fff2bd46f1494a9bd9c77eeafc.png)
[buuctf.reverse] 117-120

With the QQ group file storage function of super nice, you immediately have n cloud disks that are easy to download and never expire
随机推荐
Force buckle -104 Maximum depth of binary tree
Vscode attempted to write the procedure to a pipeline that does not exist
203 postgraduate entrance examination Japanese self-study postgraduate entrance examination experience post; Can I learn Japanese by myself?
Oracle function trigger
使用Navicat对比多环境数据库数据差异和结构差异,以及自动DML和DDL脚本
Study on correlation of pumpkin price and design of price prediction model based on BP neural network
Match a mobile number from a large number of mobile numbers
Armbian version name comparison
Lvs-dr mode single network segment case
2022 postgraduate entrance examination experience post -- Alibaba Business School of Hangzhou Normal University -- management science and Engineering (including the recommendation of books and course
Title B of the certification cup of the pistar cluster in the Ibagu catalog
请问在手机上开户股票,还是去证券公司开户安全?
从海量手机号中匹配某一个手机号
Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.
[2020 cloud development + source code] 30 minutes to create and launch wechat applet practical project | zero cost | cloud database | cloud function
[MySQL learning notes 22] index
puzzle(019.2)六边锁
【mysql学习笔记21】存储引擎
[buuctf.reverse] 117-120
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate