@Test public void testSetSession() { MaterializedResult result = computeActual("SET SESSION test_string = 'bar'"); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of("test_string", "bar")); result = computeActual(format("SET SESSION %s.connector_long = 999", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_long", "999")); result = computeActual(format("SET SESSION %s.connector_string = 'baz'", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_string", "baz")); result = computeActual(format("SET SESSION %s.connector_string = 'ban' || 'ana'", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_string", "banana")); result = computeActual(format("SET SESSION %s.connector_long = 444", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_long", "444")); result = computeActual(format("SET SESSION %s.connector_long = 111 + 111", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_long", "222")); result = computeActual(format("SET SESSION %s.connector_boolean = 111 < 3", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_boolean", "false")); result = computeActual(format("SET SESSION %s.connector_double = 11.1", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_double", "11.1")); }
@Test public void testSetSession() { MaterializedResult result = computeActual("SET SESSION test_string = 'bar'"); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of("test_string", "bar")); result = computeActual(format("SET SESSION %s.connector_long = 999", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_long", "999")); result = computeActual(format("SET SESSION %s.connector_string = 'baz'", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_string", "baz")); result = computeActual(format("SET SESSION %s.connector_string = 'ban' || 'ana'", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_string", "banana")); result = computeActual(format("SET SESSION %s.connector_long = 444", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_long", "444")); result = computeActual(format("SET SESSION %s.connector_long = 111 + 111", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_long", "222")); result = computeActual(format("SET SESSION %s.connector_boolean = 111 < 3", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_boolean", "false")); result = computeActual(format("SET SESSION %s.connector_double = 11.1", TESTING_CATALOG)); assertTrue((Boolean) getOnlyElement(result).getField(0)); assertEquals(result.getSetSessionProperties(), ImmutableMap.of(TESTING_CATALOG + ".connector_double", "11.1")); }