Skip to content

Commit f449cbf

Browse files
committed
Merged with latest main branch
2 parents 3076062 + 4b64daf commit f449cbf

File tree

127 files changed

+4182
-3418
lines changed

Some content is hidden

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

127 files changed

+4182
-3418
lines changed

.github/workflows/test_scala_no_spark.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
4949
- name: Run Flink tests
5050
run: |
51+
export SBT_OPTS="-Xmx24G -Xms4G --add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
5152
sbt "++ 2.12.18 flink/test"
5253
5354
- name: Run Aggregator tests
@@ -58,6 +59,10 @@ jobs:
5859
run: |
5960
sbt "++ 2.12.18 online/test"
6061
62+
- name: Run Catalyst Util tests
63+
run: |
64+
sbt "++ 2.12.18 online/testOnly -- -n catalystUtilHiveUdfTest"
65+
6166
- name: Run api tests
6267
run: |
6368
sbt "++ 2.12.18 api/test"

.plugin-versions

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
asdf-plugin-manager https://github.com/asdf-community/asdf-plugin-manager.git b5862c1
2+
gcloud https://github.com/jthegedus/asdf-gcloud.git 00cdf06
23
java https://github.com/halcyon/asdf-java.git 0ec69b2
34
python https://github.com/danhper/asdf-python.git a3a0185
45
sbt https://github.com/lerencao/asdf-sbt 53c9f4b
56
scala https://github.com/asdf-community/asdf-scala.git 0533444
7+
thrift https://github.com/alisaifee/asdf-thrift.git fecdd6c

.tool-versions

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
java corretto-11.0.25.9.1
2-
scala 2.12.20
1+
java corretto-17.0.9.8.1
2+
scala 2.12.18
33
asdf-plugin-manager 1.4.0
44
sbt 1.8.2
55
python
66
3.7.17
77
3.11.0
8+
gcloud 504.0.1

aggregator/src/test/scala/ai/chronon/aggregator/test/ApproxDistinctTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
package ai.chronon.aggregator.test
1818

1919
import ai.chronon.aggregator.base.ApproxDistinctCount
20-
import junit.framework.TestCase
2120
import org.junit.Assert._
21+
import org.scalatest.flatspec.AnyFlatSpec
2222

