In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the "query conversion method of flinksql table". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the query transformation method of flinksql table.
Package com.jd.data;import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;import org.apache.flink.table.api.DataTypes;import org.apache.flink.table.api.Table;import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;import org.apache.flink.table.descriptors.FileSystem;import org.apache.flink.table.descriptors.OldCsv;import org.apache.flink.table.descriptors.Schema;import org.apache.flink.types.Row;import scala.Tuple3 Import static org.apache.flink.table.api.Expressions.$;public class TableAipDemo03 {public static void main (String [] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment (); env.setParallelism (1); / / 1. Creation table execution StreamTableEnvironment tableEnv = StreamTableEnvironment.create (env); String path = "/ Users/liuhaijing/Desktop/flinktestword/aaa.txt" TableEnv.connect (new FileSystem (). Path (path)) .withFormat (new OldCsv ()) / defines the formatting method .withSchema (new Schema (). Field ("a", DataTypes.STRING ()) / / defines the structure of the table .field ("b", DataTypes.STRING ()) .field ("c") DataTypes.STRING ()) .createTemporaryTable ("xxx") / / query and transformation of tables Table xxx = tableEnv.from ("xxx"); / / simple query Table select = xxx.select ("a, b"). Filter ($("a"). IsEqual ("a"); Table select2 = select.groupBy ($("a")) .select ($("a"), $("a"). Count (). As ("count")) Select2.printSchema (); / / output result in a revocable manner will be preceded by a column of boolean true indicating that this time shall prevail, and false shall be invalid tableEnv.toRetractStream (select2, Row.class). Print (); env.execute ("job") }} Thank you for your reading, the above is the content of "query conversion method of flinksql table". After the study of this article, I believe you have a deeper understanding of the query conversion method of flinksql table, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.