@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Version)) { return false; } return this.compareTo((Version)obj) == 0; }
@Override protected String getUpsertKeyword() { if (getVersion().compareTo(NINE_1) >= 0) { return SQLConstants.NonReserved.UPSERT; } return SQLConstants.Reserved.MERGE; } };
@Override public String getHibernateDialectClassName() { if (getVersion().compareTo(EIGHT_2) >= 0) { return "org.hibernate.dialect.PostgreSQL82Dialect"; //$NON-NLS-1$ } return "org.hibernate.dialect.PostgreSQL81Dialect"; //$NON-NLS-1$ }
@Override public String getHibernateDialectClassName() { if (getVersion().compareTo(FIFTEEN_0_2) >= 0) { return "org.hibernate.dialect.SybaseASE15Dialect"; //$NON-NLS-1$ } return "org.hibernate.dialect.Sybase11Dialect"; //$NON-NLS-1$ }
@Override public boolean supportsRowOffset() { return getVersion().compareTo(V_4_8) >= 0; } }
@Override public boolean supportsOrderByUnrelated() { //prior to 8.10 we did not support unrelated from the grouping columns return getVersion().compareTo(EIGHT_10) >= 0; }
@Override public boolean supportsWindowFunctionNthValue() { return getVersion().compareTo(ELEVEN_2) >= 0; } }
@Override public String getHibernateDialectClassName() { if (this.getVersion().compareTo(TEN_6) >= 0) { if (this.getVersion().compareTo(TEN_7) >= 0) { return "org.hibernate.dialect.DerbyTenSevenDialect"; //$NON-NLS-1$ } return "org.hibernate.dialect.DerbyTenSixDialect"; //$NON-NLS-1$ } return "org.hibernate.dialect.DerbyTenFiveDialect"; //$NON-NLS-1$ }
@Override public String getHibernateDialectClassName() { if (getVersion().compareTo(NINE_0) >= 0) { if (getVersion().compareTo(TEN_0) >= 0) { return "org.hibernate.dialect.SQLServer2008Dialect"; //$NON-NLS-1$ } return "org.hibernate.dialect.SQLServer2005Dialect"; //$NON-NLS-1$ } return "org.hibernate.dialect.SQLServerDialect"; //$NON-NLS-1$ }
@Override public boolean supportsRecursiveCommonTableExpressions() { return getVersion().compareTo(TEN_0) >= 0; }
@Override public boolean supportsRowOffset() { return this.getVersion().compareTo(TEN_5) >= 0; }
@Override protected List<Object> convertDateToString(Function function) { if (getVersion().compareTo(TEN_0) >= 0) { return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$ } return Arrays.asList("replace(convert(varchar, ", function.getParameters().get(0), ", 102), '.', '-')"); //$NON-NLS-1$ //$NON-NLS-2$ }
protected List<?> convertTimestampToString(Function function) { if (getVersion().compareTo(FIFTEEN_5) >= 0) { return Arrays.asList("stuff(convert(varchar, ", function.getParameters().get(0), ", 23), 11, 1, ' ')"); //$NON-NLS-1$ //$NON-NLS-2$ } LinkedList<Object> result = new LinkedList<Object>(); result.addAll(convertDateToString(function)); result.add("+' '+"); //$NON-NLS-1$ result.addAll(convertTimeToString(function)); return result; }
@Override public String translateLiteralDate(Date dateValue) { if (getVersion().compareTo(TEN_0) >= 0) { return super.translateLiteralDate(dateValue); } return super.translateLiteralTimestamp(new Timestamp(dateValue.getTime())); }
@Override public String getLateralKeyword() { if (getVersion().compareTo(EIGHT_1) < 0) { return SQLConstants.Reserved.TABLE; } return super.getLateralKeyword(); }
@Override public List<?> translateLimit(Limit limit, ExecutionContext context) { if (getVersion().compareTo(ELEVEN_0) >= 0) { return Arrays.asList("OFFSET ", limit.getRowOffset(), " ROWS FETCH NEXT ", limit.getRowLimit(), " ROWS ONLY"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return super.translateLimit(limit, context); }
@Override public String translateLiteralTimestamp(Timestamp timestampValue) { if (getVersion().compareTo(TEN_0) < 0) { return super.translateLiteralTimestamp(timestampValue); } return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$ }
@Override public void initCapabilities(Connection connection) throws TranslatorException { super.initCapabilities(connection); // https://phoenix.apache.org/joins.html if(getVersion().compareTo(V_4_8) >= 0) { setSupportsInnerJoins(true); setSupportsOuterJoins(true); setSupportsFullOuterJoins(true); } }
@Override public void initCapabilities(Connection connection) throws TranslatorException { super.initCapabilities(connection); if (getVersion().compareTo(ELEVEN_2) >= 0) { AggregateAttributes aa = new AggregateAttributes(); aa.setAllowsOrderBy(true); addPushDownFunction(ORACLE, LISTAGG, STRING, STRING, STRING).setAggregateAttributes(aa); addPushDownFunction(ORACLE, LISTAGG, STRING, STRING).setAggregateAttributes(aa); } }
public AggregationOptions getOptions(int batchSize) { if (this.version.compareTo(TWO_4) < 0) { return AggregationOptions.builder().batchSize(batchSize).outputMode(AggregationOptions.OutputMode.INLINE).build(); } return AggregationOptions.builder().batchSize(batchSize).outputMode(AggregationOptions.OutputMode.CURSOR) .allowDiskUse(useDisk()).build(); } }