org.apache.calcite.sql.SqlDialect - java examples

Here are the examples of the java api org.apache.calcite.sql.SqlDialect taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

116 Examples 7

19 View Complete Implementation : H2SqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the H2 database.
 */
public clreplaced H2SqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new H2SqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.H2).withIdentifierQuoteString("\""));

    /**
     * Creates an H2SqlDialect.
     */
    public H2SqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }
}

19 View Complete Implementation : NeoviewSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Neoview database.
 */
public clreplaced NeoviewSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new NeoviewSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.NEOVIEW));

    /**
     * Creates a NeoviewSqlDialect.
     */
    public NeoviewSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : RedshiftSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Redshift database.
 */
public clreplaced RedshiftSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.REDSHIFT).withIdentifierQuoteString("\"").withQuotedCasing(Casing.TO_LOWER).withUnquotedCasing(Casing.TO_LOWER).withCaseSensitive(false);

    public static final SqlDialect DEFAULT = new RedshiftSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a RedshiftSqlDialect.
     */
    public RedshiftSqlDialect(Context context) {
        super(context);
    }

    @Override
    public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch) {
        unparseFetchUsingLimit(writer, offset, fetch);
    }
}

19 View Complete Implementation : CalciteSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation that produces SQL that can be parsed
 * by Apache Calcite.
 */
public clreplaced CalciteSqlDialect extends SqlDialect {

    /**
     * A dialect useful for generating SQL which can be parsed by the Apache
     * Calcite parser, in particular quoting literals and identifiers. If you
     * want a dialect that knows the full capabilities of the database, create
     * one from a connection.
     */
    public static final SqlDialect DEFAULT = new CalciteSqlDialect(emptyContext().withDatabaseProduct(DatabaseProduct.CALCITE).withIdentifierQuoteString("\""));

    /**
     * Creates a CalciteSqlDialect.
     */
    public CalciteSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : VerticaSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Vertica database.
 */
public clreplaced VerticaSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.VERTICA).withIdentifierQuoteString("\"").withUnquotedCasing(Casing.UNCHANGED);

    public static final SqlDialect DEFAULT = new VerticaSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a VerticaSqlDialect.
     */
    public VerticaSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsNestedAggregations() {
        return false;
    }
}

19 View Complete Implementation : NeoviewSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Neoview database.
 */
public clreplaced NeoviewSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.NEOVIEW);

    public static final SqlDialect DEFAULT = new NeoviewSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a NeoviewSqlDialect.
     */
    public NeoviewSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : InformixSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Informix database.
 */
public clreplaced InformixSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new InformixSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.INFORMIX));

    /**
     * Creates an InformixSqlDialect.
     */
    public InformixSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : H2SqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the H2 database.
 */
public clreplaced H2SqlDialect extends SqlDialect {

    public static final Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.H2).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new H2SqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an H2SqlDialect.
     */
    public H2SqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }
}

19 View Complete Implementation : ParaccelSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Paraccel database.
 */
public clreplaced ParaccelSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new ParaccelSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.PARACCEL).withIdentifierQuoteString("\""));

    /**
     * Creates a ParaccelSqlDialect.
     */
    public ParaccelSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : HsqldbSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Hsqldb database.
 */
public clreplaced HsqldbSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.HSQLDB);

    public static final SqlDialect DEFAULT = new HsqldbSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an HsqldbSqlDialect.
     */
    public HsqldbSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }

    @Override
    public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
        switch(call.getKind()) {
            case FLOOR:
                if (call.operandCount() != 2) {
                    super.unparseCall(writer, call, leftPrec, rightPrec);
                    return;
                }
                final SqlLiteral timeUnitNode = call.operand(1);
                final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.clreplaced);
                final String translatedLit = convertTimeUnit(timeUnit);
                SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit, timeUnitNode.getParserPosition());
                SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
                break;
            default:
                super.unparseCall(writer, call, leftPrec, rightPrec);
        }
    }

    @Override
    public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch) {
        unparseFetchUsingLimit(writer, offset, fetch);
    }

    @Override
    public SqlNode rewriteSingleValueExpr(SqlNode aggCall) {
        final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);
        final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
        final SqlNode unionOperand = SqlStdOperatorTable.VALUES.createCall(SqlParserPos.ZERO, SqlLiteral.createApproxNumeric("0", SqlParserPos.ZERO));
        // For hsqldb, generate
        // CASE COUNT(*)
        // WHEN 0 THEN NULL
        // WHEN 1 THEN MIN(<result>)
        // ELSE (VALUES 1 UNION ALL VALUES 1)
        // END
        final SqlNode caseExpr = new SqlCase(SqlParserPos.ZERO, SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand), SqlNodeList.of(SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO), SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)), SqlNodeList.of(nullLiteral, SqlStdOperatorTable.MIN.createCall(SqlParserPos.ZERO, operand)), SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO, SqlStdOperatorTable.UNION_ALL.createCall(SqlParserPos.ZERO, unionOperand, unionOperand)));
        LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr);
        return caseExpr;
    }

    private static String convertTimeUnit(TimeUnitRange unit) {
        switch(unit) {
            case YEAR:
                return "YYYY";
            case MONTH:
                return "MM";
            case DAY:
                return "DD";
            case WEEK:
                return "WW";
            case HOUR:
                return "HH24";
            case MINUTE:
                return "MI";
            case SECOND:
                return "SS";
            default:
                throw new replacedertionError("could not convert time unit to HSQLDB equivalent: " + unit);
        }
    }
}

