@Override public List<?> translate(Function function) { Expression ex = function.getParameters().get(0); if ((ex instanceof ColumnReference && "date" .equalsIgnoreCase( ((ColumnReference) ex).getMetadataObject().getNativeType())) // $NON-NLS-1$ || (!(ex instanceof ColumnReference) && !(ex instanceof Literal) && !(ex instanceof Function))) { ex = ConvertModifier.createConvertFunction( getLanguageFactory(), function.getParameters().get(0), TypeFacility.RUNTIME_NAMES.TIMESTAMP); function.getParameters().set(0, ex); } return super.translate(function); }
@Override public String getSourceComment(ExecutionContext context, Command command) { String comment = super.getSourceComment(context, command); boolean usingPayloadComment = false; if (context != null) { // Check for db hints Object payload = context.getCommandPayload(); if (payload instanceof String) { String payloadString = (String) payload; if (payloadString.startsWith(HINT_PREFIX)) { int i = payloadString.indexOf(HINT_SUFFIX); if (i > 0 && payloadString.substring(i + 2).trim().length() == 0) { comment += payloadString + " "; // $NON-NLS-1$ usingPayloadComment = true; } else { String msg = JDBCPlugin.Util.gs( JDBCPlugin.Event.TEIID11003, "Execution Payload", payloadString); // $NON-NLS-1$ context.addWarning(new TranslatorException(msg)); LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg); } } } } if (!usingPayloadComment && context != null) { String hint = context.getSourceHint(); if (context.getGeneralHint() != null) { if (hint != null) { hint += (" " + context.getGeneralHint()); // $NON-NLS-1$ } else { hint = context.getGeneralHint(); } } if (hint != null) { // append a source hint if (!hint.contains(HINT_PREFIX)) { comment += HINT_PREFIX + ' ' + hint + ' ' + HINT_SUFFIX + ' '; } else { String msg = JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID11003, "Source Hint", hint); // $NON-NLS-1$ context.addWarning(new TranslatorException(msg)); LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg); } } } if (command instanceof Select) { // // This simple algorithm determines the hint which will be added to the // query. // Right now, we look through all functions passed in the query // (returned as a collection) // Then we check if any of those functions are sdo_relate // If so, the ORDERED hint is added, if not, it isn't Collection<Function> col = CollectorVisitor.collectObjects(Function.class, command); for (Function func : col) { if (func.getName().equalsIgnoreCase(OracleExecutionFactory.RELATE)) { return comment + "/*+ ORDERED */ "; // $NON-NLS-1$ } } } return comment; }