Package org.apache.spark.sql.jdbc
Class DatabricksDialect
Object
org.apache.spark.sql.jdbc.JdbcDialect
org.apache.spark.sql.jdbc.DatabricksDialect
- All Implemented Interfaces:
- Serializable,- org.apache.spark.internal.Logging,- NoLegacyJDBCError,- scala.Equals,- scala.Product
public class DatabricksDialect
extends JdbcDialect
implements NoLegacyJDBCError, scala.Product, Serializable
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.apache.spark.internal.Loggingorg.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract static Rapply()booleanCheck 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.getTableSample(org.apache.spark.sql.execution.datasources.v2.TableSampleInfo sample) booleanbooleanisSyntaxErrorBestEffort(SQLException exception) Attempts to determine if the given SQLException is a SQL syntax error.String[][]listSchemas(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) Lists all the schemas in this table.quoteIdentifier(String colName) Quotes the identifier.booleanschemasExists(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options, String schema) Check schema exists or not.booleanbooleanReturns ture if dialect supports LIMIT clause.booleanReturns ture if dialect supports OFFSET clause.booleanstatic StringtoString()Methods inherited from class org.apache.spark.sql.jdbc.JdbcDialectalterTable, beforeFetch, classifyException, classifyException, compileAggregate, compileExpression, compileValue, convertJavaDateToDate, convertJavaTimestampToTimestamp, convertJavaTimestampToTimestampNTZ, convertTimestampNTZToJavaTimestamp, createConnectionFactory, createIndex, createSchema, createTable, dropIndex, dropSchema, dropTable, functions, getAddColumnQuery, getDayTimeIntervalAsMicros, getDeleteColumnQuery, getFullyQualifiedQuotedTableName, getJdbcSQLQueryBuilder, getLimitClause, getOffsetClause, getRenameColumnQuery, getSchemaCommentQuery, getSchemaQuery, getTableCommentQuery, getTableExistsQuery, getTruncateQuery, getTruncateQuery, getUpdateColumnNullabilityQuery, getUpdateColumnTypeQuery, getYearMonthIntervalAsMonths, indexExists, insertIntoTable, isCascadingTruncateTable, isSupportedFunction, listIndexes, removeSchemaCommentQuery, renameTable, renameTable, supportsJoin, updateExtraColumnMetaMethods inherited from class java.lang.Objectequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface scala.EqualscanEqual, equalsMethods inherited from interface org.apache.spark.internal.LogginginitializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logBasedOnLevel, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, MDC, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContextMethods inherited from interface org.apache.spark.sql.jdbc.NoLegacyJDBCErrorclassifyExceptionMethods inherited from interface scala.ProductproductArity, productElement, productElementName, productElementNames, productIterator, productPrefix
- 
Constructor Details- 
DatabricksDialectpublic DatabricksDialect()
 
- 
- 
Method Details- 
applypublic abstract static R apply()
- 
toString
- 
canHandleDescription copied from class:JdbcDialectCheck if this dialect instance can handle a certain jdbc url.- Specified by:
- canHandlein class- JdbcDialect
- Parameters:
- url- the jdbc url.
- Returns:
- True if the dialect can be applied on the given jdbc url.
 
- 
isObjectNotFoundException- Overrides:
- isObjectNotFoundExceptionin class- JdbcDialect
 
- 
getCatalystTypepublic scala.Option<DataType> getCatalystType(int sqlType, String typeName, int size, MetadataBuilder md) Description copied from class:JdbcDialectGet the custom datatype mapping for the given jdbc meta information.Guidelines for mapping database defined timestamps to Spark SQL timestamps: - 
     TIMESTAMP WITHOUT TIME ZONE if preferTimestampNTZ ->
     TimestampNTZType
- 
     TIMESTAMP WITHOUT TIME ZONE if !preferTimestampNTZ ->
     TimestampType(LTZ)
- TIMESTAMP WITH TIME ZONE -> TimestampType(LTZ)
- TIMESTAMP WITH LOCAL TIME ZONE -> TimestampType(LTZ)
- 
     If the TIMESTAMP cannot be distinguished by sqlTypeandtypeName, preferTimestampNTZ is respected for now, but we may need to add another option in the future if necessary.
 - Overrides:
- getCatalystTypein class- JdbcDialect
- Parameters:
- sqlType- Refers to- Typesconstants, or other constants defined by the target database, e.g.- -101is Oracle's TIMESTAMP WITH TIME ZONE type. This value is returned by- ResultSetMetaData.getColumnType(int).
- typeName- The column type name used by the database (e.g. "BIGINT UNSIGNED"). This is sometimes used to determine the target data type when- sqlTypeis not sufficient if multiple database types are conflated into a single id. This value is returned by- ResultSetMetaData.getColumnTypeName(int).
- size- The size of the type, e.g. the maximum precision for numeric types, length for character string, etc. This value is returned by- ResultSetMetaData.getPrecision(int).
- md- Result metadata associated with this type. This contains additional information from- ResultSetMetaDataor user specified options.- 
               isTimestampNTZ: Whether read a TIMESTAMP WITHOUT TIME ZONE value asTimestampNTZTypeor not. This is configured byJDBCOptions.preferTimestampNTZ.
- 
               scale: The length of fractional partResultSetMetaData.getScale(int)
 
- 
               
- Returns:
- An option the actual DataType (subclasses of DataType) or None if the default type mapping should be used.
 
- 
     TIMESTAMP WITHOUT TIME ZONE if preferTimestampNTZ ->
     
- 
getJDBCTypeDescription copied from class:JdbcDialectRetrieve the jdbc / sql type for a given datatype.- Overrides:
- getJDBCTypein class- JdbcDialect
- Parameters:
- dt- The datatype (e.g.- StringType)
- Returns:
- The new JdbcType if there is an override for this DataType
 
- 
isSyntaxErrorBestEffortDescription copied from class:JdbcDialectAttempts to determine if the given SQLException is a SQL syntax error.This check is best-effort: it may not detect all syntax errors across all JDBC dialects. However, if this method returns true, the exception is guaranteed to be a syntax error. This is used to decide whether to wrap the exception in a more appropriate Spark exception. - Overrides:
- isSyntaxErrorBestEffortin class- JdbcDialect
- Parameters:
- exception- (undocumented)
- Returns:
- true if the exception is confidently identified as a syntax error; false otherwise.
 
- 
quoteIdentifierDescription copied from class:JdbcDialectQuotes 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:
- quoteIdentifierin class- JdbcDialect
- Parameters:
- colName- (undocumented)
- Returns:
- (undocumented)
 
- 
supportsLimitpublic boolean supportsLimit()Description copied from class:JdbcDialectReturns ture if dialect supports LIMIT clause.Note: Some build-in dialect supports LIMIT clause with some trick, please see: OracleDialect.OracleSQLQueryBuilderandMsSqlServerDialect.MsSqlServerSQLQueryBuilder.- Overrides:
- supportsLimitin class- JdbcDialect
- Returns:
- (undocumented)
 
- 
supportsOffsetpublic boolean supportsOffset()Description copied from class:JdbcDialectReturns ture if dialect supports OFFSET clause.Note: Some build-in dialect supports OFFSET clause with some trick, please see: OracleDialect.OracleSQLQueryBuilderandMySQLDialect.MySQLSQLQueryBuilder.- Overrides:
- supportsOffsetin class- JdbcDialect
- Returns:
- (undocumented)
 
- 
supportsTableSamplepublic boolean supportsTableSample()- Overrides:
- supportsTableSamplein class- JdbcDialect
 
- 
getTableSample- Overrides:
- getTableSamplein class- JdbcDialect
 
- 
supportsHintpublic boolean supportsHint()- Overrides:
- supportsHintin class- JdbcDialect
 
- 
schemasExistspublic boolean schemasExists(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options, String schema) Description copied from class:JdbcDialectCheck schema exists or not.- Overrides:
- schemasExistsin class- JdbcDialect
- Parameters:
- conn- (undocumented)
- options- (undocumented)
- schema- (undocumented)
- Returns:
- (undocumented)
 
- 
listSchemaspublic String[][] listSchemas(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) Description copied from class:JdbcDialectLists all the schemas in this table.- Overrides:
- listSchemasin class- JdbcDialect
- Parameters:
- conn- (undocumented)
- options- (undocumented)
- Returns:
- (undocumented)
 
 
-