19 View Complete Implementation : AccessSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Access database.
 */
public clreplaced AccessSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new AccessSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.ACCESS).withIdentifierQuoteString("\""));

    /**
     * Creates an AccessSqlDialect.
     */
    public AccessSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }
}

19 View Complete Implementation : FlatTableSqlQuoteUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * If KylinConfig#enableHiveDdlQuote return false, disable quote.
 * If SqlDialect is specific, use it; else use the KylinConfig#getFactTableDialect to quote identifier.
 */
public static String quoteIdentifier(String identifier, SqlDialect specificSqlDialect) {
    if (!kylinConfig.enableHiveDdlQuote()) {
        return identifier;
    }
    if (specificSqlDialect != null) {
        return specificSqlDialect.quoteIdentifier(identifier);
    }
    setQuote();
    return defaultDialect.quoteIdentifier(identifier);
}

19 View Complete Implementation : InterbaseSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Interbase database.
 */
public clreplaced InterbaseSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.INTERBASE);

    public static final SqlDialect DEFAULT = new InterbaseSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an InterbaseSqlDialect.
     */
    public InterbaseSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : DerbySqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Apache Derby database.
 */
public clreplaced DerbySqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new DerbySqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.DERBY));

    /**
     * Creates a DerbySqlDialect.
     */
    public DerbySqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : DerbySqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Apache Derby database.
 */
public clreplaced DerbySqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.DERBY);

    public static final SqlDialect DEFAULT = new DerbySqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a DerbySqlDialect.
     */
    public DerbySqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : HsqldbSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Hsqldb database.
 */
public clreplaced HsqldbSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new HsqldbSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.HSQLDB));

    /**
     * Creates an HsqldbSqlDialect.
     */
    public HsqldbSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }

    @Override
    public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
        switch(call.getKind()) {
            case FLOOR:
                if (call.operandCount() != 2) {
                    super.unparseCall(writer, call, leftPrec, rightPrec);
                    return;
                }
                final SqlLiteral timeUnitNode = call.operand(1);
                final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.clreplaced);
                final String translatedLit = convertTimeUnit(timeUnit);
                SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, translatedLit, timeUnitNode.getParserPosition());
                SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
                break;
            default:
                super.unparseCall(writer, call, leftPrec, rightPrec);
        }
    }

    @Override
    public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch) {
        unparseFetchUsingLimit(writer, offset, fetch);
    }

    @Override
    public SqlNode rewriteSingleValueExpr(SqlNode aggCall) {
        final SqlNode operand = ((SqlBasicCall) aggCall).operand(0);
        final SqlLiteral nullLiteral = SqlLiteral.createNull(SqlParserPos.ZERO);
        final SqlNode unionOperand = SqlStdOperatorTable.VALUES.createCall(SqlParserPos.ZERO, SqlLiteral.createApproxNumeric("0", SqlParserPos.ZERO));
        // For hsqldb, generate
        // CASE COUNT(*)
        // WHEN 0 THEN NULL
        // WHEN 1 THEN MIN(<result>)
        // ELSE (VALUES 1 UNION ALL VALUES 1)
        // END
        final SqlNode caseExpr = new SqlCase(SqlParserPos.ZERO, SqlStdOperatorTable.COUNT.createCall(SqlParserPos.ZERO, operand), SqlNodeList.of(SqlLiteral.createExactNumeric("0", SqlParserPos.ZERO), SqlLiteral.createExactNumeric("1", SqlParserPos.ZERO)), SqlNodeList.of(nullLiteral, SqlStdOperatorTable.MIN.createCall(SqlParserPos.ZERO, operand)), SqlStdOperatorTable.SCALAR_QUERY.createCall(SqlParserPos.ZERO, SqlStdOperatorTable.UNION_ALL.createCall(SqlParserPos.ZERO, unionOperand, unionOperand)));
        LOGGER.debug("SINGLE_VALUE rewritten into [{}]", caseExpr);
        return caseExpr;
    }

    private static String convertTimeUnit(TimeUnitRange unit) {
        switch(unit) {
            case YEAR:
                return "YYYY";
            case MONTH:
                return "MM";
            case DAY:
                return "DD";
            case WEEK:
                return "WW";
            case HOUR:
                return "HH24";
            case MINUTE:
                return "MI";
            case SECOND:
                return "SS";
            default:
                throw new replacedertionError("could not convert time unit to HSQLDB equivalent: " + unit);
        }
    }
}

19 View Complete Implementation : ParaccelSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Paraccel database.
 */
public clreplaced ParaccelSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.PARACCEL).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new ParaccelSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a ParaccelSqlDialect.
     */
    public ParaccelSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : InterbaseSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Interbase database.
 */