23-
class ApproxDistinctTest extends TestCase {
23+
class ApproxDistinctTest extends AnyFlatSpec {
2424
def testErrorBound(uniques: Int, errorBound: Int, lgK: Int): Unit = {
2525
val uniqueElems = 1 to uniques
2626
val duplicates = uniqueElems ++ uniqueElems ++ uniqueElems
@@ -50,13 +50,13 @@ class ApproxDistinctTest extends TestCase {
5050
assertTrue(Math.abs(estimated - uniques) < errorBound)
5151
}
5252

53-
def testErrorBounds(): Unit = {
53+
it should "error bounds" in {
5454
testErrorBound(uniques = 100, errorBound = 1, lgK = 10)
5555
testErrorBound(uniques = 1000, errorBound = 20, lgK = 10)
5656
testErrorBound(uniques = 10000, errorBound = 300, lgK = 10)
5757
}
5858

59-
def testMergingErrorBounds(): Unit = {
59+
it should "merging error bounds" in {
6060
testMergingErrorBound(uniques = 100, errorBound = 1, lgK = 10, merges = 10)
6161
testMergingErrorBound(uniques = 1000, errorBound = 20, lgK = 10, merges = 4)
6262
testMergingErrorBound(uniques = 10000, errorBound = 400, lgK = 10, merges = 100)

aggregator/src/test/scala/ai/chronon/aggregator/test/ApproxHistogramTest.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package ai.chronon.aggregator.test
22

33
import ai.chronon.aggregator.base.ApproxHistogram
44
import ai.chronon.aggregator.base.ApproxHistogramIr
5-
import junit.framework.TestCase
65
import org.junit.Assert._
6+
import org.scalatest.flatspec.AnyFlatSpec
77

88
import java.util
99
import scala.jdk.CollectionConverters._
1010

11-
class ApproxHistogramTest extends TestCase {
12-
def testHistogram(): Unit = {
11+
class ApproxHistogramTest extends AnyFlatSpec {
12+
it should "histogram" in {
1313
val approxHistogram = new ApproxHistogram[String](3)
1414
val counts = (1L to 3).map(i => i.toString -> i).toMap
1515
val ir = makeIr(approxHistogram, counts)
@@ -19,7 +19,7 @@ class ApproxHistogramTest extends TestCase {
1919
assertEquals(toHashMap(counts), approxHistogram.finalize(ir))
2020
}
2121

22-
def testSketch(): Unit = {
22+
it should "sketch" in {
2323
val approxHistogram = new ApproxHistogram[String](3)
2424
val counts = (1L to 4).map(i => i.toString -> i).toMap
2525
val expected = counts.toSeq.sortBy(_._2).reverse.take(3).toMap
@@ -30,7 +30,7 @@ class ApproxHistogramTest extends TestCase {
3030
assertEquals(toHashMap(expected), approxHistogram.finalize(ir))
3131
}
3232

33-
def testMergeSketches(): Unit = {
33+
it should "merge sketches" in {
3434
val approxHistogram = new ApproxHistogram[String](3)
3535
val counts1: Map[String, Long] = Map("5" -> 5L, "4" -> 4, "2" -> 2, "1" -> 1)
3636
val counts2: Map[String, Long] = Map("6" -> 6L, "4" -> 4, "2" -> 2, "1" -> 1)
@@ -52,7 +52,7 @@ class ApproxHistogramTest extends TestCase {
5252
assertTrue(ir.histogram.isEmpty)
5353
}
5454

55-
def testMergeHistograms(): Unit = {
55+
it should "merge histograms" in {
5656
val approxHistogram = new ApproxHistogram[String](3)
5757
val counts1: Map[String, Long] = Map("4" -> 4L, "2" -> 2)
5858
val counts2: Map[String, Long] = Map("3" -> 3L, "2" -> 2)
@@ -74,7 +74,7 @@ class ApproxHistogramTest extends TestCase {
7474
assertTrue(ir.sketch.isEmpty)
7575
}
7676

77-
def testMergeHistogramsToSketch(): Unit = {
77+
it should "merge histograms to sketch" in {
7878
val approxHistogram = new ApproxHistogram[String](3)
7979
val counts1: Map[String, Long] = Map("4" -> 4L, "3" -> 3)
8080
val counts2: Map[String, Long] = Map("2" -> 2L, "1" -> 1)
@@ -97,7 +97,7 @@ class ApproxHistogramTest extends TestCase {
9797
assertTrue(ir.histogram.isEmpty)
9898
}
9999

100-
def testMergeSketchAndHistogram(): Unit = {
100+
it should "merge sketch and histogram" in {
101101
val approxHistogram = new ApproxHistogram[String](3)
102102
val counts1: Map[String, Long] = Map("5" -> 5L, "3" -> 3, "2" -> 2, "1" -> 1)
103103
val counts2: Map[String, Long] = Map("2" -> 2L)
@@ -119,7 +119,7 @@ class ApproxHistogramTest extends TestCase {
119119
assert(ir.histogram.isEmpty)
120120
}
121121

122-
def testNormalizeHistogram(): Unit = {
122+
it should "normalize histogram" in {
123123
val approxHistogram = new ApproxHistogram[String](3)
124124
val counts = (1L to 3).map(i => i.toString -> i).toMap
125125
val ir = makeIr(approxHistogram, counts)
@@ -129,7 +129,7 @@ class ApproxHistogramTest extends TestCase {
129129
assertEquals(ir, normalized)
130130
}
131131

132-
def testNormalizeSketch(): Unit = {
132+
it should "normalize sketch" in {
133133
val approxHistogram = new ApproxHistogram[String](3)
134134
val counts = (1L to 4).map(i => i.toString -> i).toMap
135135
val expected = counts.toSeq.sortBy(_._2).reverse.take(3).toMap

aggregator/src/test/scala/ai/chronon/aggregator/test/ApproxPercentilesTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ package ai.chronon.aggregator.test
1818

1919
import ai.chronon.aggregator.base.ApproxPercentiles
2020
import ai.chronon.aggregator.row.StatsGenerator
21-
import junit.framework.TestCase
2221
import org.apache.datasketches.kll.KllFloatsSketch
2322
import org.junit.Assert._
23+
import org.scalatest.flatspec.AnyFlatSpec
2424
import org.slf4j.Logger
2525
import org.slf4j.LoggerFactory
2626

2727
import scala.util.Random
2828

29-
class ApproxPercentilesTest extends TestCase {
29+
class ApproxPercentilesTest extends AnyFlatSpec {
3030
@transient lazy val logger: Logger = LoggerFactory.getLogger(getClass)
3131

3232
def basicImplTestHelper(nums: Int, slide: Int, k: Int, percentiles: Array[Double], errorPercent: Float): Unit = {
@@ -56,7 +56,7 @@ class ApproxPercentilesTest extends TestCase {
5656
diffs.foreach(diff => assertTrue(diff < errorMargin))
5757
}
5858

59-
def testBasicPercentiles: Unit = {
59+
it should "basic percentiles: unit = {" in {
6060
val percentiles_tested: Int = 31
6161
val percentiles: Array[Double] = (0 to percentiles_tested).toArray.map(i => i * 1.0 / percentiles_tested)
6262
basicImplTestHelper(3000, 5, 100, percentiles, errorPercent = 4)
@@ -74,7 +74,7 @@ class ApproxPercentilesTest extends TestCase {
7474
drift
7575
}
7676

77-
def testPSIDrifts(): Unit = {
77+
it should "psi drifts" in {
7878
assertTrue(
7979
getPSIDrift(
8080
Array(1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7).map(_.toFloat),

aggregator/src/test/scala/ai/chronon/aggregator/test/FrequentItemsTest.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import ai.chronon.aggregator.base.FrequentItemType
44
import ai.chronon.aggregator.base.FrequentItems
55
import ai.chronon.aggregator.base.FrequentItemsFriendly
66
import ai.chronon.aggregator.base.ItemsSketchIR
7-
import junit.framework.TestCase
87
import org.junit.Assert._
8+
import org.scalatest.flatspec.AnyFlatSpec
99

1010
import java.util
1111
import scala.jdk.CollectionConverters._
1212

13-
class FrequentItemsTest extends TestCase {
14-
def testNonPowerOfTwoAndTruncate(): Unit = {
13+
class FrequentItemsTest extends AnyFlatSpec {
14+
it should "non power of two and truncate" in {
1515
val size = 3
1616
val items = new FrequentItems[String](size)
1717
val ir = items.prepare("4")
@@ -32,7 +32,7 @@ class FrequentItemsTest extends TestCase {
3232
)), result)
3333
}
3434

35-
def testLessItemsThanSize(): Unit = {
35+
it should "less items than size" in {
3636
val size = 10
3737
val items = new FrequentItems[java.lang.Long](size)
3838
val ir = items.prepare(3)
@@ -52,7 +52,7 @@ class FrequentItemsTest extends TestCase {
5252
)), result)
5353
}
5454

55-
def testZeroSize(): Unit = {
55+
it should "zero size" in {
5656
val size = 0
5757
val items = new FrequentItems[java.lang.Double](size)
5858
val ir = items.prepare(3.0)
@@ -68,7 +68,7 @@ class FrequentItemsTest extends TestCase {
6868
assertEquals(new util.HashMap[String, Double](), result)
6969
}
7070

71-
def testSketchSizes(): Unit = {
71+
it should "sketch sizes" in {
7272
val expectedSketchSizes =
7373
Map(
7474
-1 -> 2,
@@ -87,7 +87,7 @@ class FrequentItemsTest extends TestCase {
8787
assertEquals(expectedSketchSizes, actualSketchSizes)
8888
}
8989

90-
def testNormalization(): Unit = {
90+
it should "normalization" in {
9191
val testValues = (1 to 4)
9292
.map(i => i -> i)
9393
.toMap
@@ -118,7 +118,7 @@ class FrequentItemsTest extends TestCase {
118118
assertEquals(expectedStringValues, actualStringValues)
119119
}
120120

121-
def testBulkMerge(): Unit = {
121+
it should "bulk merge" in {
122122
val sketch = new FrequentItems[String](3)
123123

124124
val irs = Seq(

aggregator/src/test/scala/ai/chronon/aggregator/test/MinHeapTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
package ai.chronon.aggregator.test
1818

1919
import ai.chronon.aggregator.base.MinHeap
20-
import junit.framework.TestCase
2120
import org.junit.Assert._
21+
import org.scalatest.flatspec.AnyFlatSpec
2222

2323
import java.util
2424
import scala.collection.JavaConverters._
2525

26-
class MinHeapTest extends TestCase {
27-
def testInserts(): Unit = {
26+
class MinHeapTest extends AnyFlatSpec {
27+
it should "inserts" in {
2828
val mh = new MinHeap[Int](maxSize = 4, Ordering.Int)
2929

3030
def make_container = new util.ArrayList[Int](4)

aggregator/src/test/scala/ai/chronon/aggregator/test/MomentTest.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package ai.chronon.aggregator.test
22

33
import ai.chronon.aggregator.base._
4-
import junit.framework.TestCase
54
import org.apache.commons.math3.stat.descriptive.moment.{Kurtosis => ApacheKurtosis}
65
import org.apache.commons.math3.stat.descriptive.moment.{Skewness => ApacheSkew}
76
import org.junit.Assert._
7+
import org.scalatest.flatspec.AnyFlatSpec
88

9-
class MomentTest extends TestCase {
9+
class MomentTest extends AnyFlatSpec {
1010
def makeAgg(aggregator: MomentAggregator, values: Seq[Double]): (MomentAggregator, MomentsIR) = {
1111
var ir = aggregator.prepare(values.head)
1212

@@ -36,32 +36,32 @@ class MomentTest extends TestCase {
3636
assertEquals(expected(v1 ++ v2), agg.finalize(ir), 0.1)
3737
}
3838

39-
def testUpdate(): Unit = {
39+
it should "update" in {
4040
val values = Seq(1.1, 2.2, 3.3, 4.4, 5.5)
4141
assertUpdate(new Skew(), values, expectedSkew)
4242
assertUpdate(new Kurtosis(), values, expectedKurtosis)
4343
}
4444

45-
def testInsufficientSizes(): Unit = {
45+
it should "insufficient sizes" in {
4646
val values = Seq(1.1, 2.2, 3.3, 4.4)
4747
assertUpdate(new Skew(), values.take(2), _ => Double.NaN)
4848
assertUpdate(new Kurtosis(), values.take(3), _ => Double.NaN)
4949
}
5050

51-
def testNoVariance(): Unit = {
51+
it should "no variance" in {
5252
val values = Seq(1.0, 1.0, 1.0, 1.0)
5353
assertUpdate(new Skew(), values, _ => Double.NaN)
5454
assertUpdate(new Kurtosis(), values, _ => Double.NaN)
5555
}
5656

57-
def testMerge(): Unit = {
57+
it should "merge" in {
5858
val values1 = Seq(1.1, 2.2, 3.3)
5959
val values2 = Seq(4.4, 5.5)
6060
assertMerge(new Kurtosis(), values1, values2, expectedKurtosis)
6161
assertMerge(new Skew(), values1, values2, expectedSkew)
6262
}
6363

64-
def testNormalize(): Unit = {
64+
it should "normalize" in {
6565
val values = Seq(1.0, 2.0, 3.0, 4.0, 5.0)
6666
val (agg, ir) = makeAgg(new Kurtosis, values)
6767

aggregator/src/test/scala/ai/chronon/aggregator/test/RowAggregatorTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package ai.chronon.aggregator.test
1818

1919
import ai.chronon.aggregator.row.RowAggregator
2020
import ai.chronon.api._
21-
import junit.framework.TestCase
2221
import org.junit.Assert._
22+
import org.scalatest.flatspec.AnyFlatSpec
2323

2424
import java.util
2525
import scala.collection.JavaConverters._
@@ -48,8 +48,8 @@ object TestRow {
4848
def apply(inputsArray: Any*): TestRow = new TestRow(inputsArray: _*)()
4949
}
5050

51-
class RowAggregatorTest extends TestCase {
52-
def testUpdate(): Unit = {
51+
class RowAggregatorTest extends AnyFlatSpec {
52+
it should "update" in {
5353
val rows = List(
5454
TestRow(1L, 4, 5.0f, "A", Seq(5, 3, 4), Seq("D", "A", "B", "A"), Map("A" -> 1, "B" -> 2)),
5555
TestRow(2L, 3, 4.0f, "B", Seq(6, null), Seq(), null),

aggregator/src/test/scala/ai/chronon/aggregator/test/SawtoothAggregatorTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import ai.chronon.aggregator.windowing._
2222
import ai.chronon.api.Extensions.AggregationOps
2323
import ai.chronon.api._
2424
import com.google.gson.Gson
25-
import junit.framework.TestCase
2625
import org.junit.Assert._
26+
import org.scalatest.flatspec.AnyFlatSpec
2727
import org.slf4j.Logger
2828
import org.slf4j.LoggerFactory
2929

@@ -46,9 +46,9 @@ class Timer {
4646
}
4747
}
4848

49-
class SawtoothAggregatorTest extends TestCase {
49+
class SawtoothAggregatorTest extends AnyFlatSpec {
5050

51-
def testTailAccuracy(): Unit = {
51+
it should "tail accuracy" in {
5252
val timer = new Timer
5353
val queries = CStream.genTimestamps(new Window(30, TimeUnit.DAYS), 10000, 5 * 60 * 1000)
5454

@@ -119,7 +119,7 @@ class SawtoothAggregatorTest extends TestCase {
119119
}
120120
}
121121

122-
def testRealTimeAccuracy(): Unit = {
122+
it should "real time accuracy" in {
123123
val timer = new Timer
124124
val queries = CStream.genTimestamps(new Window(1, TimeUnit.DAYS), 1000)
125125
val columns = Seq(Column("ts", LongType, 180),

aggregator/src/test/scala/ai/chronon/aggregator/test/SawtoothOnlineAggregatorTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ import ai.chronon.api.Extensions.WindowOps
2424
import ai.chronon.api.Extensions.WindowUtils
2525
import ai.chronon.api._
2626
import com.google.gson.Gson
27-
import junit.framework.TestCase
2827
import org.junit.Assert.assertEquals
28+
import org.scalatest.flatspec.AnyFlatSpec
2929

3030
import java.time.Instant
3131
import java.time.ZoneOffset
3232
import java.time.format.DateTimeFormatter
3333
import java.util.Locale
3434

35-
class SawtoothOnlineAggregatorTest extends TestCase {
35+
class SawtoothOnlineAggregatorTest extends AnyFlatSpec {
3636

37-
def testConsistency(): Unit = {
37+
it should "consistency" in {
3838
val queryEndTs = TsUtils.round(System.currentTimeMillis(), WindowUtils.Day.millis)
3939
val batchEndTs = queryEndTs - WindowUtils.Day.millis
4040
val queries = CStream.genTimestamps(new Window(1, TimeUnit.DAYS), 1000)

0 commit comments

Comments
 (0)