Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
859549f
add savepoint
Oct 10, 2018
816f0b7
Merge branch 'v1.4.1' of https://github.com/DTStack/flinkStreamSQL in…
Oct 10, 2018
f237049
Update README.md
yangsishu Oct 10, 2018
c5cabfd
Merge pull request #9 from DTStack/v1.4.1
yangsishu Oct 10, 2018
015d494
Merge branch 'master' into v1.4.1
Oct 10, 2018
356f605
Update README.md
yangsishu Oct 10, 2018
e50936b
fix mysql async side fill data exception(IndexOutOfBoundsException)
zoudaokoulife Oct 10, 2018
a545fa4
Merge branch 'v1.4.1'
zoudaokoulife Oct 10, 2018
b5be9c0
ysq
Oct 11, 2018
9e8cc55
Merge pull request #10 from DTStack/v1.4.1
yangsishu Oct 11, 2018
a64da86
Type information for indicating event or processing time. However, it…
zoudaokoulife Oct 11, 2018
ddbc0a5
Merge remote-tracking branch 'origin/v1.4.1' into v1.4.1
zoudaokoulife Oct 11, 2018
3894737
Merge branch 'v1.4.1'
zoudaokoulife Oct 11, 2018
74f0cf6
update comment
yangsishu Oct 18, 2018
b4f424c
comment update
yangsishu Oct 18, 2018
82fd7fe
implement hbase table cache
Oct 18, 2018
a89f0a0
cache all data in hbase table
Oct 19, 2018
b8c9251
modify pom, exclude hadoop and log4j
zoudaokoulife Oct 20, 2018
a692b31
Merge branch 'master' into v1.4.1
zoudaokoulife Oct 20, 2018
05dc2d8
load data from hbase
Oct 20, 2018
8f15904
Merge branch 'v1.4.1' of github.com:DTStack/flinkStreamSQL into v1.4.1
Oct 20, 2018
d709c29
exclude hdfs jars
Oct 20, 2018
2875e49
add function demo
yangsishu Oct 21, 2018
92b4037
modify support create table field type(for match standard SQL)
zoudaokoulife Oct 22, 2018
f0375f8
Merge remote-tracking branch 'origin/master'
zoudaokoulife Oct 22, 2018
54ddfd3
Merge branch 'master' into v1.4.1
zoudaokoulife Oct 22, 2018
e4c6a63
Merge remote-tracking branch 'origin/v1.4.1' into v1.4.1
zoudaokoulife Oct 22, 2018
8e570ff
Update README.md
yangsishu Oct 22, 2018
6f7ac17
Update README.md
yangsishu Oct 22, 2018
b935f28
add prefix query function
Oct 22, 2018
885afd5
Merge branch 'v1.4.1' of github.com:DTStack/flinkStreamSQL into v1.4.1
Oct 22, 2018
b7c0146
Update README.md
yangsishu Oct 24, 2018
2d9985b
Update README.md
yangsishu Oct 24, 2018
8a109e4
Update README.md
yangsishu Oct 24, 2018
4801793
Update README.md
yangsishu Nov 1, 2018
7e904b5
modify dbsink bug (not support TIMESTAMP)
zoudaokoulife Nov 2, 2018
827e78c
Update README.md
yangsishu Nov 2, 2018
d5c5b24
Merge branch 'v1.4.1'
zoudaokoulife Nov 2, 2018
afce01b
Merge remote-tracking branch 'origin/master'
zoudaokoulife Nov 2, 2018
aea00f7
add license
zoudaokoulife Nov 3, 2018
94ea2a1
bigfix
Nov 6, 2018
41d323d
Merge branch 'v1.4.1'
Nov 6, 2018
9828b94
fix md demo
zoudaokoulife Nov 8, 2018
625ab58
fix conflict
Nov 16, 2018
8a0e223
fix bug
Nov 16, 2018
5425de2
Update README.md
yangsishu Nov 16, 2018
9f4ddae
fix redis async bug
Nov 16, 2018
a63b327
Merge branch 'master' of github.com:DTStack/flinkStreamSQL
Nov 16, 2018
bd3b789
Merge branch 'v1.5.0_dev' into v1.5.0_release
Nov 16, 2018
277bedc
update kafka source
zhihui-ge Nov 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
> > * 自定义create view 语法
> > * 自定义create function 语法
> > * 实现了流与维表的join
> > * 支持原生FLinkSQL所有的语法

