use of io.trino.sql.tree.StringLiteral in project trino by trinodb.
the class TestSetTimeZoneTask method testSetTimeZoneIntervalDayTimeTypeInvalidFunctionCall.
@Test
public void testSetTimeZoneIntervalDayTimeTypeInvalidFunctionCall() {
QueryStateMachine stateMachine = createQueryStateMachine("SET TIME ZONE parse_duration('3601s')");
SetTimeZone setTimeZone = new SetTimeZone(new NodeLocation(1, 1), Optional.of(new FunctionCall(new NodeLocation(1, 24), QualifiedName.of(ImmutableList.of(new Identifier(new NodeLocation(1, 24), "parse_duration", false))), ImmutableList.of(new StringLiteral(new NodeLocation(1, 39), "3601s")))));
assertThatThrownBy(() -> executeSetTimeZone(setTimeZone, stateMachine)).isInstanceOf(TrinoException.class).hasMessage("Invalid time zone offset interval: interval contains seconds");
}
use of io.trino.sql.tree.StringLiteral in project trino by trinodb.
the class TestSetTimeZoneTask method testSetTimeZoneVarcharFunctionCall.
@Test
public void testSetTimeZoneVarcharFunctionCall() {
QueryStateMachine stateMachine = createQueryStateMachine("SET TIME ZONE concat_ws('/', 'America', 'Los_Angeles')");
SetTimeZone setTimeZone = new SetTimeZone(new NodeLocation(1, 1), Optional.of(new FunctionCall(new NodeLocation(1, 15), QualifiedName.of(ImmutableList.of(new Identifier(new NodeLocation(1, 15), "concat_ws", false))), ImmutableList.of(new StringLiteral(new NodeLocation(1, 25), "/"), new StringLiteral(new NodeLocation(1, 30), "America"), new StringLiteral(new NodeLocation(1, 41), "Los_Angeles")))));
executeSetTimeZone(setTimeZone, stateMachine);
Map<String, String> setSessionProperties = stateMachine.getSetSessionProperties();
assertThat(setSessionProperties).hasSize(1);
assertEquals(setSessionProperties.get(TIME_ZONE_ID), "America/Los_Angeles");
}
use of io.trino.sql.tree.StringLiteral in project trino by trinodb.
the class TestSetTimeZoneTask method testSetTimeZoneIntervalDayTimeTypeFunctionCall.
@Test
public void testSetTimeZoneIntervalDayTimeTypeFunctionCall() {
QueryStateMachine stateMachine = createQueryStateMachine("SET TIME ZONE parse_duration('8h')");
SetTimeZone setTimeZone = new SetTimeZone(new NodeLocation(1, 1), Optional.of(new FunctionCall(new NodeLocation(1, 24), QualifiedName.of(ImmutableList.of(new Identifier(new NodeLocation(1, 24), "parse_duration", false))), ImmutableList.of(new StringLiteral(new NodeLocation(1, 39), "8h")))));
executeSetTimeZone(setTimeZone, stateMachine);
Map<String, String> setSessionProperties = stateMachine.getSetSessionProperties();
assertThat(setSessionProperties).hasSize(1);
assertEquals(setSessionProperties.get(TIME_ZONE_ID), "+08:00");
}
use of io.trino.sql.tree.StringLiteral in project trino by trinodb.
the class TestSetPropertiesTask method testSetMaterializedViewProperties.
@Test
public void testSetMaterializedViewProperties() {
QualifiedObjectName materializedViewName = qualifiedObjectName("test_materialized_view");
metadata.createMaterializedView(testSession, materializedViewName, someMaterializedView(), false, false);
// set all properties to non-DEFAULT values and check the results
executeSetProperties(new SetProperties(MATERIALIZED_VIEW, asQualifiedName(materializedViewName), ImmutableList.of(new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_1_NAME), new LongLiteral("111")), new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_2_NAME), new StringLiteral("abc")))));
assertThat(metadata.getMaterializedView(testSession, materializedViewName).get().getProperties()).isEqualTo(ImmutableMap.of(MATERIALIZED_VIEW_PROPERTY_1_NAME, 111L, MATERIALIZED_VIEW_PROPERTY_2_NAME, "abc"));
// set all properties to DEFAULT and check the results
executeSetProperties(new SetProperties(MATERIALIZED_VIEW, asQualifiedName(materializedViewName), ImmutableList.of(new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_1_NAME)), new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_2_NAME)))));
// since the default value of property 1 is null, property 1 should not appear in the result, whereas property 2 should appear in
// the result with its (non-null) default value
assertThat(metadata.getMaterializedView(testSession, materializedViewName).get().getProperties()).isEqualTo(ImmutableMap.of(MATERIALIZED_VIEW_PROPERTY_2_NAME, MATERIALIZED_VIEW_PROPERTY_2_DEFAULT_VALUE));
}
use of io.trino.sql.tree.StringLiteral in project trino by trinodb.
the class TestSetSessionTask method testSetSessionWithParameters.
@Test
public void testSetSessionWithParameters() {
FunctionCall functionCall = new TestingFunctionResolution(transactionManager, plannerContext).functionCallBuilder(QualifiedName.of("concat")).addArgument(VARCHAR, new StringLiteral("ban")).addArgument(VARCHAR, new Parameter(0)).build();
testSetSessionWithParameters("bar", functionCall, "banana", ImmutableList.of(new StringLiteral("ana")));
}
Aggregations