mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-11-29 18:48:23 +08:00
[Core] [DataSet] Support sampling key
This commit is contained in:
parent
2deb5056b0
commit
155cf6e5a5
@ -394,6 +394,7 @@ public class DataSetServiceImpl
|
||||
TableBuilder.Companion.ORDER_BY(columnEntities.stream().filter(DataSetColumnEntity::isOrderByKey).map(DataSetColumnEntity::getName).collect(Collectors.toList()));
|
||||
TableBuilder.Companion.PARTITION_BY(columnEntities.stream().filter(DataSetColumnEntity::isPartitionKey).map(DataSetColumnEntity::getName).collect(Collectors.toList()));
|
||||
TableBuilder.Companion.PRIMARY_KEY(columnEntities.stream().filter(DataSetColumnEntity::isPrimaryKey).map(DataSetColumnEntity::getName).collect(Collectors.toList()));
|
||||
TableBuilder.Companion.SAMPLING_KEY(columnEntities.stream().filter(DataSetColumnEntity::isSamplingKey).map(DataSetColumnEntity::getName).collect(Collectors.toList()));
|
||||
String sql = TableBuilder.Companion.SQL();
|
||||
log.info("Create table sql \n {} \n on dataset [ {} ]", sql, entity.getName());
|
||||
|
||||
|
@ -163,6 +163,11 @@ abstract class AbstractSql<T> {
|
||||
return getSelf()
|
||||
}
|
||||
|
||||
fun SAMPING_KEY(columns: List<String>): T {
|
||||
sql().samplingKey.addAll(columns.map { item -> "\t$item" })
|
||||
return getSelf()
|
||||
}
|
||||
|
||||
fun FROM(table: String?): T {
|
||||
sql().tables.add(table)
|
||||
return getSelf()
|
||||
@ -533,6 +538,7 @@ abstract class AbstractSql<T> {
|
||||
var orderByKey: MutableList<String?> = ArrayList()
|
||||
val partitionByKey: MutableList<String?> = ArrayList()
|
||||
val primaryKey: MutableList<String?> = ArrayList()
|
||||
val samplingKey: MutableList<String?> = ArrayList()
|
||||
|
||||
init {
|
||||
// Prevent Synthetic Access
|
||||
@ -688,6 +694,9 @@ abstract class AbstractSql<T> {
|
||||
if (primaryKey.isNotEmpty()) {
|
||||
sqlClause(builder, "PRIMARY KEY", primaryKey, "(", ")", ", ")
|
||||
}
|
||||
if (samplingKey.isNotEmpty()) {
|
||||
sqlClause(builder, "SAMPLE BY", samplingKey, "(", ")", ", ")
|
||||
}
|
||||
if (end) {
|
||||
builder.append(";")
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ class TableBuilder {
|
||||
sql().PRIMARY_KEY(values)
|
||||
}
|
||||
|
||||
fun SAMPLING_KEY(values: List<String>) {
|
||||
sql().SAMPING_KEY(values)
|
||||
}
|
||||
|
||||
fun END() {
|
||||
sql().END()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user