Skip to content

Commit 9db439f

Browse files
committed
fix fields duplicates
1 parent 2181ac2 commit 9db439f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

bridge/src/main/scala/app/softnetwork/elastic/sql/bridge/ElasticAggregation.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,17 @@ object ElasticAggregation {
167167
.fetchSource(
168168
th.identifier.name +: th.fields
169169
.filterNot(_.isScriptField)
170+
.filterNot(_.sourceField == th.identifier.name)
170171
.map(_.sourceField)
172+
.distinct
171173
.toArray,
172174
Array.empty
173175
)
174176
.copy(
175177
scripts = th.fields
176178
.filter(_.isScriptField)
179+
.groupBy(_.sourceField)
180+
.map(_._2.head)
177181
.map(f => f.sourceField -> Script(f.painless(None)).lang("painless"))
178182
.toMap
179183
)

es6/bridge/src/main/scala/app/softnetwork/elastic/sql/bridge/ElasticAggregation.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,17 @@ object ElasticAggregation {
167167
.fetchSource(
168168
th.identifier.name +: th.fields
169169
.filterNot(_.isScriptField)
170+
.filterNot(_.sourceField == th.identifier.name)
170171
.map(_.sourceField)
172+
.distinct
171173
.toArray,
172174
Array.empty
173175
)
174176
.copy(
175177
scripts = th.fields
176178
.filter(_.isScriptField)
179+
.groupBy(_.sourceField)
180+
.map(_._2.head)
177181
.map(f => f.sourceField -> Script(f.painless(None)).lang("painless"))
178182
.toMap
179183
)

0 commit comments

Comments
 (0)