Search in sources :

Example 1 with IntervalLiteral

use of com.facebook.presto.sql.tree.IntervalLiteral in project presto by prestodb.

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(com.facebook.presto.sql.tree.IntervalLiteral) TimestampLiteral(com.facebook.presto.sql.tree.TimestampLiteral) CharLiteral(com.facebook.presto.sql.tree.CharLiteral) TimeLiteral(com.facebook.presto.sql.tree.TimeLiteral) Test(org.testng.annotations.Test)

Example 2 with IntervalLiteral

use of com.facebook.presto.sql.tree.IntervalLiteral in project presto by prestodb.

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(com.facebook.presto.sql.tree.IntervalLiteral) Test(org.testng.annotations.Test)

Aggregations

IntervalLiteral (com.facebook.presto.sql.tree.IntervalLiteral)2 Test (org.testng.annotations.Test)2 CharLiteral (com.facebook.presto.sql.tree.CharLiteral)1 TimeLiteral (com.facebook.presto.sql.tree.TimeLiteral)1 TimestampLiteral (com.facebook.presto.sql.tree.TimestampLiteral)1