public FullConnectorSession(Session session) { this.session = requireNonNull(session, "session is null"); this.properties = null; this.connectorId = null; this.catalog = null; this.sessionPropertyManager = null; this.isLegacyTimestamp = SystemSessionProperties.isLegacyTimestamp(session); }
public FullConnectorSession( Session session, Map<String, String> properties, ConnectorId connectorId, String catalog, SessionPropertyManager sessionPropertyManager) { this.session = requireNonNull(session, "session is null"); this.properties = ImmutableMap.copyOf(requireNonNull(properties, "properties is null")); this.connectorId = requireNonNull(connectorId, "connectorId is null"); this.catalog = requireNonNull(catalog, "catalog is null"); this.sessionPropertyManager = requireNonNull(sessionPropertyManager, "sessionPropertyManager is null"); this.isLegacyTimestamp = SystemSessionProperties.isLegacyTimestamp(session); }
private void assertCurrentDateAtInstant(TimeZoneKey timeZoneKey, long instant) { long expectedDays = epochDaysInZone(timeZoneKey, instant); long dateTimeCalculation = currentDate(new TestingConnectorSession("test", Optional.empty(), Optional.empty(), timeZoneKey, US, instant, ImmutableList.of(), ImmutableMap.of(), isLegacyTimestamp(session))); assertEquals(dateTimeCalculation, expectedDays); }
public static RowExpression translate( Expression expression, FunctionKind functionKind, Map<NodeRef<Expression>, Type> types, FunctionRegistry functionRegistry, TypeManager typeManager, Session session, boolean optimize) { Visitor visitor = new Visitor( functionKind, types, typeManager, session.getTimeZoneKey(), isLegacyRowFieldOrdinalAccessEnabled(session), SystemSessionProperties.isLegacyTimestamp(session)); RowExpression result = visitor.process(expression, null); requireNonNull(result, "translated expression is null"); if (optimize) { ExpressionOptimizer optimizer = new ExpressionOptimizer(functionRegistry, typeManager, session); return optimizer.optimize(result); } return result; }
@Override protected Type visitTimestampLiteral(TimestampLiteral node, StackableAstVisitorContext<Context> context) { try { if (SystemSessionProperties.isLegacyTimestamp(session)) { parseTimestampLiteral(session.getTimeZoneKey(), node.getValue()); } else { parseTimestampLiteral(node.getValue()); } } catch (Exception e) { throw new SemanticException(INVALID_LITERAL, node, "'%s' is not a valid timestamp literal", node.getValue()); } Type type; if (timestampHasTimeZone(node.getValue())) { type = TIMESTAMP_WITH_TIME_ZONE; } else { type = TIMESTAMP; } return setExpressionType(node, type); }
@Test public void testDateDiffTimestamp() DateTime baseDateTime = new DateTime(1960, 5, 3, 7, 2, 9, 678, isLegacyTimestamp(session) ? DATE_TIME_ZONE : UTC_TIME_ZONE); String baseDateTimeLiteral = "TIMESTAMP '1960-05-03 07:02:09.678'";