public clreplaced InterbaseSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new InterbaseSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.INTERBASE));

    /**
     * Creates an InterbaseSqlDialect.
     */
    public InterbaseSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : AccessSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Access database.
 */
public clreplaced AccessSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.ACCESS).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new AccessSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an AccessSqlDialect.
     */
    public AccessSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }
}

19 View Complete Implementation : OracleSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Oracle database.
 */
public clreplaced OracleSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new OracleSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.ORACLE).withIdentifierQuoteString("\""));

    /**
     * Creates an OracleSqlDialect.
     */
    public OracleSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    protected boolean allowsAs() {
        return false;
    }

    @Override
    public boolean supportsAliasedValues() {
        return false;
    }

    @Override
    public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
        if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
            SqlUtil.unparseFunctionSyntax(OracleSqlOperatorTable.SUBSTR, writer, call);
        } else {
            switch(call.getKind()) {
                case FLOOR:
                    if (call.operandCount() != 2) {
                        super.unparseCall(writer, call, leftPrec, rightPrec);
                        return;
                    }
                    final SqlLiteral timeUnitNode = call.operand(1);
                    final TimeUnitRange timeUnit = timeUnitNode.getValueAs(TimeUnitRange.clreplaced);
                    SqlCall call2 = SqlFloorFunction.replaceTimeUnitOperand(call, timeUnit.name(), timeUnitNode.getParserPosition());
                    SqlFloorFunction.unparseDatetimeFunction(writer, call2, "TRUNC", true);
                    break;
                default:
                    super.unparseCall(writer, call, leftPrec, rightPrec);
            }
        }
    }
}

19 View Complete Implementation : SybaseSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Sybase database.
 */
public clreplaced SybaseSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.SYBASE);

    public static final SqlDialect DEFAULT = new SybaseSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a SybaseSqlDialect.
     */
    public SybaseSqlDialect(Context context) {
        super(context);
    }

    @Override
    public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch) {
    // No-op; see unparseTopN.
    // Sybase uses "SELECT TOP (n)" rather than "FETCH NEXT n ROWS".
    }

    @Override
    public void unparseTopN(SqlWriter writer, SqlNode offset, SqlNode fetch) {
        // Parentheses are not required, but we use them to be consistent with
        // Microsoft SQL Server, which recommends them but does not require them.
        // 
        // Note that "fetch" is ignored.
        writer.keyword("TOP");
        writer.keyword("(");
        fetch.unparse(writer, -1, -1);
        writer.keyword(")");
    }
}

19 View Complete Implementation : TeradataSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Teradata database.
 */
public clreplaced TeradataSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.TERADATA).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new TeradataSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a TeradataSqlDialect.
     */
    public TeradataSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : AnsiSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for an unknown ANSI compatible database.
 */
public clreplaced AnsiSqlDialect extends SqlDialect {

    public static final Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.UNKNOWN).withIdentifierQuoteString("`");

    /**
     * A dialect useful for generating generic SQL. If you need to do something
     * database-specific like quoting identifiers, don't rely on this dialect to
     * do what you want.
     */
    public static final SqlDialect DEFAULT = new AnsiSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an AnsiSqlDialect.
     */
    public AnsiSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : SqlBuilder.java
Copyright Apache License 2.0
Author : apache
/**
 * Extension to {@link StringBuilder} for the purposes of creating SQL queries
 * and expressions.
 *
 * <p>Using this clreplaced helps to prevent SQL injection attacks, incorrectly
 * quoted identifiers and strings. These problems occur when you build SQL by
 * concatenating strings, and you forget to treat identifers and string literals
 * correctly. SqlBuilder has special methods for appending identifiers and
 * literals.
 */
public clreplaced SqlBuilder {

    private final StringBuilder buf;

    private final SqlDialect dialect;

    /**
     * Creates a SqlBuilder.
     *
     * @param dialect Dialect
     */
    public SqlBuilder(SqlDialect dialect) {
        replacedert dialect != null;
        this.dialect = dialect;
        this.buf = new StringBuilder();
    }

    /**
     * Creates a SqlBuilder with a given string.
     *
     * @param dialect Dialect
     * @param s       Initial contents of the buffer
     */
    public SqlBuilder(SqlDialect dialect, String s) {
        replacedert dialect != null;
        this.dialect = dialect;
        this.buf = new StringBuilder(s);
    }

    /**
     * Returns the dialect.
     *
     * @return dialect
     */
    public SqlDialect getDialect() {
        return dialect;
    }

    /**
     * Returns the length (character count).
     *
     * @return the length of the sequence of characters currently
     * represented by this object
     */
    public int length() {
        return buf.length();
    }

    /**
     * Clears the contents of the buffer.
     */
    public void clear() {
        buf.setLength(0);
    }

    /**
     * {@inheritDoc}
     *
     * <p>Returns the SQL string.
     *
     * @return SQL string
     * @see #getSql()
     */
    @Override
    public String toString() {
        return getSql();
    }

    /**
     * Returns the SQL.
     */
    public String getSql() {
        return buf.toString();
    }

    /**
     * Returns the SQL and clears the buffer.
     *
     * <p>Convenient if you are reusing the same SQL builder in a loop.
     */
    public String getSqlAndClear() {
        final String str = buf.toString();
        clear();
        return str;
    }

    /**
     * Appends a hygienic SQL string.
     *
     * @param s SQL string to append
     * @return This builder
     */
    public SqlBuilder append(SqlString s) {
        buf.append(s.getSql());
        return this;
    }

    /**
     * Appends a string, without any quoting.
     *
     * <p>Calls to this method are dubious.
     *
     * @param s String to append
     * @return This builder
     */
    public SqlBuilder append(String s) {
        buf.append(s);
        return this;
    }

    /**
     * Appends a character, without any quoting.
     *
     * @param c Character to append
     * @return This builder
     */
    public SqlBuilder append(char c) {
        buf.append(c);
        return this;
    }

    /**
     * Appends a number, per {@link StringBuilder#append(long)}.
     */
    public SqlBuilder append(long n) {
        buf.append(n);
        return this;
    }

    /**
     * Appends an identifier to this buffer, quoting accordingly.
     *
     * @param name Identifier
     * @return This builder
     */
    public SqlBuilder identifier(String name) {
        dialect.quoteIdentifier(buf, name);
        return this;
    }

    /**
     * Appends one or more identifiers to this buffer, quoting accordingly.
     *
     * @param names Varargs array of identifiers
     * @return This builder
     */
    public SqlBuilder identifier(String... names) {
        dialect.quoteIdentifier(buf, UnmodifiableArrayList.of(names));
        return this;
    }

    /**
     * Appends a compound identifier to this buffer, quoting accordingly.
     *
     * @param names Parts of a compound identifier
     * @return This builder
     */
    public SqlBuilder identifier(List<String> names) {
        dialect.quoteIdentifier(buf, names);
        return this;
    }

    /**
     * Returns the contents of this SQL buffer as a 'certified kocher' SQL
     * string.
     *
     * <p>Use this method in preference to {@link #toString()}. It indicates
     * that the SQL string has been constructed using good hygiene, and is
     * therefore less likely to contain SQL injection or badly quoted
     * identifiers or strings.
     *
     * @return Contents of this builder as a SQL string.
     */
    public SqlString toSqlString() {
        return new SqlString(dialect, buf.toString());
    }

    /**
     * Appends a string literal to this buffer.
     *
     * <p>For example, calling <code>literal("can't")</code>
     * would convert the buffer
     * <blockquote><code>SELECT </code></blockquote>
     * to
     * <blockquote><code>SELECT 'can''t'</code></blockquote>
     *
     * @param s String to append
     * @return This buffer
     */
    public SqlBuilder literal(String s) {
        buf.append(s == null ? "null" : dialect.quoteStringLiteral(s));
        return this;
    }

    /**
     * Appends a timestamp literal to this buffer.
     *
     * @param timestamp Timestamp to append
     * @return This buffer
     */
    public SqlBuilder literal(Timestamp timestamp) {
        buf.append(timestamp == null ? "null" : dialect.quoteTimestampLiteral(timestamp));
        return this;
    }

    /**
     * Returns the index within this string of the first occurrence of the
     * specified substring.
     *
     * @see StringBuilder#indexOf(String)
     */
    public int indexOf(String str) {
        return buf.indexOf(str);
    }

    /**
     * Returns the index within this string of the first occurrence of the
     * specified substring, starting at the specified index.
     *
     * @see StringBuilder#indexOf(String, int)
     */
    public int indexOf(String str, int fromIndex) {
        return buf.indexOf(str, fromIndex);
    }

    /**
     * Inserts the string into this character sequence.
     *
     * @see StringBuilder#insert(int, String)
     */
    public SqlBuilder insert(int offset, String str) {
        buf.insert(offset, str);
        return this;
    }
}

19 View Complete Implementation : InfobrightSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Infobright database.
 */
public clreplaced InfobrightSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.INFOBRIGHT).withIdentifierQuoteString("`");

    public static final SqlDialect DEFAULT = new InfobrightSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an InfobrightSqlDialect.
     */
    public InfobrightSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }
}

19 View Complete Implementation : SqlNodes.java
Copyright Apache License 2.0
Author : dremio
/**
 * Utilities to work with SqlNode
 */
public clreplaced SqlNodes {

    private static SqlDialect DREMIO_DIALECT = new SqlDialect(DatabaseProduct.UNKNOWN, "Dremio", Character.toString(SqlUtils.QUOTE), NullCollation.FIRST);

    /**
     * @param sqlNode
     * @return SQL representation of the node
     */
    public static String toSQLString(SqlNode sqlNode) {
        SqlPrettyWriter writer = new SqlPrettyWriter(DREMIO_DIALECT);
        writer.setSelectLisreplacedemsOnSeparateLines(false);
        writer.setIndentation(0);
        writer.setQuoteAllIdentifiers(false);
        sqlNode.unparse(writer, 0, 0);
        return writer.toString();
    }

    /**
     * @param node
     * @return tree representation of the node
     */
    public static String toTreeString(SqlNode node) {
        PrinterVisitor visitor = new PrinterVisitor();
        node.accept(visitor);
        return visitor.toString();
    }
}

19 View Complete Implementation : JdbcConvention.java
Copyright Apache License 2.0
Author : bitnine-oss
/**
 * Calling convention for relational operations that occur in a JDBC
 * database.
 * <p/>
 * <p>The convention is a slight misnomer. The operations occur in whatever
 * data-flow architecture the database uses internally. Nevertheless, the result
 * pops out in JDBC.</p>
 * <p/>
 * <p>This is the only convention, thus far, that is not a singleton. Each
 * instance contains a JDBC schema (and therefore a data source). If Calcite is
 * working with two different databases, it would even make sense to convert
 * from "JDBC#A" convention to "JDBC#B", even though we don't do it currently.
 * (That would involve asking database B to open a database link to database
 * A.)</p>
 * <p/>
 * <p>As a result, converter rules from and two this convention need to be
 * instantiated, at the start of planning, for each JDBC database in play.</p>
 */
public final clreplaced JdbcConvention extends Convention.Impl {

    /**
     * Cost of a JDBC node versus implementing an equivalent node in a "typical"
     * calling convention.
     */
    public static final double COST_MULTIPLIER = 0.8d;

    private final SqlDialect dialect;

    private final Expression expression;

    public JdbcConvention(SqlDialect dialect, Expression expression, String name) {
        super("JDBC." + name, JdbcRel.clreplaced);
        this.dialect = dialect;
        this.expression = expression;
    }

    public static JdbcConvention of(SqlDialect dialect, Expression expression, String name) {
        return new JdbcConvention(dialect, expression, name);
    }

    @Override
    public void register(RelOptPlanner planner) {
        for (RelOptRule rule : JdbcRules.rules(this)) {
            planner.addRule(rule);
        }
        planner.addRule(FilterSetOpTransposeRule.INSTANCE);
        planner.addRule(ProjectRemoveRule.INSTANCE);
    }

    public SqlDialect getDialect() {
        return dialect;
    }

    public Expression getExpression() {
        return expression;
    }
}

19 View Complete Implementation : IngresSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Ingres database.
 */
public clreplaced IngresSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.INGRES);

    public static final SqlDialect DEFAULT = new IngresSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an IngresSqlDialect.
     */
    public IngresSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : AnsiSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for an unknown ANSI compatible database.
 */
public clreplaced AnsiSqlDialect extends SqlDialect {

    /**
     * A dialect useful for generating generic SQL. If you need to do something
     * database-specific like quoting identifiers, don't rely on this dialect to
     * do what you want.
     */
    public static final SqlDialect DEFAULT = new AnsiSqlDialect(emptyContext().withDatabaseProduct(DatabaseProduct.UNKNOWN).withIdentifierQuoteString("`"));

    /**
     * Creates an AnsiSqlDialect.
     */
    public AnsiSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : Db2SqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the IBM DB2 database.
 */
public clreplaced Db2SqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.DB2);

    public static final SqlDialect DEFAULT = new Db2SqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a Db2SqlDialect.
     */
    public Db2SqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean hasImplicitTableAlias() {
        return false;
    }

    @Override
    public void unparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) {
        // DB2 supported qualifiers. Singular form of these keywords are also acceptable.
        // YEAR/YEARS
        // MONTH/MONTHS
        // DAY/DAYS
        // HOUR/HOURS
        // MINUTE/MINUTES
        // SECOND/SECONDS
        switch(qualifier.timeUnitRange) {
            case YEAR:
            case MONTH:
            case DAY:
            case HOUR:
            case MINUTE:
            case SECOND:
            case MICROSECOND:
                final String timeUnit = qualifier.timeUnitRange.startUnit.name();
                writer.keyword(timeUnit);
                break;
            default:
                throw new replacedertionError("Unsupported type: " + qualifier.timeUnitRange);
        }
        if (null != qualifier.timeUnitRange.endUnit) {
            throw new replacedertionError("Unsupported end unit: " + qualifier.timeUnitRange.endUnit);
        }
    }

    @Override
    public void unparseSqlIntervalLiteral(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec) {
        // A duration is a positive or negative number representing an interval of time.
        // If one operand is a date, the other labeled duration of YEARS, MONTHS, or DAYS.
        // If one operand is a time, the other must be labeled duration of HOURS, MINUTES, or SECONDS.
        // If one operand is a timestamp, the other operand can be any of teh duration.
        SqlIntervalLiteral.IntervalValue interval = (SqlIntervalLiteral.IntervalValue) literal.getValue();
        if (interval.getSign() == -1) {
            writer.print("-");
        }
        writer.literal(literal.getValue().toString());
        unparseSqlIntervalQualifier(writer, interval.getIntervalQualifier(), RelDataTypeSystem.DEFAULT);
    }
}

19 View Complete Implementation : Db2SqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the IBM DB2 database.
 */
public clreplaced Db2SqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new Db2SqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.DB2));

    /**
     * Creates a Db2SqlDialect.
     */
    public Db2SqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean hasImplicitTableAlias() {
        return false;
    }

    @Override
    public void unparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) {
        // DB2 supported qualifiers. Singular form of these keywords are also acceptable.
        // YEAR/YEARS
        // MONTH/MONTHS
        // DAY/DAYS
        // HOUR/HOURS
        // MINUTE/MINUTES
        // SECOND/SECONDS
        switch(qualifier.timeUnitRange) {
            case YEAR:
            case MONTH:
            case DAY:
            case HOUR:
            case MINUTE:
            case SECOND:
            case MICROSECOND:
                final String timeUnit = qualifier.timeUnitRange.startUnit.name();
                writer.keyword(timeUnit);
                break;
            default:
                throw new replacedertionError("Unsupported type: " + qualifier.timeUnitRange);
        }
        if (null != qualifier.timeUnitRange.endUnit) {
            throw new replacedertionError("Unsupported end unit: " + qualifier.timeUnitRange.endUnit);
        }
    }

    @Override
    public void unparseSqlIntervalLiteral(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec) {
        // A duration is a positive or negative number representing an interval of time.
        // If one operand is a date, the other labeled duration of YEARS, MONTHS, or DAYS.
        // If one operand is a time, the other must be labeled duration of HOURS, MINUTES, or SECONDS.
        // If one operand is a timestamp, the other operand can be any of teh duration.
        SqlIntervalLiteral.IntervalValue interval = (SqlIntervalLiteral.IntervalValue) literal.getValue();
        if (interval.getSign() == -1) {
            writer.print("-");
        }
        writer.literal(literal.getValue().toString());
        unparseSqlIntervalQualifier(writer, interval.getIntervalQualifier(), RelDataTypeSystem.DEFAULT);
    }
}

19 View Complete Implementation : LucidDbSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the LucidDB database.
 */
public clreplaced LucidDbSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.LUCIDDB).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new LucidDbSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a LucidDbSqlDialect.
     */
    public LucidDbSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : FirebirdSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Firebird database.
 */
public clreplaced FirebirdSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new FirebirdSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.FIREBIRD));

    /**
     * Creates a FirebirdSqlDialect.
     */
    public FirebirdSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : Lattice.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates a context to which SQL can be generated.
 */
public SqlWriter createSqlWriter(SqlDialect dialect, StringBuilder buf, IntFunction<SqlNode> field) {
    return new SqlWriter(this, dialect, buf, new SqlImplementor.SimpleContext(dialect, field));
}

19 View Complete Implementation : HiveSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Apache Hive database.
 */
public clreplaced HiveSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new HiveSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.HIVE).withNullCollation(NullCollation.LOW));

    private final boolean emulateNullDirection;

    /**
     * Creates a HiveSqlDialect.
     */
    public HiveSqlDialect(Context context) {
        super(context);
        // Since 2.1.0, Hive natively supports "NULLS FIRST" and "NULLS LAST".
        // See https://issues.apache.org/jira/browse/HIVE-12994.
        emulateNullDirection = (context.databaseMajorVersion() < 2) || (context.databaseMajorVersion() == 2 && context.databaseMinorVersion() < 1);
    }

    @Override
    protected boolean allowsAs() {
        return false;
    }

    @Override
    public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch) {
        unparseFetchUsingLimit(writer, offset, fetch);
    }

    @Override
    public SqlNode emulateNullDirection(SqlNode node, boolean nullsFirst, boolean desc) {
        if (emulateNullDirection) {
            return emulateNullDirectionWithIsNull(node, nullsFirst, desc);
        }
        return null;
    }

    @Override
    public void unparseCall(final SqlWriter writer, final SqlCall call, final int leftPrec, final int rightPrec) {
        switch(call.getKind()) {
            case POSITION:
                final SqlWriter.Frame frame = writer.startFunCall("INSTR");
                writer.sep(",");
                call.operand(1).unparse(writer, leftPrec, rightPrec);
                writer.sep(",");
                call.operand(0).unparse(writer, leftPrec, rightPrec);
                if (3 == call.operandCount()) {
                    throw new RuntimeException("3rd operand Not Supported for Function INSTR in Hive");
                }
                writer.endFunCall(frame);
                break;
            case MOD:
                SqlOperator op = SqlStdOperatorTable.PERCENT_REMAINDER;
                SqlSyntax.BINARY.unparse(writer, op, call, leftPrec, rightPrec);
                break;
            default:
                super.unparseCall(writer, call, leftPrec, rightPrec);
        }
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }
}

19 View Complete Implementation : NetezzaSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Netezza database.
 */
public clreplaced NetezzaSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.NETEZZA).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new NetezzaSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a NetezzaSqlDialect.
     */
    public NetezzaSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : InfobrightSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Infobright database.
 */
public clreplaced InfobrightSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new InfobrightSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.INFOBRIGHT).withIdentifierQuoteString("`"));

    /**
     * Creates an InfobrightSqlDialect.
     */
    public InfobrightSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsWindowFunctions() {
        return false;
    }
}

19 View Complete Implementation : FirebirdSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Firebird database.
 */
public clreplaced FirebirdSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.FIREBIRD);

    public static final SqlDialect DEFAULT = new FirebirdSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a FirebirdSqlDialect.
     */
    public FirebirdSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : IngresSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Ingres database.
 */
public clreplaced IngresSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new IngresSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.INGRES));

    /**
     * Creates an IngresSqlDialect.
     */
    public IngresSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : PhoenixSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Apache Phoenix database.
 */
public clreplaced PhoenixSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.PHOENIX).withIdentifierQuoteString("\"");

    public static final SqlDialect DEFAULT = new PhoenixSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a PhoenixSqlDialect.
     */
    public PhoenixSqlDialect(Context context) {
        super(context);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }
}

19 View Complete Implementation : LucidDbSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the LucidDB database.
 */
public clreplaced LucidDbSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new LucidDbSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.LUCIDDB).withIdentifierQuoteString("\""));

    /**
     * Creates a LucidDbSqlDialect.
     */
    public LucidDbSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : JdbcConvention.java
Copyright Apache License 2.0
Author : apache
/**
 * Calling convention for relational operations that occur in a JDBC
 * database.
 *
 * <p>The convention is a slight misnomer. The operations occur in whatever
 * data-flow architecture the database uses internally. Nevertheless, the result
 * pops out in JDBC.</p>
 *
 * <p>This is the only convention, thus far, that is not a singleton. Each
 * instance contains a JDBC schema (and therefore a data source). If Calcite is
 * working with two different databases, it would even make sense to convert
 * from "JDBC#A" convention to "JDBC#B", even though we don't do it currently.
 * (That would involve asking database B to open a database link to database
 * A.)</p>
 *
 * <p>As a result, converter rules from and to this convention need to be
 * instantiated, at the start of planning, for each JDBC database in play.</p>
 */
public clreplaced JdbcConvention extends Convention.Impl {

    /**
     * Cost of a JDBC node versus implementing an equivalent node in a "typical"
     * calling convention.
     */
    public static final double COST_MULTIPLIER = 0.8d;

    public final SqlDialect dialect;

    public final Expression expression;

    public JdbcConvention(SqlDialect dialect, Expression expression, String name) {
        super("JDBC." + name, JdbcRel.clreplaced);
        this.dialect = dialect;
        this.expression = expression;
    }

    public static JdbcConvention of(SqlDialect dialect, Expression expression, String name) {
        return new JdbcConvention(dialect, expression, name);
    }

    @Override
    public void register(RelOptPlanner planner) {
        for (RelOptRule rule : JdbcRules.rules(this)) {
            planner.addRule(rule);
        }
        planner.addRule(FilterSetOpTransposeRule.INSTANCE);
        planner.addRule(ProjectRemoveRule.INSTANCE);
    }
}

19 View Complete Implementation : NetezzaSqlDialect.java
Copyright Apache License 2.0
Author : lealone
/**
 * A <code>SqlDialect</code> implementation for the Netezza database.
 */
public clreplaced NetezzaSqlDialect extends SqlDialect {

    public static final SqlDialect DEFAULT = new NetezzaSqlDialect(EMPTY_CONTEXT.withDatabaseProduct(DatabaseProduct.NETEZZA).withIdentifierQuoteString("\""));

    /**
     * Creates a NetezzaSqlDialect.
     */
    public NetezzaSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : SnowflakeSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Snowflake database.
 */
public clreplaced SnowflakeSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.SNOWFLAKE).withIdentifierQuoteString("\"").withUnquotedCasing(Casing.TO_UPPER);

    public static final SqlDialect DEFAULT = new SnowflakeSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a SnowflakeSqlDialect.
     */
    public SnowflakeSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : HiveSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Apache Hive database.
 */
public clreplaced HiveSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.HIVE).withNullCollation(NullCollation.LOW);

    public static final SqlDialect DEFAULT = new HiveSqlDialect(DEFAULT_CONTEXT);

    private final boolean emulateNullDirection;

    /**
     * Creates a HiveSqlDialect.
     */
    public HiveSqlDialect(Context context) {
        super(context);
        // Since 2.1.0, Hive natively supports "NULLS FIRST" and "NULLS LAST".
        // See https://issues.apache.org/jira/browse/HIVE-12994.
        emulateNullDirection = (context.databaseMajorVersion() < 2) || (context.databaseMajorVersion() == 2 && context.databaseMinorVersion() < 1);
    }

    @Override
    protected boolean allowsAs() {
        return false;
    }

    @Override
    public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch) {
        unparseFetchUsingLimit(writer, offset, fetch);
    }

    @Override
    public SqlNode emulateNullDirection(SqlNode node, boolean nullsFirst, boolean desc) {
        if (emulateNullDirection) {
            return emulateNullDirectionWithIsNull(node, nullsFirst, desc);
        }
        return null;
    }

    @Override
    public void unparseCall(final SqlWriter writer, final SqlCall call, final int leftPrec, final int rightPrec) {
        switch(call.getKind()) {
            case POSITION:
                final SqlWriter.Frame frame = writer.startFunCall("INSTR");
                writer.sep(",");
                call.operand(1).unparse(writer, leftPrec, rightPrec);
                writer.sep(",");
                call.operand(0).unparse(writer, leftPrec, rightPrec);
                if (3 == call.operandCount()) {
                    throw new RuntimeException("3rd operand Not Supported for Function INSTR in Hive");
                }
                writer.endFunCall(frame);
                break;
            case MOD:
                SqlOperator op = SqlStdOperatorTable.PERCENT_REMAINDER;
                SqlSyntax.BINARY.unparse(writer, op, call, leftPrec, rightPrec);
                break;
            case TRIM:
                unparseTrim(writer, call, leftPrec, rightPrec);
                break;
            case OTHER_FUNCTION:
                if (call.getOperator() instanceof SqlSubstringFunction) {
                    final SqlWriter.Frame funCallFrame = writer.startFunCall(call.getOperator().getName());
                    call.operand(0).unparse(writer, leftPrec, rightPrec);
                    writer.sep(",", true);
                    call.operand(1).unparse(writer, leftPrec, rightPrec);
                    if (3 == call.operandCount()) {
                        writer.sep(",", true);
                        call.operand(2).unparse(writer, leftPrec, rightPrec);
                    }
                    writer.endFunCall(funCallFrame);
                } else {
                    super.unparseCall(writer, call, leftPrec, rightPrec);
                }
                break;
            default:
                super.unparseCall(writer, call, leftPrec, rightPrec);
        }
    }

    /**
     * For usage of TRIM, LTRIM and RTRIM in Hive, see
     * <a href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF">Hive UDF usage</a>.
     */
    private void unparseTrim(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
        replacedert call.operand(0) instanceof SqlLiteral : call.operand(0);
        SqlLiteral flag = call.operand(0);
        final String operatorName;
        switch(flag.getValueAs(SqlTrimFunction.Flag.clreplaced)) {
            case LEADING:
                operatorName = "LTRIM";
                break;
            case TRAILING:
                operatorName = "RTRIM";
                break;
            default:
                operatorName = call.getOperator().getName();
                break;
        }
        final SqlWriter.Frame frame = writer.startFunCall(operatorName);
        call.operand(2).unparse(writer, leftPrec, rightPrec);
        writer.endFunCall(frame);
    }

    @Override
    public boolean supportsCharSet() {
        return false;
    }

    @Override
    public boolean supportsGroupByWithRollup() {
        return true;
    }

    @Override
    public boolean supportsGroupByWithCube() {
        return true;
    }

    @Override
    public boolean supportsNestedAggregations() {
        return false;
    }

    @Override
    public SqlNode getCastSpec(final RelDataType type) {
        if (type instanceof BasicSqlType) {
            switch(type.getSqlTypeName()) {
                case INTEGER:
                    SqlAlienSystemTypeNameSpec typeNameSpec = new SqlAlienSystemTypeNameSpec("INT", type.getSqlTypeName(), SqlParserPos.ZERO);
                    return new SqlDataTypeSpec(typeNameSpec, SqlParserPos.ZERO);
            }
        }
        return super.getCastSpec(type);
    }
}

19 View Complete Implementation : JdbcConvention.java
Copyright Apache License 2.0
Author : apache
public static JdbcConvention of(SqlDialect dialect, Expression expression, String name) {
    return new JdbcConvention(dialect, expression, name);
}

19 View Complete Implementation : JdbcToEnumerableConverter.java
Copyright Apache License 2.0
Author : apache
private SqlString generateSql(SqlDialect dialect) {
    final JdbcImplementor jdbcImplementor = new JdbcImplementor(dialect, (JavaTypeFactory) getCluster().getTypeFactory());
    final JdbcImplementor.Result result = jdbcImplementor.visitChild(0, getInput());
    return result.replacedtatement().toSqlString(dialect);
}

19 View Complete Implementation : CalciteSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation that produces SQL that can be parsed
 * by Apache Calcite.
 */
public clreplaced CalciteSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.CALCITE).withIdentifierQuoteString("\"");

    /**
     * A dialect useful for generating SQL which can be parsed by the Apache
     * Calcite parser, in particular quoting literals and identifiers. If you
     * want a dialect that knows the full capabilities of the database, create
     * one from a connection.
     */
    public static final SqlDialect DEFAULT = new CalciteSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates a CalciteSqlDialect.
     */
    public CalciteSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : InformixSqlDialect.java
Copyright Apache License 2.0
Author : apache
/**
 * A <code>SqlDialect</code> implementation for the Informix database.
 */
public clreplaced InformixSqlDialect extends SqlDialect {

    public static final SqlDialect.Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT.withDatabaseProduct(SqlDialect.DatabaseProduct.INFORMIX);

    public static final SqlDialect DEFAULT = new InformixSqlDialect(DEFAULT_CONTEXT);

    /**
     * Creates an InformixSqlDialect.
     */
    public InformixSqlDialect(Context context) {
        super(context);
    }
}

19 View Complete Implementation : JdbcToEnumerableConverter.java
Copyright Apache License 2.0
Author : bitnine-oss
private String generateSql(SqlDialect dialect) {
    final JdbcImplementor jdbcImplementor = new JdbcImplementor(dialect, (JavaTypeFactory) getCluster().getTypeFactory());
    final JdbcImplementor.Result result = jdbcImplementor.visitChild(0, getInput());
    return result.asQuery().toSqlString(dialect).getSql();
}