Skip to content

Commit

Permalink
add plan serde test
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitsultana committed Jan 30, 2025
1 parent b671adc commit 8cc51e5
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
package org.apache.pinot.tsdb.spi.plan.serde;

import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand All @@ -36,21 +36,23 @@

public class TimeSeriesPlanSerdeTest {
private static final int SERIES_LIMIT = 1000;
private static final Map<String, String> QUERY_OPTIONS = Collections.emptyMap();
private static final Map<String, String> QUERY_OPTIONS = ImmutableMap.of("numGroupsLimit", "1000");

@Test
public void testSerdeForScanFilterProjectNode() {
Map<String, String> aggParams = new HashMap<>();
aggParams.put("window", "5m");

// create leaf node
LeafTimeSeriesPlanNode leafTimeSeriesPlanNode =
new LeafTimeSeriesPlanNode("sfp#0", new ArrayList<>(), "myTable", "myTimeColumn", TimeUnit.MILLISECONDS, 0L,
"myFilterExpression", "myValueExpression", new AggInfo("SUM", false, aggParams), new ArrayList<>(),
SERIES_LIMIT, QUERY_OPTIONS);
// serialize and deserialize to re-create another node
BaseTimeSeriesPlanNode planNode =
TimeSeriesPlanSerde.deserialize(TimeSeriesPlanSerde.serialize(leafTimeSeriesPlanNode));
assertTrue(planNode instanceof LeafTimeSeriesPlanNode);
LeafTimeSeriesPlanNode deserializedNode = (LeafTimeSeriesPlanNode) planNode;
// assert that deserialized node is same as serialized node
assertEquals(deserializedNode.getTableName(), "myTable");
assertEquals(deserializedNode.getTimeColumn(), "myTimeColumn");
assertEquals(deserializedNode.getTimeUnit(), TimeUnit.MILLISECONDS);
Expand All @@ -62,5 +64,7 @@ public void testSerdeForScanFilterProjectNode() {
assertNotNull(deserializedNode.getAggInfo().getParams());
assertEquals(deserializedNode.getAggInfo().getParams().get("window"), "5m");
assertEquals(deserializedNode.getGroupByExpressions().size(), 0);
assertEquals(deserializedNode.getLimit(), SERIES_LIMIT);
assertEquals(deserializedNode.getQueryOptions(), QUERY_OPTIONS);
}
}

0 comments on commit 8cc51e5

Please sign in to comment.