CN110399386B - Presto-based SQL UPDATE method and control system - Google Patents
Presto-based SQL UPDATE method and control system Download PDFInfo
- Publication number
- CN110399386B CN110399386B CN201910637363.9A CN201910637363A CN110399386B CN 110399386 B CN110399386 B CN 110399386B CN 201910637363 A CN201910637363 A CN 201910637363A CN 110399386 B CN110399386 B CN 110399386B
- Authority
- CN
- China
- Prior art keywords
- update
- presto
- sql
- delete
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2458—Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
- G06F16/2471—Distributed queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Software Systems (AREA)
- Probability & Statistics with Applications (AREA)
- Fuzzy Systems (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention belongs to the technical field of information retrieval, and discloses a Presto-based SQL UPDATE method and a control system, wherein the Presto supports UPDATE operation in syntax by modifying an SQL interpreter, generates a corresponding AST syntax tree when receiving an UPDATE statement, and generates a DELETE execution plan according to a DELETE flow; replicating the DELETE execution plan writes the SET portion into the DELETE's execution plan node, packages it into an UPDATE node, and is ultimately identified by the corresponding connector and performs the UPDATE operation. The invention receives and analyzes the UPDATE SQL request by Presto, generates the UPDATE flow based on the DELETE flow, identifies the flow through the connector, and performs data updating operation when finally operating data, thereby achieving the UPDATE SQL execution effect and realizing data updating.
Description
Technical Field
The invention belongs to the technical field of information retrieval, and particularly relates to a Presto-based SQL UPDATE method and a control system.
Background
Currently, the current state of the art commonly used in the industry is such that:
presto is a large data distributed SQL query engine. The interactive query can be performed on big data from the number G to the number P, and the query speed reaches the level of a commercial data warehouse. It may query data storage products including Hive, Cassandra, and even some businesses. A single Presto query may consolidate data from multiple data sources for unified analysis.
Presto is a distributed system that operates in a clustered environment, with a complete installation including a coordinator (coordinator) and multiple workers. Queries are submitted to the coordinator via a client, such as a Presto CLI, and the coordinator is responsible for parsing, analyzing, and scheduling queries to be executed on different workers. And each worker node reads data from various data sources through a corresponding data source connector.
Since Presto official design does not support SQL UPDATE operations, it cannot be implemented in Presto systems when there is an UPDATE requirement.
When the normal flow submits UPDATE SQL to Presto, the server directly returns no support because Presto of the official original edition has no UPDATE function, and because the prior art has the defect that the table data UPDATE function is absent, the data source needs to be directly operated when a scene with data UPDATE exists in actual use, SQL cannot be used, and the operation is easy to make mistakes.
In summary, the problems of the prior art are as follows:
the existing official Presto original edition does not support UPDATE operation, so that a data source needs to be directly operated when a scene with data updating exists in actual use, SQL cannot be used, and operation is easy to make mistakes.
The difficulty of solving the technical problems is as follows:
the official source code has too few explanatory documents, and the reading and understanding of the source code are difficult; the source code has large code amount and more places to be changed; the compatibility of the newly added module with the functions of the original modules needs to be ensured. More importantly, the difficulty is innovation.
The significance of solving the technical problems is as follows:
the invention provides a method for implementing UPDATE SQL on Presto UPDATE table data, which is used for supplementing the function deficiency of an official version and is a process from 'no' to 'available'.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a Presto-based SQL UPDATE method and a control system. The invention provides a function for updating the table data for the prior art and provides an implementation idea at the same time
The invention is realized in this way, a Presto-based SQL UPDATE method includes:
by modifying the SQL interpreter, Presto syntactically supports UPDATE operation, generates a corresponding AST syntax tree when receiving an UPDATE statement, generates a DELETE execution plan according to the DELETE flow, copies the DELETE execution plan, writes the SET part into the execution plan nodes of DELETE, packs the SET part into the UPDATE node, and finally identifies and UPDATEs the corresponding connector.
Further, the Presto-based SQL UPDATE method specifically comprises the following steps:
step one, modifying an SQL parser item, adding UPDATE grammar parsing content, and enabling presto to parse and generate a corresponding AST grammar tree when an UPDATE statement is received.
And step two, adding an UPDATE execution plan node.
And step three, executing the UPDATE execution plan according to a DELETE flow, reading data from a data source by connecting the data source, filtering the data meeting WHERE conditions, and acquiring unique identifiers (ids) of the data.
And step four, executing the PDATE execution plan according to the DELETE flow, reading data from a data source through the data source connection, filtering the data meeting WHERE conditions, and acquiring unique identifiers (id) of the data.
And step five, the connector identifies the UPDATE according to the flow node type and the SET content, and UPDATEs the data according to the id acquired in the step four and the SET content in the UPDATE SQL.
The invention also aims to provide a Presto-based SQL UPDATE control system for implementing the Presto-based SQL UPDATE method.
The invention also aims to provide a Presto-based SQL UPDATE program, which realizes the Presto-based SQL UPDATE method.
The invention also aims to provide an information data processing terminal for realizing the Presto-based SQL UPDATE method.
It is another object of the present invention to provide a computer-readable storage medium, comprising instructions which, when executed on a computer, cause the computer to perform the Presto-based SQL UPDATE method.
In summary, the advantages and positive effects of the invention are:
software version | Executing update (set) 30 world name ═ sam'; effect of (1) | Conclusion |
Original edition | Query failed:line 1:1:mismatched input'update'. | Operation failure |
Version of the invention | UPDATE:1row | Operation is successful |
Effect graph witness part
The invention makes Presto support SQL UPDATE operation by means of expanding SQL syntax parser, expanding original edition SQL DELETE flow and the like; the SQL UPDATE operation is realized by modifying an antr 4 grammar file, creating an UPDATE flow node, executing a DELETE flow, identifying the UPDATE operation and executing data updating.
The invention receives and analyzes the UPDATE SQL request by Presto, generates the UPDATE flow based on the DELETE flow, identifies the flow through the connector, and performs data updating operation when finally operating data, thereby achieving the UPDATE SQL execution effect and realizing data updating.
Drawings
Fig. 1 is a flowchart of the Presto-based SQL UPDATE method according to the embodiment of the present invention.
Fig. 2 is a schematic diagram of a basic architecture of a Presto system cluster according to an embodiment of the present invention.
Fig. 3 is a schematic processing flow diagram of the UPDATE SQL in the system according to the embodiment of the present invention.
Fig. 4 is an official original version (failure to execute) diagram provided by an embodiment of the present invention.
Fig. 5 is a diagram of the version (execution success) provided by an embodiment of the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The existing official Presto original edition does not support UPDATE operation, so that a data source needs to be directly operated when a scene with data updating exists in actual use, SQL cannot be used, and operation is easy to make mistakes.
To solve the above problems, the following describes the technical solution of the present invention in detail with reference to the accompanying drawings.
The SQL UPDATE method based on Presto provided by the embodiment of the invention comprises the following steps:
by modifying the SQL interpreter, Presto syntactically support UPDATE operations, upon receiving an UPDATE statement, a corresponding AST syntax tree is generated, and a DELETE execution plan is generated in accordance with DELETE flow, which is replicated and packaged as UPDATE nodes by writing the SET portion into the execution plan nodes of DELETE, and finally identified by the corresponding connectors and subjected to UPDATE operations.
As shown in fig. 1 to fig. 3, the SQL UPDATE method based on Presto provided in the embodiment of the present invention specifically includes the following steps:
s101, modifying an SQL parser item, adding UPDATE grammar parsing content, and enabling presto to parse and generate a corresponding AST grammar tree when an UPDATE statement is received.
S102, adding an UPDATE execution plan node.
S103, executing the UPDATE execution plan according to a DELETE flow, reading data from a data source by connecting the data source, filtering the data meeting WHERE conditions, and obtaining the unique identification (id) of the data.
S104, executing the PDATE execution plan according to a DELETE flow, reading data from a data source through a data source connection, filtering the data meeting WHERE conditions, and obtaining the unique identification (id) of the data.
And S105, identifying the UPDATE by the connector according to the flow node type and the SET content, and updating the data according to the id acquired in the fourth step and the SET content in the UPDATE SQL.
The invention is further described with reference to specific examples.
Example 1:
assuming that there is a table user, there are two columns in the table, name and pwd, and there are several data in the table, each data has a unique id, when executing a statement:
update user set pwd='123'where name='mar'。
the invention provides syntax and function support of update for presto which originally does not support update, and the specific steps comprise:
(1) and (4) modifying an antlr4 syntax rule file and adding update syntax support.
(2) When the server receives update sql, it parses and generates the corresponding AST syntax tree.
(3) An update execution plan node is created that inherits the delete execution plan node, where set content is added.
(4) And creating a delete query execution process, putting the update execution plan node into the process, and executing according to the delete process.
(5) And the delete flow screens out the ids of all data with the name ═ mar' and sends the ids to the connector for data deletion operation.
(6) When the connector processes the data deleting operation, whether the data deleting operation is an update flow or not is identified specifically, if so, the corresponding row is updated, otherwise, the data deleting operation is executed according to the original delete flow.
The node added with the UPDATE execution plan node provided by the embodiment of the invention is the extension of the DELETE execution plan node, only has the content of column value more than that of the DELETE node, and is compatible with the execution flow of DELETE because of the subtype of the DELETE node.
The invention is further described below in connection with a functional demonstration.
The following is the function demonstration content of the invention, and the flow is as follows: creating a table containing 3 fields, inserting 3 pieces of data into the table, executing an UPDATE statement to UPDATE one piece of data, and checking an UPDATE result.
The official original version (failed execution) is as in fig. 4. The version of the invention (successful execution) is shown in fig. 5.
In the above embodiments, all or part of the implementation may be realized by software, hardware, firmware, or any combination thereof. When used in whole or in part, is implemented in a computer program product that includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the procedures or functions according to the embodiments of the present invention are wholly or partially generated. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website site, computer, server, or data center to another website site, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL), or wireless (e.g., infrared, wireless, microwave, etc.)). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.
Claims (5)
1. A Presto-based SQL UPDATE method is characterized by comprising the following steps:
modifying the SQL interpreter to perform UPDATE syntax operation; receiving an UPDATE statement, generating a corresponding AST syntax tree, and generating a DELETE execution plan according to a DELETE flow;
copying the DELETE execution plan to write the SET part into the execution plan nodes of the DELETE, packaging into UPDATE nodes, and finally identifying and updating by corresponding connectors;
the SQL UPDATE method based on Presto specifically comprises the following steps:
modifying an SQL parser item, adding UPDATE grammar parsing content, and enabling presto to parse and generate a corresponding AST grammar tree when an UPDATE statement is received;
step two, adding an UPDATE execution plan node;
step three, executing the UPDATE execution plan according to a DELETE flow, reading data from a data source by data source connection, filtering the data meeting WHERE conditions, and obtaining unique identification ids of the data;
and step four, the connector identifies the UPDATE according to the flow node type and the SET content, and UPDATEs the data according to the id acquired in the step three and the SET content in the UPDATE SQL.
2. A Presto-based SQL UPDATE control system implementing the Presto-based SQL UPDATE method of claim 1.
3. A Presto-based SQL UPDATE program, characterized in that the Presto-based SQL UPDATE program implements the Presto-based SQL UPDATE method of claim 1.
4. An information data processing terminal for implementing the Presto-based SQL UPDATE method according to claim 1.
5. A computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform the Presto-based SQL UPDATE method of claim 1.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910637363.9A CN110399386B (en) | 2019-07-15 | 2019-07-15 | Presto-based SQL UPDATE method and control system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910637363.9A CN110399386B (en) | 2019-07-15 | 2019-07-15 | Presto-based SQL UPDATE method and control system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110399386A CN110399386A (en) | 2019-11-01 |
CN110399386B true CN110399386B (en) | 2022-05-10 |
Family
ID=68325580
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910637363.9A Active CN110399386B (en) | 2019-07-15 | 2019-07-15 | Presto-based SQL UPDATE method and control system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110399386B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110874364B (en) * | 2019-11-19 | 2023-04-11 | 北京启迪区块链科技发展有限公司 | Query statement processing method, device, equipment and storage medium |
CN113032642B (en) * | 2019-12-24 | 2024-02-09 | 医渡云(北京)技术有限公司 | Data processing method and device for target object, medium and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107729428A (en) * | 2017-09-28 | 2018-02-23 | 南威软件股份有限公司 | A kind of SQL query method based on Presto and Elasticsearch |
CN108563509A (en) * | 2018-04-28 | 2018-09-21 | 北京京东金融科技控股有限公司 | Data query implementation method, device, medium and electronic equipment |
CN109033123A (en) * | 2018-05-31 | 2018-12-18 | 康键信息技术(深圳)有限公司 | Querying method, device, computer equipment and storage medium based on big data |
CN109739882A (en) * | 2019-01-04 | 2019-05-10 | 南威软件股份有限公司 | A kind of big data enquiring and optimizing method based on Presto and Elasticsearch |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11120021B2 (en) * | 2017-01-11 | 2021-09-14 | Facebook, Inc. | Systems and methods for optimizing queries |
-
2019
- 2019-07-15 CN CN201910637363.9A patent/CN110399386B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107729428A (en) * | 2017-09-28 | 2018-02-23 | 南威软件股份有限公司 | A kind of SQL query method based on Presto and Elasticsearch |
CN108563509A (en) * | 2018-04-28 | 2018-09-21 | 北京京东金融科技控股有限公司 | Data query implementation method, device, medium and electronic equipment |
CN109033123A (en) * | 2018-05-31 | 2018-12-18 | 康键信息技术(深圳)有限公司 | Querying method, device, computer equipment and storage medium based on big data |
CN109739882A (en) * | 2019-01-04 | 2019-05-10 | 南威软件股份有限公司 | A kind of big data enquiring and optimizing method based on Presto and Elasticsearch |
Non-Patent Citations (3)
Title |
---|
Business-oriented customized big data query system and its SQL parser design and implementation;Ge Wenshuai等;《roceedings of 2018 2nd International Conference on Electronic Information Technology and Computer Engineering (EITCE 2018)》;20181031;第13-18页 * |
分布式sql引擎原理分析-逻辑执行计划生成;sundyxiong;《https://cloud.tencent.com/developer/article/1195072》;20180826;全文 * |
分布式内存数据库系统的查询处理与优化;王立;《中国优秀博硕士学位论文全文数据库(博士)信息科技辑》;20151215;I138-2 * |
Also Published As
Publication number | Publication date |
---|---|
CN110399386A (en) | 2019-11-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11514046B2 (en) | Tiering with pluggable storage system for parallel query engines | |
CN110908997B (en) | Data blood relationship construction method and device, server and readable storage medium | |
WO2020233367A1 (en) | Blockchain data storage and query method, apparatus and device, and storage medium | |
KR102440082B1 (en) | Data Sharing and Materialized Views in Databases | |
CN107506451B (en) | Abnormal information monitoring method and device for data interaction | |
US8065323B2 (en) | Offline validation of data in a database system for foreign key constraints | |
US9740698B2 (en) | Document merge based on knowledge of document schema | |
US9996597B2 (en) | Unified mapreduce framework for large-scale data processing | |
US7313572B2 (en) | Attribute partitioning for user extensibility | |
US20140173559A1 (en) | Identifying differences between source codes of different versions of a software when each source code is organized using incorporated files | |
CN113490928A (en) | Sharing of instantiated views in a database system | |
CN111858760B (en) | Data processing method and device for heterogeneous database | |
CN110399386B (en) | Presto-based SQL UPDATE method and control system | |
CN114780641B (en) | Multi-library multi-table synchronization method, device, computer equipment and storage medium | |
CN113760947A (en) | Data center, data processing method, device, equipment and storage medium | |
US20170293619A1 (en) | Simulating data definition triggers in a database system | |
CN112395307A (en) | Statement execution method, statement execution device, server and storage medium | |
US11169993B2 (en) | Datastore mechanism for managing out-of-memory data | |
CN111796855B (en) | Incremental version updating method and device, storage medium and computer equipment | |
US7801921B2 (en) | Deletion of data from child tables with multiple parents | |
CN111241065A (en) | Security multi-compatibility lightweight database adaptation development and operation device supporting domestic database | |
US11157506B2 (en) | Multiform persistence abstraction | |
CN116627448A (en) | Method for creating micro-service and related equipment | |
CN113779068B (en) | Data query method, device, equipment and storage medium | |
US10452592B1 (en) | Message bus-based streaming rules engine |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |