Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does Table API mean in Flink

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the meaning of Table API in Flink, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

What is Table API?

Table API & SQL is a declarative API. Users only need to care about what to do, not how to do it. For example, the WordCount example in the figure only needs to care about what dimension to aggregate and what type of aggregation to do, not the underlying implementation.

High performance. Table API & SQL will have an optimizer at the underlying level to optimize query. For example, if two count operations are written in the WordCount example, the optimizer will recognize and avoid duplicate calculations, keep only one count operation, and output the same value twice to achieve better performance.

The flow and batch are unified. As can be found in the above figure example, API does not distinguish between streams and batches, and the same set of query can be reused in streams and batches. For business development, avoid developing two sets of code.

The standard is stable. Table API & SQL follows the SQL standard and is not easy to change. The advantage of API stability is that you don't have to think about API compatibility.

Easy to understand. The semantics are clear and what you see is what you get.

Table API characteristics

Table API makes multi-declared data processing easier to write.

How do you understand it? For example, we have a Table (tab), and we need to perform some filtering operations and then output to the result table, the corresponding implementation is: tab.where ("a"

< 10").inertInto("resultTable1");此外,我们还需要做另外一些筛选,然后也对结果输出,即 tab.where("a >

InsertInto ("resultTable2"). You will find that it is very simple and convenient to write in Table API, and the function is implemented in two lines of code.

Table API is a set of API of Flink itself, which makes it easier for us to extend the standard SQL. Of course, when extending SQL, it is not random to extend it. You need to consider the semantics, atomicity, and orthogonality of API, and add it when and only when needed.

Compared with SQL, we can think of Table API as a superset of SQL. SQL can operate with Table API, but we can extend and improve SQL from the point of view of ease of use and functionality.

How to get a Table

Step 1: register the corresponding TableSource

The second step is to call the scan method of Table environement to get the Table object

Three ways to register Table Source

Register through Table descriptor

Register by customizing source

Register through DataStream

How to output a Table

Table descriptor

Custom Table sink

Output as a DataStream

The above is all the content of this article "what is the meaning of Table API in Flink?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report