Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flink
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leona
web
flink
Commits
7bd5609d
Commit
7bd5609d
authored
Oct 23, 2019
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync
parent
e0101e59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
maven/.gitignore
maven/.gitignore
+1
-0
maven/src/main/java/com/duanledexianxianxian/maven/flink/sql/sql/Main.java
...va/com/duanledexianxianxian/maven/flink/sql/sql/Main.java
+10
-3
No files found.
maven/.gitignore
View file @
7bd5609d
...
...
@@ -106,3 +106,4 @@ buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
/.idea/
maven/src/main/java/com/duanledexianxianxian/maven/flink/sql/sql/Main.java
View file @
7bd5609d
...
...
@@ -7,7 +7,10 @@ import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import
org.apache.flink.streaming.api.functions.source.RichSourceFunction
;
import
org.apache.flink.streaming.api.functions.timestamps.BoundedOutOfOrdernessTimestampExtractor
;
import
org.apache.flink.streaming.api.windowing.time.Time
;
import
org.apache.flink.table.api.EnvironmentSettings
;
import
org.apache.flink.table.api.Over
;
import
org.apache.flink.table.api.Table
;
import
org.apache.flink.table.api.TableEnvironment
;
import
org.apache.flink.table.api.java.StreamTableEnvironment
;
import
org.apache.flink.types.Row
;
...
...
@@ -35,8 +38,12 @@ public class Main {
Table
table
=
tableEnv
.
fromDataStream
(
source
,
"eventTime.rowtime"
);
// register DataStream as Table
tableEnv
.
registerTable
(
"Zhisheng"
,
table
);
Table
sorted
=
tableEnv
.
sqlQuery
(
"select * from Zhisheng "
);
// tableEnv.registerTable("Zhisheng", table);
Table
sorted
=
table
.
window
(
Over
.
partitionBy
(
"eventTime"
)
.
orderBy
(
"eventTime.desc"
)
.
preceding
(
"20.second"
)
.
following
(
"CURRENT_RANGE"
)
.
as
(
"window"
)).
select
(
"eventTime "
);
DataStream
<
Row
>
rowDataStream
=
tableEnv
.
toAppendStream
(
sorted
,
Row
.
class
);
rowDataStream
.
print
();
...
...
@@ -80,7 +87,7 @@ public class Main {
public
void
run
(
SourceContext
<
Event
>
ctx
)
throws
Exception
{
while
(
running
)
{
ctx
.
collect
(
new
Event
());
Thread
.
sleep
(
1
);
Thread
.
sleep
(
5000
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment