Package org.apache.calcite.sql.dialect
Class PostgresqlSqlDialect
java.lang.Object
org.apache.calcite.sql.SqlDialect
org.apache.calcite.sql.dialect.PostgresqlSqlDialect
A
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
Modifier and TypeFieldDescriptionstatic final SqlDialect
static final SqlDialect.Context
static final RelDataTypeSystem
PostgreSQL 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
ConstructorDescriptionPostgresqlSqlDialect
(SqlDialect.Context context) Creates a PostgresqlSqlDialect. -
Method Summary
Modifier and TypeMethodDescription@Nullable SqlNode
getCastSpec
(RelDataType type) Returns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.boolean
Whether 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.boolean
Returns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`
.boolean
supportsFunction
(SqlOperator operator, RelDataType type, List<RelDataType> paramTypes) Returns whether this dialect supports a given function or operator.boolean
Returns whether the dialect supports GROUP BY literals.boolean
Returns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1))
.void
unparseCall
(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) 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, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, rewriteMaxMin, supportBooleanCaseWhen, supportsAggregateFunction, supportsAggregateFunctionFilter, supportsAliasedValues, supportsApproxCountDistinct, supportsDataType, supportsGroupByWithCube, supportsGroupByWithRollup, supportsImplicitTypeCoercion, supportsJoinType, supportsOffsetFetch, supportsTimestampPrecision, supportsWindowFunctions, unparseBoolLiteral, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, 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:SqlDialect
Returns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`
.- Overrides:
supportsCharSet
in classSqlDialect
-
getCastSpec
Description copied from class:SqlDialect
Returns 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:
getCastSpec
in classSqlDialect
-
rewriteSingleValueExpr
Description copied from class:SqlDialect
Rewrites SINGLE_VALUE into expression based on database variants E.g. HSQLDB, MYSQL, ORACLE, etc.- Overrides:
rewriteSingleValueExpr
in classSqlDialect
-
supportsFunction
public boolean supportsFunction(SqlOperator operator, RelDataType type, List<RelDataType> paramTypes) Description copied from class:SqlDialect
Returns 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:
supportsFunction
in classSqlDialect
-
requiresAliasForFromItems
public boolean requiresAliasForFromItems()Description copied from class:SqlDialect
Whether 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 e
but remove the alias
e
and it is not:SELECT * FROM (SELECT * FROM Emp)
In Oracle, both queries are legal.
- Overrides:
requiresAliasForFromItems
in classSqlDialect
-
supportsNestedAggregations
public boolean supportsNestedAggregations()Description copied from class:SqlDialect
Returns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1))
.- Overrides:
supportsNestedAggregations
in classSqlDialect
-
unparseCall
- Overrides:
unparseCall
in classSqlDialect
-
rewriteMaxMinExpr
Description copied from class:SqlDialect
Rewrites MAX(x)/MIN(x) as BOOL_OR(x)/BOOL_AND(x) for certain database variants (Postgres and Redshift, currently).- Overrides:
rewriteMaxMinExpr
in classSqlDialect
- See Also:
-
supportsGroupByLiteral
public boolean supportsGroupByLiteral()Description copied from class:SqlDialect
Returns 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:
supportsGroupByLiteral
in classSqlDialect
-