Skip to content

Commit

Permalink
Add missed update to AstBuilderTest for sort option
Browse files Browse the repository at this point in the history
Signed-off-by: James Duong <[email protected]>
  • Loading branch information
jduo committed Oct 31, 2024
1 parent b8dff3a commit 49fc894
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Optional;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -670,15 +671,61 @@ public void testTrendline() {
+ " test_field_alias_2",
trendline(
relation("t"),
Optional.empty(),
computation(5, field("test_field"), "test_field_alias", SMA),
computation(1, field("test_field_2"), "test_field_alias_2", SMA)));
}

@Test
public void testTrendlineSort() {
assertEqual(
"source=t | trendline sort test_field sma(5, test_field)",
trendline(
relation("t"),
Optional.of(
field(
"test_field",
argument("asc", booleanLiteral(true)),
argument("type", nullLiteral()))),
computation(5, field("test_field"), "test_field_trendline", SMA)));
}

@Test
public void testTrendlineSortDesc() {
assertEqual(
"source=t | trendline sort - test_field sma(5, test_field)",
trendline(
relation("t"),
Optional.of(
field(
"test_field",
argument("asc", booleanLiteral(false)),
argument("type", nullLiteral()))),
computation(5, field("test_field"), "test_field_trendline", SMA)));
}

@Test
public void testTrendlineSortAsc() {
assertEqual(
"source=t | trendline sort + test_field sma(5, test_field)",
trendline(
relation("t"),
Optional.of(
field(
"test_field",
argument("asc", booleanLiteral(true)),
argument("type", nullLiteral()))),
computation(5, field("test_field"), "test_field_trendline", SMA)));
}

@Test
public void testTrendlineNoAlias() {
assertEqual(
"source=t | trendline sma(5, test_field)",
trendline(relation("t"), computation(5, field("test_field"), "test_field_trendline", SMA)));
trendline(
relation("t"),
Optional.empty(),
computation(5, field("test_field"), "test_field_trendline", SMA)));
}

@Test
Expand Down

0 comments on commit 49fc894

Please sign in to comment.