Search in sources :

Example 6 with IntervalLiteral

use of io.crate.sql.tree.IntervalLiteral in project crate by crate.

the class IntervalLiteralTest method testNegative.

@Test
public void testNegative() {
    IntervalLiteral interval = (IntervalLiteral) SqlParser.createExpression("INTERVAL -'1' HOUR");
    assertThat(interval.getValue(), is("1"));
    assertThat(interval.getSign(), is(IntervalLiteral.Sign.MINUS));
    assertThat(interval.getStartField(), is(IntervalLiteral.IntervalField.HOUR));
    assertThat(interval.getEndField(), is(nullValue()));
}
Also used : IntervalLiteral(io.crate.sql.tree.IntervalLiteral) Test(org.junit.Test)

Example 7 with IntervalLiteral

use of io.crate.sql.tree.IntervalLiteral in project crate by crate.

the class IntervalLiteralTest method testTo.

@Test
public void testTo() {
    IntervalLiteral interval = (IntervalLiteral) SqlParser.createExpression("INTERVAL '1' HOUR TO SECOND");
    assertThat(interval.getValue(), is("1"));
    assertThat(interval.getSign(), is(IntervalLiteral.Sign.PLUS));
    assertThat(interval.getStartField(), is(IntervalLiteral.IntervalField.HOUR));
    assertThat(interval.getEndField(), is(IntervalLiteral.IntervalField.SECOND));
}
Also used : IntervalLiteral(io.crate.sql.tree.IntervalLiteral) Test(org.junit.Test)

Example 8 with IntervalLiteral

use of io.crate.sql.tree.IntervalLiteral in project crate by crate.

the class IntervalLiteralTest method testMonth.

@Test
public void testMonth() {
    IntervalLiteral interval = (IntervalLiteral) SqlParser.createExpression("INTERVAL +'1' MONTH");
    assertThat(interval.getValue(), is("1"));
    assertThat(interval.getSign(), is(IntervalLiteral.Sign.PLUS));
    assertThat(interval.getStartField(), is(IntervalLiteral.IntervalField.MONTH));
    assertThat(interval.getEndField(), is(nullValue()));
}
Also used : IntervalLiteral(io.crate.sql.tree.IntervalLiteral) Test(org.junit.Test)

Example 9 with IntervalLiteral

use of io.crate.sql.tree.IntervalLiteral in project crate by crate.

the class IntervalLiteralTest method testDay.

@Test
public void testDay() {
    IntervalLiteral interval = (IntervalLiteral) SqlParser.createExpression("INTERVAL +'1' DAY");
    assertThat(interval.getValue(), is("1"));
    assertThat(interval.getSign(), is(IntervalLiteral.Sign.PLUS));
    assertThat(interval.getStartField(), is(IntervalLiteral.IntervalField.DAY));
    assertThat(interval.getEndField(), is(nullValue()));
}
Also used : IntervalLiteral(io.crate.sql.tree.IntervalLiteral) Test(org.junit.Test)

Aggregations

IntervalLiteral (io.crate.sql.tree.IntervalLiteral)9 Test (org.junit.Test)8 Token (org.antlr.v4.runtime.Token)1