# 已支持
* 源表:kafka 0.9,1.x版本
Expand All @@ -14,6 +15,8 @@
* 增加oracle维表,结果表功能
* 增加SQlServer维表,结果表功能
* 增加kafka结果表功能
* 增加SQL支持CEP
* 维表快照

## 1 快速起步
### 1.1 运行模式
Expand All @@ -26,7 +29,7 @@
### 1.2 执行环境

* Java: JDK8及以上
* Flink集群: 1.4(单机模式不需要安装Flink集群)
* Flink集群: 1.4,1.5(单机模式不需要安装Flink集群)
* 操作系统:理论上不限

### 1.3 打包
Expand All @@ -44,12 +47,12 @@ mvn clean package -Dmaven.test.skip
#### 1.4.1 启动命令

```
sh submit.sh -sql D:\sideSql.txt -name xctest -remoteSqlPluginPath /opt/dtstack/150_flinkplugin/sqlplugin -localSqlPluginPath D:\gitspace\flinkStreamSQL\plugins -mode yarn -flinkconf D:\flink_home\kudu150etc -yarnconf D:\hadoop\etc\hadoopkudu -confProp {\"time.characteristic\":\"EventTime\",\"sql.checkpoint.interval\":10000}
sh submit.sh -sql D:\sideSql.txt -name xctest -remoteSqlPluginPath /opt/dtstack/150_flinkplugin/sqlplugin -localSqlPluginPath D:\gitspace\flinkStreamSQL\plugins -addjar \["udf.jar\"\] -mode yarn -flinkconf D:\flink_home\kudu150etc -yarnconf D:\hadoop\etc\hadoopkudu -confProp \{\"time.characteristic\":\"EventTime\",\"sql.checkpoint.interval\":10000\}
```

#### 1.4.2 命令行参数选项

* **model**
* **mode**
* 描述:执行模式,也就是flink集群的工作模式
* local: 本地模式
* standalone: 独立部署模式的flink集群
Expand Down Expand Up @@ -79,6 +82,7 @@ sh submit.sh -sql D:\sideSql.txt -name xctest -remoteSqlPluginPath /opt/dtstack

* **addjar**
* 描述:扩展jar路径,当前主要是UDF定义的jar;
* 格式:json
* 必选:否
* 默认值:无

Expand Down Expand Up @@ -139,12 +143,16 @@ sh submit.sh -sql D:\sideSql.txt -name xctest -remoteSqlPluginPath /opt/dtstack
## 3 样例

```

CREATE (scala|table) FUNCTION CHARACTER_LENGTH WITH com.dtstack.Kun


CREATE TABLE MyTable(
name varchar,
channel varchar,
pv int,
xctime bigint,
CHARACTER_LENGTH(channel) AS timeLeng
CHARACTER_LENGTH(channel) AS timeLeng //自定义的函数
)WITH(
type ='kafka09',
bootstrapServers ='172.16.8.198:9092',
Expand Down Expand Up @@ -182,7 +190,7 @@ CREATE TABLE sideTable(
cf:name varchar as name,
cf:info varchar as info,
PRIMARY KEY(name),
PERIOD FOR SYSTEM_TIME
PERIOD FOR SYSTEM_TIME //维表标识
)WITH(
type ='hbase',
zookeeperQuorum ='rdos1:2181',
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/com/dtstack/flink/sql/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public class Main {

private static final Logger LOG = LoggerFactory.getLogger(Main.class);

private static final String LOCAL_MODE = "local";

private static final int failureRate = 3;

private static final int failureInterval = 6; //min
Expand Down Expand Up @@ -141,7 +139,7 @@ public static void main(String[] args) throws Exception {
Thread.currentThread().setContextClassLoader(dtClassLoader);

URLClassLoader parentClassloader;
if(!LOCAL_MODE.equals(deployMode)){
if(!ClusterMode.local.name().equals(deployMode)){
parentClassloader = (URLClassLoader) threadClassLoader.getParent();
}else{
parentClassloader = dtClassLoader;
Expand Down Expand Up @@ -313,7 +311,7 @@ private static void registerTable(SqlTree sqlTree, StreamExecutionEnvironment en
}

private static StreamExecutionEnvironment getStreamExeEnv(Properties confProperties, String deployMode) throws IOException {
StreamExecutionEnvironment env = !LOCAL_MODE.equals(deployMode) ?
StreamExecutionEnvironment env = !ClusterMode.local.name().equals(deployMode) ?
StreamExecutionEnvironment.getExecutionEnvironment() :
new MyLocalStreamEnvironment();

Expand Down
2 changes: 1 addition & 1 deletion docs/kafkaSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CREATE TABLE tableName(
|bootstrapServers | kafka bootstrap-server 地址信息(多个用逗号隔开)|是||
|zookeeperQuorum | kafka zk地址信息(多个之间用逗号分隔)|是||
|topic | 需要读取的 topic 名称|是||
|offsetReset | 读取的topic 的offset初始位置[latest\|earliest]|否|latest|
|offsetReset | 读取的topic 的offset初始位置[latest\|earliest\|指定offset值({"0":12312,"1":12321,"2":12312},{"partition_no":offset_value})]|否|latest|
|parallelism | 并行度设置|否|1|

## 5.样例:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@
import com.dtstack.flink.sql.source.IStreamSourceGener;
import com.dtstack.flink.sql.source.kafka.table.KafkaSourceTableInfo;
import com.dtstack.flink.sql.table.SourceTableInfo;
import com.dtstack.flink.sql.util.PluginUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.api.common.functions.RuntimeContext;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer09;
import org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartition;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.StreamTableEnvironment;
import org.apache.flink.types.Row;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
Expand Down Expand Up @@ -76,7 +80,20 @@ public Table genStreamSource(SourceTableInfo sourceTableInfo, StreamExecutionEnv
//earliest,latest
if("earliest".equalsIgnoreCase(kafka09SourceTableInfo.getOffsetReset())){
kafkaSrc.setStartFromEarliest();
}else{
}else if(kafka09SourceTableInfo.getOffsetReset().startsWith("{")){
try {
// {"0":12312,"1":12321,"2":12312}
Properties properties = PluginUtil.jsonStrToObject(kafka09SourceTableInfo.getOffsetReset(), Properties.class);
Map<String, Object> offsetMap = PluginUtil.ObjectToMap(properties);
Map<KafkaTopicPartition, Long> specificStartupOffsets = new HashMap<>();
for(Map.Entry<String,Object> entry:offsetMap.entrySet()){
specificStartupOffsets.put(new KafkaTopicPartition(topicName,Integer.valueOf(entry.getKey())),Long.valueOf(entry.getValue().toString()));
}
kafkaSrc.setStartFromSpecificOffsets(specificStartupOffsets);
} catch (Exception e) {
throw new RuntimeException("not support offsetReset type:" + kafka09SourceTableInfo.getOffsetReset());
}
}else {
kafkaSrc.setStartFromLatest();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@
import com.dtstack.flink.sql.source.IStreamSourceGener;
import com.dtstack.flink.sql.source.kafka.table.KafkaSourceTableInfo;
import com.dtstack.flink.sql.table.SourceTableInfo;
import com.dtstack.flink.sql.util.PluginUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer010;
import org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartition;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.StreamTableEnvironment;
import org.apache.flink.types.Row;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
Expand Down Expand Up @@ -75,7 +79,20 @@ public Table genStreamSource(SourceTableInfo sourceTableInfo, StreamExecutionEnv
//earliest,latest
if("earliest".equalsIgnoreCase(kafka010SourceTableInfo.getOffsetReset())){
kafkaSrc.setStartFromEarliest();
}else{
}else if(kafka010SourceTableInfo.getOffsetReset().startsWith("{")){
try {
// {"0":12312,"1":12321,"2":12312}
Properties properties = PluginUtil.jsonStrToObject(kafka010SourceTableInfo.getOffsetReset(), Properties.class);
Map<String, Object> offsetMap = PluginUtil.ObjectToMap(properties);
Map<KafkaTopicPartition, Long> specificStartupOffsets = new HashMap<>();
for(Map.Entry<String,Object> entry:offsetMap.entrySet()){
specificStartupOffsets.put(new KafkaTopicPartition(topicName,Integer.valueOf(entry.getKey())),Long.valueOf(entry.getValue().toString()));
}
kafkaSrc.setStartFromSpecificOffsets(specificStartupOffsets);
} catch (Exception e) {
throw new RuntimeException("not support offsetReset type:" + kafka010SourceTableInfo.getOffsetReset());
}
}else {
kafkaSrc.setStartFromLatest();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@
import com.dtstack.flink.sql.source.IStreamSourceGener;
import com.dtstack.flink.sql.source.kafka.table.KafkaSourceTableInfo;
import com.dtstack.flink.sql.table.SourceTableInfo;
import com.dtstack.flink.sql.util.PluginUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011;
import org.apache.flink.streaming.connectors.kafka.internals.KafkaTopicPartition;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.StreamTableEnvironment;
import org.apache.flink.types.Row;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
Expand Down Expand Up @@ -75,6 +79,19 @@ public Table genStreamSource(SourceTableInfo sourceTableInfo, StreamExecutionEnv
//earliest,latest
if("earliest".equalsIgnoreCase(kafka011SourceTableInfo.getOffsetReset())){
kafkaSrc.setStartFromEarliest();
}else if(kafka011SourceTableInfo.getOffsetReset().startsWith("{")){
try {
// {"0":12312,"1":12321,"2":12312}
Properties properties = PluginUtil.jsonStrToObject(kafka011SourceTableInfo.getOffsetReset(), Properties.class);
Map<String, Object> offsetMap = PluginUtil.ObjectToMap(properties);
Map<KafkaTopicPartition, Long> specificStartupOffsets = new HashMap<>();
for(Map.Entry<String,Object> entry:offsetMap.entrySet()){
specificStartupOffsets.put(new KafkaTopicPartition(topicName,Integer.valueOf(entry.getKey())),Long.valueOf(entry.getValue().toString()));
}
kafkaSrc.setStartFromSpecificOffsets(specificStartupOffsets);
} catch (Exception e) {
throw new RuntimeException("not support offsetReset type:" + kafka011SourceTableInfo.getOffsetReset());
}
}else{
kafkaSrc.setStartFromLatest();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public MysqlAllReqRow(RowTypeInfo rowTypeInfo, JoinInfo joinInfo, List<FieldInfo
super(new MysqlAllSideInfo(rowTypeInfo, joinInfo, outFieldInfoList, sideTableInfo));
}


@Override
protected Row fillData(Row input, Object sideInput) {
Map<String, Object> cacheInfo = (Map<String, Object>) sideInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ public void asyncInvoke(Row input, ResultFuture<Row> resultFuture) throws Except
List<String> value = async.keys(key + ":*").get();
String[] values = value.toArray(new String[value.size()]);
RedisFuture<List<KeyValue<String, String>>> future = async.mget(values);
while (future.isDone()){
try {
List<KeyValue<String, String>> kvList = future.get();
if (kvList.size() != 0){
for (int i=0; i<kvList.size(); i++){
String[] splitKeys = kvList.get(i).getKey().split(":");
future.thenAccept(new Consumer<List<KeyValue<String, String>>>() {
@Override
public void accept(List<KeyValue<String, String>> keyValues) {
if (keyValues.size() != 0){
for (int i=0; i<keyValues.size(); i++){
String[] splitKeys = keyValues.get(i).getKey().split(":");
keyValue.put(splitKeys[1], splitKeys[2]);
keyValue.put(splitKeys[3], kvList.get(i).getValue());
keyValue.put(splitKeys[3], keyValues.get(i).getValue());
}
Row row = fillData(input, keyValue);
resultFuture.complete(Collections.singleton(row));
Expand All @@ -164,13 +164,8 @@ public void asyncInvoke(Row input, ResultFuture<Row> resultFuture) throws Except
putCache(key, CacheMissVal.getMissKeyObj());
}
}
} catch (InterruptedException e1) {
e1.printStackTrace();
} catch (ExecutionException e1) {
e1.printStackTrace();
}
}

});
}

private String buildCacheKey(List<String> keyData) {
Expand Down