Skip to content

Commit 8566981

Browse files
committed
Add SPARKLINE aggregation fuction
1 parent 622ff24 commit 8566981

File tree

42 files changed

+6774
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6774
-69
lines changed

x-pack/plugin/esql/compute/build.gradle

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ def prop(Name, Type, type, Wrapper, TYPE, BYTES, Array, Hash) {
8181
]
8282
}
8383

84+
def propWithoutExtra(prop1) {
85+
def res = [ "hasExtra": "" ]
86+
for ( e in prop1 ) {
87+
res.put(e.key, e.value)
88+
res.put("Extra" + e.key, "")
89+
}
90+
return res
91+
}
92+
93+
def propWithExtra(prop1, prop2) {
94+
def res = [ "hasExtra": "true" ]
95+
for ( e in prop1 ) {
96+
res.put(e.key, e.value)
97+
}
98+
for ( e in prop2 ) {
99+
res.put("Extra" + e.key, e.value)
100+
}
101+
return res
102+
}
103+
84104
def addOccurrence(props, Occurrence) {
85105
def newProps = props.collectEntries { [(it.key): it.value] }
86106
newProps["Occurrence"] = Occurrence
@@ -651,6 +671,28 @@ tasks.named('stringTemplates').configure {
651671
it.outputFile = "org/elasticsearch/compute/aggregation/ValuesBytesRefAggregator.java"
652672
}
653673

674+
File sparklineAggregatorInputFile = new File("${projectDir}/src/main/java/org/elasticsearch/compute/aggregation/X-SparklineAggregator.java.st")
675+
template {
676+
it.properties = intProperties
677+
it.inputFile = sparklineAggregatorInputFile
678+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineIntAggregator.java"
679+
}
680+
template {
681+
it.properties = longProperties
682+
it.inputFile = sparklineAggregatorInputFile
683+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineLongAggregator.java"
684+
}
685+
template {
686+
it.properties = floatProperties
687+
it.inputFile = sparklineAggregatorInputFile
688+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineFloatAggregator.java"
689+
}
690+
template {
691+
it.properties = doubleProperties
692+
it.inputFile = sparklineAggregatorInputFile
693+
it.outputFile = "org/elasticsearch/compute/aggregation/SparklineDoubleAggregator.java"
694+
}
695+
654696
File stdDevAggregatorInputFile = file("src/main/java/org/elasticsearch/compute/aggregation/X-StdDevAggregator.java.st")
655697
template {
656698
it.properties = intProperties
@@ -875,25 +917,45 @@ tasks.named('stringTemplates').configure {
875917

876918
File bucketedSortInputFile = new File("${projectDir}/src/main/java/org/elasticsearch/compute/data/sort/X-BucketedSort.java.st")
877919
template {
878-
it.properties = intProperties
920+
it.properties = propWithoutExtra(intProperties)
879921
it.inputFile = bucketedSortInputFile
880922
it.outputFile = "org/elasticsearch/compute/data/sort/IntBucketedSort.java"
881923
}
882924
template {
883-
it.properties = longProperties
925+
it.properties = propWithoutExtra(longProperties)
884926
it.inputFile = bucketedSortInputFile
885927
it.outputFile = "org/elasticsearch/compute/data/sort/LongBucketedSort.java"
886928
}
887929
template {
888-
it.properties = floatProperties
930+
it.properties = propWithoutExtra(floatProperties)
889931
it.inputFile = bucketedSortInputFile
890932
it.outputFile = "org/elasticsearch/compute/data/sort/FloatBucketedSort.java"
891933
}
892934
template {
893-
it.properties = doubleProperties
935+
it.properties = propWithoutExtra(doubleProperties)
894936
it.inputFile = bucketedSortInputFile
895937
it.outputFile = "org/elasticsearch/compute/data/sort/DoubleBucketedSort.java"
896938
}
939+
template {
940+
it.properties = propWithExtra(longProperties, intProperties)
941+
it.inputFile = bucketedSortInputFile
942+
it.outputFile = "org/elasticsearch/compute/data/sort/LongIntBucketedSort.java"
943+
}
944+
template {
945+
it.properties = propWithExtra(longProperties, longProperties)
946+
it.inputFile = bucketedSortInputFile
947+
it.outputFile = "org/elasticsearch/compute/data/sort/LongLongBucketedSort.java"
948+
}
949+
template {
950+
it.properties = propWithExtra(longProperties, floatProperties)
951+
it.inputFile = bucketedSortInputFile
952+
it.outputFile = "org/elasticsearch/compute/data/sort/LongFloatBucketedSort.java"
953+
}
954+
template {
955+
it.properties = propWithExtra(longProperties, doubleProperties)
956+
it.inputFile = bucketedSortInputFile
957+
it.outputFile = "org/elasticsearch/compute/data/sort/LongDoubleBucketedSort.java"
958+
}
897959

898960
File enrichResultBuilderInput = file("src/main/java/org/elasticsearch/compute/operator/lookup/X-EnrichResultBuilder.java.st")
899961
template {

x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ private MethodSpec addIntermediateInput() {
604604
declarationType,
605605
requireVoidType(),
606606
requireName("combineIntermediate"),
607-
requireArgs(
607+
requireArgsStartsWith(
608608
Stream.concat(
609609
Stream.of(aggState.declaredType()), // aggState
610610
intermediateState.stream().map(IntermediateStateDesc::combineArgType) // intermediate state

x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/aggregation/SparklineDoubleAggregator.java

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)