Package org.apache.spark.sql.jdbc
Class PostgresDialect
Object
org.apache.spark.sql.jdbc.PostgresDialect
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]alterTable(String tableName, scala.collection.Seq<TableChange> changes, int dbMajorVersion) static voidbeforeFetch(Connection connection, scala.collection.immutable.Map<String, String> properties) static booleanstatic AnalysisExceptionclassifyException(String message, Throwable e) static scala.Option<String>compileAggregate(AggregateFunc aggFunction) static scala.Option<String>compileExpression(Expression expr) static ObjectcompileValue(Object value) static org.apache.spark.sql.internal.SQLConfconf()static Timestampjava.sql timestamps are measured with millisecond accuracy (from Long.MinValue milliseconds to Long.MaxValue milliseconds), while Spark timestamps are measured at microseconds accuracy.static LocalDateTimestatic Timestampstatic scala.Function1<Object,Connection> createConnectionFactory(org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) static StringcreateIndex(String indexName, Identifier tableIdent, NamedReference[] columns, Map<NamedReference, Map<String, String>> columnsProperties, Map<String, String> properties) static voidcreateSchema(Statement statement, String schema, String comment) static voidcreateTable(Statement statement, String tableName, String strSchema, org.apache.spark.sql.execution.datasources.jdbc.JdbcOptionsInWrite options) static StringdropIndex(String indexName, Identifier tableIdent) static StringdropSchema(String schema, boolean cascade) static scala.collection.Seq<scala.Tuple2<String,UnboundFunction>> static StringgetAddColumnQuery(String tableName, String columnName, String dataType) static scala.Option<DataType>getCatalystType(int sqlType, String typeName, int size, MetadataBuilder md) static StringgetDeleteColumnQuery(String tableName, String columnName) static Stringstatic JdbcSQLQueryBuildergetJdbcSQLQueryBuilder(org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) static scala.Option<JdbcType>getJDBCType(DataType dt) static StringgetLimitClause(Integer limit) static StringgetOffsetClause(Integer offset) static StringgetRenameColumnQuery(String tableName, String columnName, String newName, int dbMajorVersion) static StringgetSchemaCommentQuery(String schema, String comment) static StringgetSchemaQuery(String table) static StringgetTableCommentQuery(String table, String comment) static StringgetTableExistsQuery(String table) static StringgetTableSample(org.apache.spark.sql.execution.datasources.v2.TableSampleInfo sample) static StringgetTruncateQuery(String table, scala.Option<Object> cascade) The SQL query used to truncate a table.static scala.Option<Object>static StringgetUpdateColumnNullabilityQuery(String tableName, String columnName, boolean isNullable) static StringgetUpdateColumnTypeQuery(String tableName, String columnName, String newDataType) static booleanindexExists(Connection conn, String indexName, Identifier tableIdent, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) static scala.Option<Object>static booleanisSupportedFunction(String funcName) static TableIndex[]listIndexes(Connection conn, Identifier tableIdent, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) static String[][]listSchemas(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) static org.slf4j.Loggerstatic voidorg$apache$spark$internal$Logging$$log__$eq(org.slf4j.Logger x$1) static StringquoteIdentifier(String colName) static StringremoveSchemaCommentQuery(String schema) static StringrenameTable(Identifier oldTable, Identifier newTable) static booleanschemasExists(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options, String schema) static booleanstatic booleanstatic boolean
-
Constructor Details
-
PostgresDialect
public PostgresDialect()
-
-
Method Details
-
canHandle
-
isSupportedFunction
-
getCatalystType
public static scala.Option<DataType> getCatalystType(int sqlType, String typeName, int size, MetadataBuilder md) -
convertJavaTimestampToTimestampNTZ
-
convertTimestampNTZToJavaTimestamp
-
getJDBCType
-
isCascadingTruncateTable
-
getTruncateQuery
The SQL query used to truncate a table. For Postgres, the default behaviour is to also truncate any descendant tables. As this is a (possibly unwanted) side-effect, the Postgres dialect adds 'ONLY' to truncate only the table in question- Parameters:
table- The table to truncatecascade- Whether or not to cascade the truncation. Default value is the value of isCascadingTruncateTable(). Cascading a truncation will truncate tables with a foreign key relationship to the target table. However, it will not truncate tables with an inheritance relationship to the target table, as the truncate query always includes "ONLY" to prevent this behaviour.- Returns:
- The SQL query to use for truncating a table
-
beforeFetch
public static void beforeFetch(Connection connection, scala.collection.immutable.Map<String, String> properties) -
getUpdateColumnTypeQuery
-
getUpdateColumnNullabilityQuery
-
createIndex
public static String createIndex(String indexName, Identifier tableIdent, NamedReference[] columns, Map<NamedReference, Map<String, String>> columnsProperties, Map<String, String> properties) -
indexExists
public static boolean indexExists(Connection conn, String indexName, Identifier tableIdent, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) -
dropIndex
-
classifyException
-
supportsLimit
public static boolean supportsLimit() -
supportsOffset
public static boolean supportsOffset() -
supportsTableSample
public static boolean supportsTableSample() -
getTableSample
public static String getTableSample(org.apache.spark.sql.execution.datasources.v2.TableSampleInfo sample) -
renameTable
-
convertJavaTimestampToTimestamp
java.sql timestamps are measured with millisecond accuracy (from Long.MinValue milliseconds to Long.MaxValue milliseconds), while Spark timestamps are measured at microseconds accuracy. For the "infinity values" in PostgreSQL (represented by big constants), we need clamp them to avoid overflow. If it is not one of the infinity values, fall back to default behavior.- Parameters:
t- (undocumented)- Returns:
- (undocumented)
-
createConnectionFactory
public static scala.Function1<Object,Connection> createConnectionFactory(org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) -
quoteIdentifier
-
createTable
-
getTableExistsQuery
-
getSchemaQuery
-
getTruncateQuery$default$2
-
compileValue
-
compileExpression
-
compileAggregate
-
functions
-
createSchema
-
schemasExists
public static boolean schemasExists(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options, String schema) -
listSchemas
public static String[][] listSchemas(Connection conn, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) -
alterTable
public static String[] alterTable(String tableName, scala.collection.Seq<TableChange> changes, int dbMajorVersion) -
getAddColumnQuery
-
getRenameColumnQuery
-
getDeleteColumnQuery
-
getTableCommentQuery
-
getSchemaCommentQuery
-
removeSchemaCommentQuery
-
dropSchema
-
listIndexes
public static TableIndex[] listIndexes(Connection conn, Identifier tableIdent, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) -
getLimitClause
-
getOffsetClause
-
getJdbcSQLQueryBuilder
public static JdbcSQLQueryBuilder getJdbcSQLQueryBuilder(org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) -
getFullyQualifiedQuotedTableName
-
org$apache$spark$internal$Logging$$log_
public static org.slf4j.Logger org$apache$spark$internal$Logging$$log_() -
org$apache$spark$internal$Logging$$log__$eq
public static void org$apache$spark$internal$Logging$$log__$eq(org.slf4j.Logger x$1) -
conf
public static org.apache.spark.sql.internal.SQLConf conf()
-