Package org.apache.spark.sql.jdbc
Class AggregatedDialect
Object
org.apache.spark.sql.jdbc.JdbcDialect
org.apache.spark.sql.jdbc.AggregatedDialect
- All Implemented Interfaces:
Serializable
,org.apache.spark.internal.Logging
,scala.Serializable
AggregatedDialect can unify multiple dialects into one virtual Dialect.
Dialects are tried in order, and the first dialect that does not return a
neutral element will win.
param: dialects List of dialects.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging
org.apache.spark.internal.Logging.SparkShellLoggingFilter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if this dialect instance can handle a certain jdbc url.scala.Option<DataType>
getCatalystType
(int sqlType, String typeName, int size, MetadataBuilder md) Get the custom datatype mapping for the given jdbc meta information.scala.Option<JdbcType>
getJDBCType
(DataType dt) Retrieve the jdbc / sql type for a given datatype.getSchemaQuery
(String table) The SQL query that should be used to discover the schema of a table.getTableExistsQuery
(String table) Get the SQL query that should be used to find if the given table exists.getTruncateQuery
(String table, scala.Option<Object> cascade) The SQL query used to truncate a table.scala.Option<Object>
Return Some[true] iffTRUNCATE TABLE
causes cascading default.quoteIdentifier
(String colName) Quotes the identifier.Methods inherited from class org.apache.spark.sql.jdbc.JdbcDialect
alterTable, beforeFetch, classifyException, compileAggregate, compileExpression, compileValue, convertJavaTimestampToTimestamp, convertJavaTimestampToTimestampNTZ, convertTimestampNTZToJavaTimestamp, createConnectionFactory, createIndex, createSchema, createTable, dropIndex, dropSchema, functions, getAddColumnQuery, getDeleteColumnQuery, getFullyQualifiedQuotedTableName, getJdbcSQLQueryBuilder, getLimitClause, getOffsetClause, getRenameColumnQuery, getSchemaCommentQuery, getTableCommentQuery, getTableSample, getTruncateQuery, getUpdateColumnNullabilityQuery, getUpdateColumnTypeQuery, indexExists, isSupportedFunction, listIndexes, listSchemas, removeSchemaCommentQuery, renameTable, renameTable, schemasExists, supportsLimit, supportsOffset, supportsTableSample
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.spark.internal.Logging
initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq
-
Constructor Details
-
AggregatedDialect
-
-
Method Details
-
canHandle
Description copied from class:JdbcDialect
Check if this dialect instance can handle a certain jdbc url.- Specified by:
canHandle
in classJdbcDialect
- Parameters:
url
- the jdbc url.- Returns:
- True if the dialect can be applied on the given jdbc url.
-
getCatalystType
public scala.Option<DataType> getCatalystType(int sqlType, String typeName, int size, MetadataBuilder md) Description copied from class:JdbcDialect
Get the custom datatype mapping for the given jdbc meta information.- Overrides:
getCatalystType
in classJdbcDialect
- Parameters:
sqlType
- The sql type (see java.sql.Types)typeName
- The sql type name (e.g. "BIGINT UNSIGNED")size
- The size of the type.md
- Result metadata associated with this type.- Returns:
- The actual DataType (subclasses of
DataType
) or null if the default type mapping should be used.
-
getJDBCType
Description copied from class:JdbcDialect
Retrieve the jdbc / sql type for a given datatype.- Overrides:
getJDBCType
in classJdbcDialect
- Parameters:
dt
- The datatype (e.g.StringType
)- Returns:
- The new JdbcType if there is an override for this DataType
-
getSchemaQuery
Description copied from class:JdbcDialect
The SQL query that should be used to discover the schema of a table. It only needs to ensure that the result set has the same schema as the table, such as by calling "SELECT * ...". Dialects can override this method to return a query that works best in a particular database.- Overrides:
getSchemaQuery
in classJdbcDialect
- Parameters:
table
- The name of the table.- Returns:
- The SQL query to use for discovering the schema.
-
getTableExistsQuery
Description copied from class:JdbcDialect
Get the SQL query that should be used to find if the given table exists. Dialects can override this method to return a query that works best in a particular database.- Overrides:
getTableExistsQuery
in classJdbcDialect
- Parameters:
table
- The name of the table.- Returns:
- The SQL query to use for checking the table.
-
getTruncateQuery
The SQL query used to truncate a table.- Overrides:
getTruncateQuery
in classJdbcDialect
- Parameters:
table
- The table to truncate.cascade
- Whether or not to cascade the truncation. Default value is the value of isCascadingTruncateTable()- Returns:
- The SQL query to use for truncating a table
-
isCascadingTruncateTable
Description copied from class:JdbcDialect
Return Some[true] iffTRUNCATE TABLE
causes cascading default. Some[true] : TRUNCATE TABLE causes cascading. Some[false] : TRUNCATE TABLE does not cause cascading. None: The behavior of TRUNCATE TABLE is unknown (default).- Overrides:
isCascadingTruncateTable
in classJdbcDialect
- Returns:
- (undocumented)
-
quoteIdentifier
Description copied from class:JdbcDialect
Quotes the identifier. This is used to put quotes around the identifier in case the column name is a reserved keyword, or in case it contains characters that require quotes (e.g. space).- Overrides:
quoteIdentifier
in classJdbcDialect
- Parameters:
colName
- (undocumented)- Returns:
- (undocumented)
-