Search in sources :

Example 1 with IntervalLiteral

use of io.prestosql.sql.tree.IntervalLiteral in project hetu-core by openlookeng.

the class TestSqlParser method testLiterals.

@Test
public void testLiterals() {
    assertExpression("TIME" + " 'abc'", new TimeLiteral("abc"));
    assertExpression("TIMESTAMP" + " 'abc'", new TimestampLiteral("abc"));
    assertExpression("INTERVAL '33' day", new IntervalLiteral("33", Sign.POSITIVE, IntervalField.DAY, Optional.empty()));
    assertExpression("INTERVAL '33' day to second", new IntervalLiteral("33", Sign.POSITIVE, IntervalField.DAY, Optional.of(IntervalField.SECOND)));
    assertExpression("CHAR 'abc'", new CharLiteral("abc"));
}
Also used : IntervalLiteral(io.prestosql.sql.tree.IntervalLiteral) TimestampLiteral(io.prestosql.sql.tree.TimestampLiteral) CharLiteral(io.prestosql.sql.tree.CharLiteral) TimeLiteral(io.prestosql.sql.tree.TimeLiteral) Test(org.testng.annotations.Test)

Example 2 with IntervalLiteral

use of io.prestosql.sql.tree.IntervalLiteral in project hetu-core by openlookeng.

the class TestSqlParser method testInterval.

@Test
public void testInterval() {
    assertExpression("INTERVAL '123' YEAR", new IntervalLiteral("123", Sign.POSITIVE, IntervalField.YEAR));
    assertExpression("INTERVAL '123-3' YEAR TO MONTH", new IntervalLiteral("123-3", Sign.POSITIVE, IntervalField.YEAR, Optional.of(IntervalField.MONTH)));
    assertExpression("INTERVAL '123' MONTH", new IntervalLiteral("123", Sign.POSITIVE, IntervalField.MONTH));
    assertExpression("INTERVAL '123' DAY", new IntervalLiteral("123", Sign.POSITIVE, IntervalField.DAY));
    assertExpression("INTERVAL '123 23:58:53.456' DAY TO SECOND", new IntervalLiteral("123 23:58:53.456", Sign.POSITIVE, IntervalField.DAY, Optional.of(IntervalField.SECOND)));
    assertExpression("INTERVAL '123' HOUR", new IntervalLiteral("123", Sign.POSITIVE, IntervalField.HOUR));
    assertExpression("INTERVAL '23:59' HOUR TO MINUTE", new IntervalLiteral("23:59", Sign.POSITIVE, IntervalField.HOUR, Optional.of(IntervalField.MINUTE)));
    assertExpression("INTERVAL '123' MINUTE", new IntervalLiteral("123", Sign.POSITIVE, IntervalField.MINUTE));
    assertExpression("INTERVAL '123' SECOND", new IntervalLiteral("123", Sign.POSITIVE, IntervalField.SECOND));
}
Also used : IntervalLiteral(io.prestosql.sql.tree.IntervalLiteral) Test(org.testng.annotations.Test)

Aggregations

IntervalLiteral (io.prestosql.sql.tree.IntervalLiteral)2 Test (org.testng.annotations.Test)2 CharLiteral (io.prestosql.sql.tree.CharLiteral)1 TimeLiteral (io.prestosql.sql.tree.TimeLiteral)1 TimestampLiteral (io.prestosql.sql.tree.TimestampLiteral)1