Class PostgresqlSqlDialect
SqlDialect implementation for the PostgreSQL database.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.sql.SqlDialect
SqlDialect.CalendarPolicy, SqlDialect.Context, SqlDialect.DatabaseProduct, SqlDialect.FakeUtil -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SqlDialectstatic final SqlDialect.Contextstatic final RelDataTypeSystemPostgreSQL type system.Fields inherited from class org.apache.calcite.sql.SqlDialect
BUILT_IN_OPERATORS_LIST, EMPTY_CONTEXT, identifierEndQuoteString, identifierEscapedQuote, identifierQuoteString, literalEndQuoteString, literalEscapedQuote, literalQuoteString, LOGGER, nullCollation -
Constructor Summary
ConstructorsConstructorDescriptionPostgresqlSqlDialect(SqlDialect.Context context) Creates a PostgresqlSqlDialect. -
Method Summary
Modifier and TypeMethodDescription@Nullable SqlNodegetCastSpec(RelDataType type) Returns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.booleanWhether a sub-query in the FROM clause must have an alias.rewriteMaxMinExpr(SqlNode aggCall, RelDataType relDataType) Rewrites MAX(x)/MIN(x) as BOOL_OR(x)/BOOL_AND(x) for certain database variants (Postgres and Redshift, currently).rewriteSingleValueExpr(SqlNode aggCall, RelDataType relDataType) Rewrites SINGLE_VALUE into expression based on database variants E.g.booleansupportGenerateSelectStar(RelNode relNode) Returns whether this dialect supports generate 'SELECT *'.booleanReturns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`.booleansupportsFunction(SqlOperator operator, RelDataType type, List<RelDataType> paramTypes) Returns whether this dialect supports a given function or operator.booleanReturns whether the dialect supports GROUP BY literals.booleanReturns whether the dialect supports implicit type coercion.booleanReturns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1)).booleanvoidunparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) voidunparseSqlSetOption(SqlWriter writer, int leftPrec, int rightPrec, SqlSetOption option) Methods inherited from class org.apache.calcite.sql.SqlDialect
allowsAs, configureParser, configureParser, containsNonAscii, create, defaultNullDirection, emulateJoinTypeForCrossJoin, emulateNullDirection, emulateNullDirectionWithIsNull, getCalendarPolicy, getConformance, getDatabaseProduct, getFormatModel, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, prepareUnparse, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, rewriteMaxMin, supportBooleanCaseWhen, supportsAggregateFunction, supportsAggregateFunctionFilter, supportsAliasedValues, supportsApproxCountDistinct, supportsDataType, supportsGroupByWithCube, supportsGroupByWithRollup, supportsJoinType, supportsOffsetFetch, supportsTimestampPrecision, supportsWindowFunctions, unparseBoolLiteral, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseNumericLiteral, unparseOffset, unparseOffsetFetch, unparseSqlDatetimeArithmetic, unparseSqlIntervalLiteral, unparseSqlIntervalQualifier, unparseTableScanHints, unparseTopN, unquoteStringLiteral
-
Field Details
-
POSTGRESQL_TYPE_SYSTEM
PostgreSQL type system. -
DEFAULT_CONTEXT
-
DEFAULT
-
-
Constructor Details
-
PostgresqlSqlDialect
Creates a PostgresqlSqlDialect.
-
-
Method Details
-
supportsCharSet
public boolean supportsCharSet()Description copied from class:SqlDialectReturns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`.- Overrides:
supportsCharSetin classSqlDialect
-
getCastSpec
Description copied from class:SqlDialectReturns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.If this method returns null, the cast will be omitted. In the default implementation, this is the case for the NULL type, and therefore
CAST(NULL AS <nulltype>)is rendered asNULL.- Overrides:
getCastSpecin classSqlDialect
-
rewriteSingleValueExpr
Description copied from class:SqlDialectRewrites SINGLE_VALUE into expression based on database variants E.g. HSQLDB, MYSQL, ORACLE, etc.- Overrides:
rewriteSingleValueExprin classSqlDialect
-
supportsFunction
public boolean supportsFunction(SqlOperator operator, RelDataType type, List<RelDataType> paramTypes) Description copied from class:SqlDialectReturns whether this dialect supports a given function or operator. It only applies to built-in scalar functions and operators, since user-defined functions and procedures should be read by JdbcSchema.- Overrides:
supportsFunctionin classSqlDialect
-
supportsImplicitTypeCoercion
Description copied from class:SqlDialectReturns whether the dialect supports implicit type coercion.Most of the sql dialects support implicit type coercion, so we make this method default return true. For instance, "cast('10' as integer) > 5" can be simplified to "'10' > 5" if the dialect supports implicit type coercion for VARCHAR and INTEGER comparison.
For sql dialect that does not support implicit type coercion, such as the BigQuery, we can not convert '10' into INT64 implicitly.
Now this method is used for some auxiliary decision when translating some
RexCalls, see SqlImplementor#stripCastFromString for details.- Overrides:
supportsImplicitTypeCoercionin classSqlDialect- Parameters:
call- the call to make decision
-
requiresAliasForFromItems
public boolean requiresAliasForFromItems()Description copied from class:SqlDialectWhether a sub-query in the FROM clause must have an alias.For example, in PostgreSQL, this query is legal:
SELECT * FROM (SELECT * FROM Emp) As ebut remove the alias
eand it is not:SELECT * FROM (SELECT * FROM Emp)In Oracle, both queries are legal.
- Overrides:
requiresAliasForFromItemsin classSqlDialect
-
supportsNestedAggregations
public boolean supportsNestedAggregations()Description copied from class:SqlDialectReturns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1)).- Overrides:
supportsNestedAggregationsin classSqlDialect
-
supportGenerateSelectStar
Description copied from class:SqlDialectReturns whether this dialect supports generate 'SELECT *'.- Overrides:
supportGenerateSelectStarin classSqlDialect
-
unparseCall
- Overrides:
unparseCallin classSqlDialect
-
rewriteMaxMinExpr
Description copied from class:SqlDialectRewrites MAX(x)/MIN(x) as BOOL_OR(x)/BOOL_AND(x) for certain database variants (Postgres and Redshift, currently).- Overrides:
rewriteMaxMinExprin classSqlDialect- See Also:
-
supportsGroupByLiteral
public boolean supportsGroupByLiteral()Description copied from class:SqlDialectReturns whether the dialect supports GROUP BY literals.For instance, in
SqlDialect.DatabaseProduct.REDSHIFT, the following queries are illegal:select avg(salary) from emp group by true select avg(salary) from emp group by 'a', DATE '2022-01-01'- Overrides:
supportsGroupByLiteralin classSqlDialect
-
supportsOrderByLiteral
public boolean supportsOrderByLiteral()- Overrides:
supportsOrderByLiteralin classSqlDialect
-
unparseSqlSetOption
- Overrides:
unparseSqlSetOptionin classSqlDialect
-