Search in sources :

Example 11 with SetTimeZone

use of io.trino.sql.tree.SetTimeZone in project trino by trinodb.

the class TestSetTimeZoneTask method testSetTimeZoneStringLiteral.

@Test
public void testSetTimeZoneStringLiteral() {
    QueryStateMachine stateMachine = createQueryStateMachine("SET TIME ZONE 'America/Los_Angeles'");
    SetTimeZone setTimeZone = new SetTimeZone(new NodeLocation(1, 1), Optional.of(new StringLiteral("America/Los_Angeles")));
    executeSetTimeZone(setTimeZone, stateMachine);
    Map<String, String> setSessionProperties = stateMachine.getSetSessionProperties();
    assertThat(setSessionProperties).hasSize(1);
    assertEquals(setSessionProperties.get(TIME_ZONE_ID), "America/Los_Angeles");
}
Also used : NodeLocation(io.trino.sql.tree.NodeLocation) StringLiteral(io.trino.sql.tree.StringLiteral) SetTimeZone(io.trino.sql.tree.SetTimeZone) Test(org.testng.annotations.Test)

Example 12 with SetTimeZone

use of io.trino.sql.tree.SetTimeZone in project trino by trinodb.

the class TestSetTimeZoneTask method testSetTimeIntervalLiteralZoneHourToMinute.

@Test
public void testSetTimeIntervalLiteralZoneHourToMinute() {
    QueryStateMachine stateMachine = createQueryStateMachine("SET TIME ZONE INTERVAL -'08:00' HOUR TO MINUTE");
    SetTimeZone setTimeZone = new SetTimeZone(new NodeLocation(1, 1), Optional.of(new IntervalLiteral("8", NEGATIVE, HOUR, Optional.of(MINUTE))));
    executeSetTimeZone(setTimeZone, stateMachine);
    Map<String, String> setSessionProperties = stateMachine.getSetSessionProperties();
    assertThat(setSessionProperties).hasSize(1);
    assertEquals(setSessionProperties.get(TIME_ZONE_ID), "-08:00");
}
Also used : IntervalLiteral(io.trino.sql.tree.IntervalLiteral) NodeLocation(io.trino.sql.tree.NodeLocation) SetTimeZone(io.trino.sql.tree.SetTimeZone) Test(org.testng.annotations.Test)

Aggregations

SetTimeZone (io.trino.sql.tree.SetTimeZone)12 NodeLocation (io.trino.sql.tree.NodeLocation)11 Test (org.testng.annotations.Test)11 StringLiteral (io.trino.sql.tree.StringLiteral)6 FunctionCall (io.trino.sql.tree.FunctionCall)5 Identifier (io.trino.sql.tree.Identifier)5 IntervalLiteral (io.trino.sql.tree.IntervalLiteral)5 TrinoException (io.trino.spi.TrinoException)4 QueryUtil.quotedIdentifier (io.trino.sql.QueryUtil.quotedIdentifier)1 Test (org.junit.jupiter.api.Test)1